diff --git a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/states/cancelled.xml b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/states/cancelled.xml new file mode 100644 index 0000000000000000000000000000000000000000..13f0fd4b0198717d89d138b1d7a2bf3911d83eb2 --- /dev/null +++ b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/states/cancelled.xml @@ -0,0 +1,108 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="StateDefinition" module="Products.DCWorkflow.States"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>description</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>cancelled</string> </value> + </item> + <item> + <key> <string>permission_roles</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>Cancelled</string> </value> + </item> + <item> + <key> <string>transitions</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>type_list</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary> + <item> + <key> <string>Access contents information</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Associate</string> + <string>Auditor</string> + <string>Manager</string> + <string>Owner</string> + </tuple> + </value> + </item> + <item> + <key> <string>Add portal content</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>Delete objects</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>Modify portal content</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>View</string> </key> + <value> + <tuple> + <string>Assignee</string> + <string>Assignor</string> + <string>Associate</string> + <string>Auditor</string> + <string>Manager</string> + <string>Owner</string> + </tuple> + </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/states/recorded.xml b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/states/recorded.xml index 0024e8a06ed48954ef712e8c91ea4f23645e81f3..c9a28c7d6e37e216dcdfbe0fd5f1ccf7580666ff 100644 --- a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/states/recorded.xml +++ b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/states/recorded.xml @@ -27,7 +27,10 @@ <item> <key> <string>transitions</string> </key> <value> - <tuple/> + <tuple> + <string>cancel</string> + <string>cancel_action</string> + </tuple> </value> </item> <item> diff --git a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/transitions/cancel.xml b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/transitions/cancel.xml new file mode 100644 index 0000000000000000000000000000000000000000..1b1dc95f748e66942891a4b25da230a820f91b3a --- /dev/null +++ b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/transitions/cancel.xml @@ -0,0 +1,80 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>actbox_category</string> </key> + <value> <string>workflow</string> </value> + </item> + <item> + <key> <string>actbox_icon</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>actbox_name</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>actbox_url</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>after_script_name</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>description</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>guard</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>cancel</string> </value> + </item> + <item> + <key> <string>new_state_id</string> </key> + <value> <string>cancelled</string> </value> + </item> + <item> + <key> <string>script_name</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>Cancel Inventory Report</string> </value> + </item> + <item> + <key> <string>trigger_type</string> </key> + <value> <int>2</int> </value> + </item> + </dictionary> + </pickle> + </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <global name="Guard" module="Products.DCWorkflow.Guard"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>roles</string> </key> + <value> + <tuple> + <string>Assignor</string> + <string>Manager</string> + </tuple> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/transitions/cancel_action.xml b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/transitions/cancel_action.xml new file mode 100644 index 0000000000000000000000000000000000000000..df8a0e5a545208228e28661abe424345fa1555c1 --- /dev/null +++ b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/inventory_report_workflow/transitions/cancel_action.xml @@ -0,0 +1,80 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>actbox_category</string> </key> + <value> <string>workflow</string> </value> + </item> + <item> + <key> <string>actbox_icon</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>actbox_name</string> </key> + <value> <string>Cancel Inventory Report</string> </value> + </item> + <item> + <key> <string>actbox_url</string> </key> + <value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=cancel_action</string> </value> + </item> + <item> + <key> <string>after_script_name</string> </key> + <value> <string>cancel</string> </value> + </item> + <item> + <key> <string>description</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>guard</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>cancel_action</string> </value> + </item> + <item> + <key> <string>new_state_id</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>script_name</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>Calcal Inventory Report Acton</string> </value> + </item> + <item> + <key> <string>trigger_type</string> </key> + <value> <int>1</int> </value> + </item> + </dictionary> + </pickle> + </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <global name="Guard" module="Products.DCWorkflow.Guard"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>roles</string> </key> + <value> + <tuple> + <string>Assignor</string> + <string>Manager</string> + </tuple> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/product/ERP5/tests/testInventoryReportModule.py b/product/ERP5/tests/testInventoryReportModule.py index f9292376a6ce1c2647cf6ea9fc8d9a9e8dc35c27..957584ebee62104f758ccff1820e3758e5ee8157 100644 --- a/product/ERP5/tests/testInventoryReportModule.py +++ b/product/ERP5/tests/testInventoryReportModule.py @@ -611,48 +611,73 @@ class TestInventoryReportModule(TestOrderMixin, SecurityTestCase): """ """ if not run: return - - user_id_list = ['test_user', 'manager'] + self.createUser('test_creator', + ['Auditor', 'Author']) + + user_id_list = ['test_creator', 'test_user', 'manager'] for user in user_id_list: self.failUnlessUserCanAddDocument(user, self.getInventoryReportModule()) - + + self.login(user_id_list[0]) inventory_report = self.getInventoryReportModule().newContent(portal_type='Inventory Report') + + self.login() + for user in user_id_list: + self.failUnlessUserCanAddDocument(user, inventory_report) + inventory_report_line = inventory_report.newContent(portal_type='Inventory Report Line') self.assertEqual(inventory_report.getSimulationState(), 'draft') self.tic() - for user in user_id_list: self.login(user) self.assertEqual(self.portal.portal_workflow.isTransitionPossible(inventory_report, 'calculate'), True) self.failUnlessUserCanModifyDocument(user, inventory_report) self.failUnlessUserCanModifyDocument(user, inventory_report_line) - + inventory_report.calculate() self.tic() self.assertEqual(inventory_report.getSimulationState(), 'calculating') - for user in user_id_list: self.login(user) self.assertEqual(self.portal.portal_workflow.isTransitionPossible(inventory_report, 'record'), True) self.failUnlessUserCanModifyDocument(user, inventory_report) self.failUnlessUserCanModifyDocument(user, inventory_report_line) - + inventory_report.record() self.tic() self.assertEqual(inventory_report.getSimulationState(), 'recorded') - + for user in user_id_list: self.login(user) self.assertEqual(self.portal.portal_workflow.isTransitionPossible(inventory_report, 'calculate'), False) - self.failIfUserCanModifyDocument('test_user', inventory_report) - self.failUnlessUserCanViewDocument('test_user', inventory_report) - self.failIfUserCanModifyDocument('test_user', inventory_report_line) - self.failUnlessUserCanViewDocument('test_user', inventory_report_line) + self.login() + self.failIfUserCanPassWorkflowTransition(user_id_list[0], 'cancel_action', inventory_report) + for user in user_id_list[1:]: + self.failUnlessUserCanPassWorkflowTransition(user, 'cancel_action', inventory_report) + + + for user in user_id_list[:-1]: + self.failIfUserCanModifyDocument(user, inventory_report) + self.failUnlessUserCanViewDocument(user, inventory_report) + self.failIfUserCanModifyDocument(user, inventory_report_line) + self.failUnlessUserCanViewDocument(user, inventory_report_line) + self.failUnlessUserCanModifyDocument('manager', inventory_report) self.failUnlessUserCanModifyDocument('manager', inventory_report_line) + inventory_report.cancel() + self.tic() + self.assertEqual(inventory_report.getSimulationState(), 'cancelled') + for user in user_id_list[:-1]: + self.failIfUserCanModifyDocument(user, inventory_report) + self.failUnlessUserCanViewDocument(user, inventory_report) + self.failIfUserCanModifyDocument(user, inventory_report_line) + self.failUnlessUserCanViewDocument(user, inventory_report_line) + + self.failUnlessUserCanModifyDocument('manager', inventory_report) + self.failUnlessUserCanModifyDocument('manager', inventory_report_line) def test_02_checkCalculateProduct(self, run=run_all_test): """