Commit d7ba4285 authored by Romain Courteaud's avatar Romain Courteaud

Alarm to update the open order line period.

parent 9c2cd8a1
<key_list>
<key>children_portal_type | catalog/portal_type/z_related_children</key>
</key_list>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_requestUpdateOpenSaleOrderPeriod</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_update_open_sale_order_period</string> </value>
</item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple>
<int>4</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>4</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>-4861728000.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Updates Open Sale Order period</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type=\'Open Sale Order\',\n
validation_state=\'validated\',\n
children_portal_type=\'Open Sale Order Line\',\n
method_id=\'OpenSaleOrder_updatePeriod\',\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_requestUpdateOpenSaleOrderPeriod</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
if context.getValidationState() == \'validated\':\n
person = context.getDestinationDecisionValue(portal_type="Person")\n
if person is not None:\n
person.Person_storeOpenSaleOrderJournal()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>OpenSaleOrder_updatePeriod</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -1673,3 +1673,139 @@ class TestSlapOSStopConfirmedAggregatedSaleInvoiceTransactionAlarm(
script = 'Delivery_stopConfirmedAggregatedSaleInvoiceTransaction'
portal_type = 'Sale Invoice Transaction'
alarm = 'slapos_stop_confirmed_aggregated_sale_invoice_transaction'
class TestSlapOSUpdateOpenSaleOrderPeriod(testSlapOSMixin):
def createOpenOrder(self):
open_order = self.portal.open_sale_order_module\
.template_open_sale_order.Base_createCloneDocument(batch_mode=1)
open_order.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTHS-%s" % self.generateNewId(),
)
open_order.order()
open_order.validate()
return open_order
def test_updatePeriod_REQUEST_disallowed(self):
self.assertRaises(
Unauthorized,
self.portal.OpenSaleOrder_updatePeriod,
REQUEST={})
def _simulatePerson_storeOpenSaleOrderJournal(self):
script_name = 'Person_storeOpenSaleOrderJournal'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by Person_storeOpenSaleOrderJournal') """ )
transaction.commit()
def _dropPerson_storeOpenSaleOrderJournal(self):
script_name = 'Person_storeOpenSaleOrderJournal'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_updatePeriod_no_person(self):
open_order = self.createOpenOrder()
open_order.OpenSaleOrder_updatePeriod()
def test_updatePeriod_validated(self):
open_order = self.createOpenOrder()
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
open_order.edit(
destination_decision_value=person,
)
self._simulatePerson_storeOpenSaleOrderJournal()
try:
open_order.OpenSaleOrder_updatePeriod()
finally:
self._dropPerson_storeOpenSaleOrderJournal()
self.assertEqual(
'Visited by Person_storeOpenSaleOrderJournal',
person.workflow_history['edit_workflow'][-1]['comment'])
def test_updatePeriod_invalidated(self):
open_order = self.createOpenOrder()
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
open_order.edit(
destination_decision_value=person,
)
open_order.invalidate()
self._simulatePerson_storeOpenSaleOrderJournal()
try:
open_order.OpenSaleOrder_updatePeriod()
finally:
self._dropPerson_storeOpenSaleOrderJournal()
self.assertNotEqual(
'Visited by Person_storeOpenSaleOrderJournal',
person.workflow_history['edit_workflow'][-1]['comment'])
def _simulateOpenSaleOrder_updatePeriod(self):
script_name = 'OpenSaleOrder_updatePeriod'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by OpenSaleOrder_updatePeriod') """ )
transaction.commit()
def _dropOpenSaleOrder_updatePeriod(self):
script_name = 'OpenSaleOrder_updatePeriod'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm(self):
open_order = self.createOpenOrder()
open_order.newContent(portal_type="Open Sale Order Line")
self.tic()
self._simulateOpenSaleOrder_updatePeriod()
try:
self.portal.portal_alarms.slapos_update_open_sale_order_period.activeSense()
self.tic()
finally:
self._dropOpenSaleOrder_updatePeriod()
self.assertEqual(
'Visited by OpenSaleOrder_updatePeriod',
open_order.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_invalidated(self):
open_order = self.createOpenOrder()
open_order.newContent(portal_type="Open Sale Order Line")
open_order.invalidate()
self.tic()
self._simulateOpenSaleOrder_updatePeriod()
try:
self.portal.portal_alarms.slapos_update_open_sale_order_period.activeSense()
self.tic()
finally:
self._dropOpenSaleOrder_updatePeriod()
self.assertNotEqual(
'Visited by OpenSaleOrder_updatePeriod',
open_order.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_no_line(self):
open_order = self.createOpenOrder()
self.tic()
self._simulateOpenSaleOrder_updatePeriod()
try:
self.portal.portal_alarms.slapos_update_open_sale_order_period.activeSense()
self.tic()
finally:
self._dropOpenSaleOrder_updatePeriod()
self.assertNotEqual(
'Visited by OpenSaleOrder_updatePeriod',
open_order.workflow_history['edit_workflow'][-1]['comment'])
243
\ No newline at end of file
244
\ No newline at end of file
children_portal_type | catalog/portal_type/z_related_children
\ No newline at end of file
......@@ -32,6 +32,7 @@ portal_alarms/slapos_stop_confirmed_aggregated_sale_invoice_transaction
portal_alarms/slapos_trigger_aggregated_delivery_order_builder
portal_alarms/slapos_trigger_build
portal_alarms/slapos_trigger_payment_transaction_order_builder
portal_alarms/slapos_update_open_sale_order_period
portal_categories/trade_phase/slapos
portal_categories/trade_phase/slapos/**
portal_categories/trade_state/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment