From 713e8a437759efb5e8dcff024955b723289e0027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 19 Mar 2024 03:40:48 +0100 Subject: [PATCH] WorkflowTool: skip worklists without reference when computing Otherwise we get an error when just adding a worklist --- .../test.erp5.testWorklist.py | 28 +++++++++++++++++++ product/ERP5Type/Tool/WorkflowTool.py | 2 ++ 2 files changed, 30 insertions(+) diff --git a/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testWorklist.py b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testWorklist.py index bc628e3e24..67e04dbe5f 100644 --- a/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testWorklist.py +++ b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testWorklist.py @@ -255,6 +255,34 @@ class TestWorklist(TestWorkflowMixin): self.worklist_int_variable_id, ]) + def test_edit_worklist_view(self): + """Checks we can view and edit worklist. + """ + def check_visible(worklist): + self.clearCache() + worklist.view() + workflow_value = self.getWorkflowTool()[self.checked_workflow] + + # edit reference first + worklist_value = workflow_value.newContent(portal_type='Worklist') + check_visible(worklist_value) + worklist_value.setReference(self.worklist_assignor_id) + check_visible(worklist_value) + worklist_value.setActionName('Test (%(count)s)') + worklist_value.setAction('/') + worklist_value.setActionType('global') + check_visible(worklist_value) + + # edit reference last + worklist_value = workflow_value.newContent(portal_type='Worklist') + check_visible(worklist_value) + worklist_value.setActionName('Test (%(count)s)') + worklist_value.setAction('/') + worklist_value.setActionType('global') + check_visible(worklist_value) + worklist_value.setReference(self.worklist_owner_id) + check_visible(worklist_value) + def test_01_permission(self, quiet=0, run=run_all_test): """ Test the permission of the building module. diff --git a/product/ERP5Type/Tool/WorkflowTool.py b/product/ERP5Type/Tool/WorkflowTool.py index ba6821a66d..f762cde080 100644 --- a/product/ERP5Type/Tool/WorkflowTool.py +++ b/product/ERP5Type/Tool/WorkflowTool.py @@ -755,6 +755,8 @@ def groupWorklistListByCondition(worklist_dict, sql_catalog, metadata_dict = {} for workflow_id, worklist in six.iteritems(worklist_dict): for worklist_id, worklist_match_dict in six.iteritems(worklist): + if not worklist_id: + continue workflow_worklist_key = '/'.join((workflow_id, worklist_id)) if getSecurityUidDictAndRoleColumnDict is None: valid_criterion_dict, metadata = getValidCriterionDict( -- 2.30.9