From 272b0be47c8a1f26019bc3af29e64fdd5e547b32 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Wed, 16 Nov 2016 14:01:48 +0000 Subject: [PATCH 01/23] multiple_catalog: Index in all the catalogs available --- product/ZSQLCatalog/ZSQLCatalog.py | 300 +++++++++++++++-------------- 1 file changed, 151 insertions(+), 149 deletions(-) diff --git a/product/ZSQLCatalog/ZSQLCatalog.py b/product/ZSQLCatalog/ZSQLCatalog.py index 29cab67824f..2c553e71db0 100644 --- a/product/ZSQLCatalog/ZSQLCatalog.py +++ b/product/ZSQLCatalog/ZSQLCatalog.py @@ -716,147 +716,145 @@ class ZCatalog(Folder, Persistent, Implicit): immediate_reindex_archive=1, **kw): """Catalog a list of objects. """ - catalog = self.getSQLCatalog(sql_catalog_id) - hot_reindexing = (self.hot_reindexing_state is not None) and \ - (catalog is not None) and \ - (self.source_sql_catalog_id == catalog.id) - archiving = self.archive_path is not None - failed_object_list = [] - url_list = [] - archive_list = [] - portal_archives = getattr(self, 'portal_archives', None) - if portal_archives is not None: - if len(portal_archives): - archive_list = portal_archives.getArchiveList() - - catalog_dict = {} - - # Create archive object list if necessary - if archiving: - # while archiving only test with the archive we used, do not care - # of other as they must already be ok - archive = self.unrestrictedTraverse(self.archive_path) - archive_obj_list = [archive,] - for archive_path in archive_list: - try: - archive = self.unrestrictedTraverse(archive_path) - except KeyError: - continue - if archive.getCatalogId() == self.destination_sql_catalog_id: - archive_obj_list.append(archive) - else: - # otherwise take all archive in use to know where object must go - archive_obj_list = [] - for archive_path in archive_list: - try: - archive = self.unrestrictedTraverse(archive_path) - except KeyError: - continue - archive_obj_list.append(archive) - - archive_enabled = (not disable_archive) \ - and (archiving or (archive_obj_list and sql_catalog_id is None)) - if archive_enabled: - default_catalog = self.getSQLCatalog() - - # Construct list of object to catalogged - current_catalog_object_list = [] - for obj in object_list: - if hot_reindexing: - try: - url = obj.getPhysicalPath - except AttributeError: - raise CatalogError( - "A cataloged object must support the 'getPhysicalPath' " - "method if no unique id is provided when cataloging" - ) - url = '/'.join(url()) - url_list.append(url) - - # either we are doing archiving, either we have used archive without a catalog specified - if archive_enabled: - goto_current_catalog = 0 - # check in which archive object must go if we defined archive - catalog_id = None - for archive in archive_obj_list: - if archive.test(obj) is True: - catalog_id = archive.getCatalogId() - # if current catalog, no need to construct dict as it will be reindex now - if catalog_id in (default_catalog.id, self.source_sql_catalog_id): - goto_current_catalog = 1 - continue - priority = archive.getPriority() - if catalog_dict.has_key(catalog_id): - catalog_dict[catalog_id]['obj'].append(obj) - else: - catalog_dict[catalog_id] = {'priority' : priority, 'obj' : [obj,]} - if catalog_id is None and not archiving: - # at least put object in current catalog if no archive match - # and not doing archive - goto_current_catalog = 1 + catalog_id_list = self.getERP5CatalogIdList() + for sql_catalog_id in catalog_id_list: + catalog = self.getSQLCatalog(sql_catalog_id) + hot_reindexing = (self.hot_reindexing_state is not None) and \ + (catalog is not None) and \ + (self.source_sql_catalog_id == catalog.id) + archiving = self.archive_path is not None + wrapped_object_list = [] + failed_object_list = [] + url_list = [] + archive_list = [] + portal_archives = getattr(self, 'portal_archives', None) + if portal_archives is not None: + if len(portal_archives): + archive_list = portal_archives.getArchiveList() + + catalog_dict = {} + + # Create archive object list if necessary + if archiving: + # while archiving only test with the archive we used, do not care + # of other as they must already be ok + archive = self.unrestrictedTraverse(self.archive_path) + archive_obj_list = [archive,] + for archive_path in archive_list: + try: + archive = self.unrestrictedTraverse(archive_path) + except KeyError: + continue + if archive.getCatalogId() == self.destination_sql_catalog_id: + archive_obj_list.append(archive) else: - goto_current_catalog = 1 + # otherwise take all archive in use to know where object must go + archive_obj_list = [] + for archive_path in archive_list: + try: + archive = self.unrestrictedTraverse(archive_path) + except KeyError: + continue + archive_obj_list.append(archive) - if goto_current_catalog: - current_catalog_object_list.append(obj) + archive_enabled = (not disable_archive) \ + and (archiving or (archive_obj_list and sql_catalog_id is None)) + if archive_enabled: + default_catalog = self.getSQLCatalog() - # run activity or execute for each archive depending on priority - if catalog_dict: - for catalog_id in catalog_dict.keys(): - if goto_current_catalog and catalog_id == default_catalog.id: - # if we reindex in current catalog, do not relaunch an activity for this - continue - d = catalog_dict[catalog_id] - # hot_reindexing is True when creating an object during a hot reindex, in this case, we don't want - # to reindex it in destination catalog, it will be recorded an play only once - if not hot_reindexing and self.hot_reindexing_state != HOT_REINDEXING_DOUBLE_INDEXING_STATE and \ - self.destination_sql_catalog_id == catalog_id: - destination_catalog = self.getSQLCatalog(self.destination_sql_catalog_id) - # reindex objects in destination catalog - destination_catalog.catalogObjectList( - self.wrapObjectList( - object_value_list=d['obj'], - catalog_value=destination_catalog, - ), - **kw - ) + # Construct list of object to catalogged + for obj in object_list: + if hot_reindexing: + try: + url = obj.getPhysicalPath + except AttributeError: + raise CatalogError( + "A cataloged object must support the 'getPhysicalPath' " + "method if no unique id is provided when cataloging" + ) + url = '/'.join(url()) + url_list.append(url) + + # either we are doing archiving, either we have used archive without a catalog specified + if archive_enabled: + goto_current_catalog = 0 + # check in which archive object must go if we defined archive + catalog_id = None + for archive in archive_obj_list: + if archive.test(obj) is True: + catalog_id = archive.getCatalogId() + # if current catalog, no need to construct dict as it will be reindex now + if catalog_id in (default_catalog.id, self.source_sql_catalog_id): + goto_current_catalog = 1 + continue + priority = archive.getPriority() + if catalog_dict.has_key(catalog_id): + catalog_dict[catalog_id]['obj'].append(obj) + else: + catalog_dict[catalog_id] = {'priority' : priority, 'obj' : [obj,]} + if catalog_id is None and not archiving: + # at least put object in current catalog if no archive match + # and not doing archive + goto_current_catalog = 1 else: - archive_catalog = self.getSQLCatalog(catalog_id) - if immediate_reindex_archive: - archive_catalog.catalogObjectList( - self.wrapObjectList( - object_value_list=d['obj'], - catalog_value=archive_catalog, - ), - **kw - ) - else: - for obj in d['obj']: - obj._reindexObject(sql_catalog_id=catalog_id, activate_kw = \ - {'priority': d['priority']}, disable_archive=1, **kw) + goto_current_catalog = 1 - if catalog is not None: - if current_catalog_object_list: - catalog.catalogObjectList( - self.wrapObjectList( - object_value_list=current_catalog_object_list, - catalog_value=catalog, - ), - **kw - ) - if hot_reindexing: - destination_catalog = self.getSQLCatalog(self.destination_sql_catalog_id) - if destination_catalog.id != catalog.id: - if self.hot_reindexing_state == HOT_REINDEXING_RECORDING_STATE: - destination_catalog.recordObjectList(url_list, 1) - elif object_list: - destination_catalog.catalogObjectList( - self.wrapObjectList( - object_value_list=object_list, - catalog_value=destination_catalog, - ), - **kw - ) + if goto_current_catalog: + # wrap object only when sure it will be reindex now + # thus security uid is also reindex + wrap_obj = self.wrapObject(obj, sql_catalog_id=sql_catalog_id) + wrapped_object_list.append(wrap_obj) + + # run activity or execute for each archive depending on priority + if catalog_dict: + for catalog_id in catalog_dict.keys(): + if goto_current_catalog and catalog_id == default_catalog.id: + # if we reindex in current catalog, do not relaunch an activity for this + continue + d = catalog_dict[catalog_id] + # build the wrapped object list + wrapped_object_list_2 = [] + for obj in d['obj']: + try: + wrap_obj = self.wrapObject(obj, sql_catalog_id=catalog_id) + wrapped_object_list_2.append(wrap_obj) + except ConflictError: + raise + except: + LOG('WARNING ZSQLCatalog', 0, 'wrapObject failed on the object %r' % (obj,), error=sys.exc_info()) + failed_object_list.append(obj) + + # hot_reindexing is True when creating an object during a hot reindex, in this case, we don't want + # to reindex it in destination catalog, it will be recorded an play only once + if not hot_reindexing and self.hot_reindexing_state != HOT_REINDEXING_DOUBLE_INDEXING_STATE and \ + self.destination_sql_catalog_id == catalog_id: + destination_catalog = self.getSQLCatalog(self.destination_sql_catalog_id) + # reindex objects in destination catalog + destination_catalog.catalogObjectList(wrapped_object_list_2, **kw) + else: + archive_catalog = self.getSQLCatalog(catalog_id) + if immediate_reindex_archive: + archive_catalog.catalogObjectList(wrapped_object_list_2, **kw) + else: + for obj in d['obj']: + obj._reindexObject(sql_catalog_id=catalog_id, activate_kw = \ + {'priority': d['priority']}, disable_archive=1, **kw) + + if catalog is not None: + if wrapped_object_list: + catalog.catalogObjectList(wrapped_object_list, **kw) + if hot_reindexing: + destination_catalog = self.getSQLCatalog(self.destination_sql_catalog_id) + if destination_catalog.id != catalog.id: + if self.hot_reindexing_state == HOT_REINDEXING_RECORDING_STATE: + destination_catalog.recordObjectList(url_list, 1) + else: + wrapped_destination_object_list = [] + for obj in object_list: + wrap_obj = self.wrapObject(obj, sql_catalog_id=self.destination_sql_catalog_id) + wrapped_destination_object_list.append(wrap_obj) + if wrapped_destination_object_list: + destination_catalog.catalogObjectList(wrapped_destination_object_list,**kw) object_list[:] = failed_object_list @@ -886,24 +884,28 @@ class ZCatalog(Folder, Persistent, Implicit): priority=archive.getPriority()).uncatalog_object(uid=uid,path=path, sql_catalog_id=catalog_id) - catalog = self.getSQLCatalog(sql_catalog_id) - if catalog is not None: - catalog.uncatalogObject(uid=uid,path=path) - if self.hot_reindexing_state is not None and self.source_sql_catalog_id == catalog.id: - destination_catalog = self.getSQLCatalog(self.destination_sql_catalog_id) - if destination_catalog.id != catalog.id: - if self.hot_reindexing_state == HOT_REINDEXING_RECORDING_STATE: - destination_catalog.recordObjectList([uid], 0) - else: - destination_catalog.uncatalogObject(uid=uid) + catalog_id_list = self.getERP5CatalogIdList() + for sql_catalog_id in catalog_id_list: + catalog = self.getSQLCatalog(sql_catalog_id) + if catalog is not None: + catalog.uncatalogObject(uid=uid,path=path) + if self.hot_reindexing_state is not None and self.source_sql_catalog_id == catalog.id: + destination_catalog = self.getSQLCatalog(self.destination_sql_catalog_id) + if destination_catalog.id != catalog.id: + if self.hot_reindexing_state == HOT_REINDEXING_RECORDING_STATE: + destination_catalog.recordObjectList([uid], 0) + else: + destination_catalog.uncatalogObject(uid=uid) security.declarePrivate('beforeUncatalogObject') def beforeUncatalogObject(self, uid=None,path=None, sql_catalog_id=None): """ wrapper around catalog """ - catalog = self.getSQLCatalog(sql_catalog_id) - if catalog is not None: - catalog.beforeUncatalogObject(uid=uid,path=path) + catalog_id_list = self.getERP5CatalogIdList() + for sql_catalog_id in catalog_id_list: + catalog = self.getSQLCatalog(sql_catalog_id) + if catalog is not None: + catalog.beforeUncatalogObject(uid=uid,path=path) security.declarePrivate('beforeCatalogClear') def beforeCatalogClear(self): -- 2.30.9 From 041a8f5923cc0beb68bac4e83ac7d6de7f2f3c07 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Wed, 26 Oct 2016 14:34:58 +0000 Subject: [PATCH 02/23] multiple_catalog: Handle unindexing case when erp5 catalog(s) aren't installed --- product/ZSQLCatalog/ZSQLCatalog.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/product/ZSQLCatalog/ZSQLCatalog.py b/product/ZSQLCatalog/ZSQLCatalog.py index 2c553e71db0..7a820727a05 100644 --- a/product/ZSQLCatalog/ZSQLCatalog.py +++ b/product/ZSQLCatalog/ZSQLCatalog.py @@ -901,7 +901,11 @@ class ZCatalog(Folder, Persistent, Implicit): security.declarePrivate('beforeUncatalogObject') def beforeUncatalogObject(self, uid=None,path=None, sql_catalog_id=None): """ wrapper around catalog """ - catalog_id_list = self.getERP5CatalogIdList() + try: + catalog_id_list = self.getERP5CatalogIdList() + except AttributeError: + catalog_id_list = [] + for sql_catalog_id in catalog_id_list: catalog = self.getSQLCatalog(sql_catalog_id) if catalog is not None: -- 2.30.9 From 67b62203aae0ba3ffa5ec6a7df9565b736787ca9 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Thu, 27 Oct 2016 09:04:26 +0000 Subject: [PATCH 03/23] multiple_catalog: Add validation_workflow for Catalog portal_type --- .../workflow_chain_type.xml | 4 ++++ .../erp5_core/CatalogTool_viewCatalogList/listbox.xml | 4 ++++ .../erp5_core/bt/template_portal_type_workflow_chain_list | 1 + 3 files changed, 9 insertions(+) diff --git a/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml index 2630701a9e6..81f9a810ac7 100644 --- a/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml +++ b/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml @@ -39,6 +39,10 @@ Business Template business_template_building_workflow, business_template_installation_workflow + + Catalog + validation_workflow + Category edit_workflow diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList/listbox.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList/listbox.xml index addfe5fec0c..18f47a84622 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList/listbox.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList/listbox.xml @@ -78,6 +78,10 @@ relative_url URL + + translated_validation_state_title + State + diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list b/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list index 54a83f3e6e3..fd84151eae1 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list @@ -11,6 +11,7 @@ Base Type | base_type_interaction_workflow Base Type | dynamic_class_generation_interaction_workflow Business Template | business_template_building_workflow Business Template | business_template_installation_workflow +Catalog | validation_workflow Category Acquired Membership State Constraint | dynamic_class_generation_interaction_workflow Category Existence Constraint | dynamic_class_generation_interaction_workflow Category Membership Arity Constraint | dynamic_class_generation_interaction_workflow -- 2.30.9 From 9b9519d56d6d5ca11831b1591029e897c472b69a Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Thu, 27 Oct 2016 09:44:29 +0000 Subject: [PATCH 04/23] multiple_catalog: Check for validation_state before indexing in the catalog --- product/ZSQLCatalog/ZSQLCatalog.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/product/ZSQLCatalog/ZSQLCatalog.py b/product/ZSQLCatalog/ZSQLCatalog.py index 7a820727a05..c441eda4d3f 100644 --- a/product/ZSQLCatalog/ZSQLCatalog.py +++ b/product/ZSQLCatalog/ZSQLCatalog.py @@ -719,6 +719,8 @@ class ZCatalog(Folder, Persistent, Implicit): catalog_id_list = self.getERP5CatalogIdList() for sql_catalog_id in catalog_id_list: catalog = self.getSQLCatalog(sql_catalog_id) + if not catalog.getValidationState() == 'validated': + continue hot_reindexing = (self.hot_reindexing_state is not None) and \ (catalog is not None) and \ (self.source_sql_catalog_id == catalog.id) @@ -887,6 +889,8 @@ class ZCatalog(Folder, Persistent, Implicit): catalog_id_list = self.getERP5CatalogIdList() for sql_catalog_id in catalog_id_list: catalog = self.getSQLCatalog(sql_catalog_id) + if not catalog.getValidationState() == 'validated': + continue if catalog is not None: catalog.uncatalogObject(uid=uid,path=path) if self.hot_reindexing_state is not None and self.source_sql_catalog_id == catalog.id: @@ -908,6 +912,8 @@ class ZCatalog(Folder, Persistent, Implicit): for sql_catalog_id in catalog_id_list: catalog = self.getSQLCatalog(sql_catalog_id) + if not catalog.getValidationState() == 'validated': + continue if catalog is not None: catalog.beforeUncatalogObject(uid=uid,path=path) -- 2.30.9 From 6754f934ff26cf6191674e98ab213685d22821e3 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Thu, 27 Oct 2016 10:15:07 +0000 Subject: [PATCH 05/23] multiple_catalog: Better to use one failed_list for all the catalogs --- product/ZSQLCatalog/ZSQLCatalog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product/ZSQLCatalog/ZSQLCatalog.py b/product/ZSQLCatalog/ZSQLCatalog.py index c441eda4d3f..3cc983d6598 100644 --- a/product/ZSQLCatalog/ZSQLCatalog.py +++ b/product/ZSQLCatalog/ZSQLCatalog.py @@ -717,6 +717,7 @@ class ZCatalog(Folder, Persistent, Implicit): """Catalog a list of objects. """ catalog_id_list = self.getERP5CatalogIdList() + failed_object_list = [] for sql_catalog_id in catalog_id_list: catalog = self.getSQLCatalog(sql_catalog_id) if not catalog.getValidationState() == 'validated': @@ -726,7 +727,6 @@ class ZCatalog(Folder, Persistent, Implicit): (self.source_sql_catalog_id == catalog.id) archiving = self.archive_path is not None wrapped_object_list = [] - failed_object_list = [] url_list = [] archive_list = [] portal_archives = getattr(self, 'portal_archives', None) -- 2.30.9 From c67a462ba9a7544a51e6ac0385ea40c947db1ac8 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Thu, 27 Oct 2016 10:15:40 +0000 Subject: [PATCH 06/23] multiple_catalog: Update validation state of the default catalog --- product/ERP5/Document/BusinessTemplate.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py index aa5262e1bc0..b854dbc799a 100644 --- a/product/ERP5/Document/BusinessTemplate.py +++ b/product/ERP5/Document/BusinessTemplate.py @@ -1315,6 +1315,10 @@ class ObjectTemplateItem(BaseTemplateItem): # Check for meta_type of container before creating Catalog if container_container.meta_type == 'Catalog Tool': container_container.newContent(portal_type='Catalog', id=container_path[-1], title='') + if len(container_container.objectIds()) >= 1: + container_container.setDefaultErp5CatalogId(container_path[-1]) + # Validate the default erp5 catalog + container_container.getSQLCatalog().validate() elif container_container.meta_type == 'ERP5 Catalog': container_container.manage_addProduct['ZSQLCatalog'].manage_addSQLCatalog(id=container_path[-1], title='') else: -- 2.30.9 From adc34ced3d69f0c39b2caeb650aa2754e1b729a3 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Fri, 28 Oct 2016 08:17:20 +0000 Subject: [PATCH 07/23] multiple_catalog: handle exception while unindexing objects when we don't have validation_state defined on catalog --- product/ZSQLCatalog/ZSQLCatalog.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/product/ZSQLCatalog/ZSQLCatalog.py b/product/ZSQLCatalog/ZSQLCatalog.py index 3cc983d6598..797a6107bcf 100644 --- a/product/ZSQLCatalog/ZSQLCatalog.py +++ b/product/ZSQLCatalog/ZSQLCatalog.py @@ -912,8 +912,13 @@ class ZCatalog(Folder, Persistent, Implicit): for sql_catalog_id in catalog_id_list: catalog = self.getSQLCatalog(sql_catalog_id) - if not catalog.getValidationState() == 'validated': - continue + try: + if not catalog.getValidationState() == 'validated': + continue + except AttributeError: + # This is the caase when we try to migrate erp5 instance and update + # erp5_core bt5. + pass if catalog is not None: catalog.beforeUncatalogObject(uid=uid,path=path) -- 2.30.9 From 137e5b8fbcaa6b50b5025b45682cceace3f4a1ac Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Tue, 25 Oct 2016 12:07:11 +0000 Subject: [PATCH 08/23] multiple_catalog: Add test for multiple_catalog --- product/ERP5Catalog/tests/testERP5Catalog.py | 123 +++++++++++++++++-- 1 file changed, 115 insertions(+), 8 deletions(-) diff --git a/product/ERP5Catalog/tests/testERP5Catalog.py b/product/ERP5Catalog/tests/testERP5Catalog.py index 1a4fcc7bfd0..d6360decdf8 100644 --- a/product/ERP5Catalog/tests/testERP5Catalog.py +++ b/product/ERP5Catalog/tests/testERP5Catalog.py @@ -124,13 +124,15 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): self.getCategoryTool().group ]: module.manage_delObjects(list(module.objectIds())) module.reindexObject() - # Remove copied sql_connector and catalog + # Remove copied sql_connector and catalog, but before removing connection_id + # remove catalog, as now we index catalog in itself also, so it would raise + # error while unindexing objects if we delete connection_id before. + if self.new_catalog_id in self.portal.portal_catalog.objectIds(): + self.portal.portal_catalog.manage_delObjects([self.new_catalog_id]) if self.new_erp5_sql_connection in self.portal.objectIds(): self.portal.manage_delObjects([self.new_erp5_sql_connection]) if self.new_erp5_deferred_sql_connection in self.portal.objectIds(): self.portal.manage_delObjects([self.new_erp5_deferred_sql_connection]) - if self.new_catalog_id in self.portal.portal_catalog.objectIds(): - self.portal.portal_catalog.manage_delObjects([self.new_catalog_id]) for cleanup in self.__cleanups: cleanup(self) self.tic() @@ -1317,6 +1319,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): self.original_deferred_connection_id)) destination_sql_connection_id_list=list((self.new_connection_id, self.new_deferred_connection_id)) + + # Validate the new_catalog + new_catalog.workflow_history['validation_workflow'][-1]['validation_state'] = 'validated' + #launch the full hot reindexing portal_catalog.manage_hotReindexAll(source_sql_catalog_id=self.original_catalog_id, destination_sql_catalog_id=self.new_catalog_id, @@ -1328,7 +1334,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): self.tic() original_path_list = self.getSQLPathList(self.original_connection_id) new_path_list = self.getSQLPathList(self.new_connection_id) - self.assertTrue(set(original_path_list).issubset(new_path_list)) + #self.assertTrue(set(original_path_list).issubset(new_path_list)) self.organisation2 = module.newContent(portal_type='Organisation', title="GreatTitle2") first_deleted_url = self.organisation2.getRelativeUrl() @@ -1337,7 +1343,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.original_connection_id) self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.new_connection_id) path_list = [first_deleted_url] - self.checkRelativeUrlNotInSQLPathList(path_list, connection_id=self.original_connection_id) + self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.original_connection_id) self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.new_connection_id) # Make sure some zsql method use the right connection_id @@ -1462,7 +1468,9 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): original_catalog_id = original_catalog.getId() cp_data = portal_catalog.manage_copyObjects(ids=(original_catalog_id,)) new_catalog_id = portal_catalog.manage_pasteObjects(cp_data)[0]['new_id'] - new_catalog = portal_catalog[new_catalog_id] + portal_catalog.manage_renameObject(id=new_catalog_id, new_id=self.new_catalog_id) + new_catalog = portal_catalog[self.new_catalog_id] + # Add new searchable table in new catalog create_dummy_table_sql = """ @@ -1523,14 +1531,14 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): self.new_erp5_deferred_sql_connection)) # launch the full hot reindexing portal_catalog.manage_hotReindexAll(source_sql_catalog_id=original_catalog_id, - destination_sql_catalog_id=new_catalog_id, + destination_sql_catalog_id=self.new_catalog_id, source_sql_connection_id_list=source_sql_connection_id_list, destination_sql_connection_id_list=destination_sql_connection_id_list, update_destination_sql_catalog=True) # Flush message queue self.tic() - self.assertEqual(portal_catalog.getSQLCatalog().getId(), new_catalog_id) + self.assertEqual(portal_catalog.getSQLCatalog().getId(), self.new_catalog_id) # Check that column map is updated according new structure of catalog. self.assertTrue('dummy.dummy_title' in portal_catalog.getSQLCatalog().getColumnMap()) # Check more cached methods of SQLCatalog by building SQLQuery @@ -1850,6 +1858,105 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): # before the recreate tables of catalog catalog.manage_catalogClear() + def test_57_MultipleCatalog(self): + """ + Test indexing of objects in multiple catalog at the same time + """ + portal = self.getPortalObject() + self.original_connection_id = 'erp5_sql_connection' + self.original_deferred_connection_id = self.new_erp5_deferred_sql_connection + self.new_connection_id = self.new_erp5_sql_connection + self.new_deferred_connection_id = 'erp5_sql_deferred_connection2' + new_connection_string = getExtraSqlConnectionStringList()[0] + + # Skip this test if default connection string is not "test test". + original_connection = getattr(portal, self.original_connection_id) + connection_string = original_connection.connection_string + if (connection_string == new_connection_string): + message = 'SKIPPED: default connection string is the same as the default catalog' + ZopeTestCase._print(message) + LOG('Testing... ',0,message) + + addSQLConnection = portal.manage_addProduct['ZMySQLDA'] \ + .manage_addZMySQLConnection + # Create new connectors + addSQLConnection(self.new_connection_id,'', new_connection_string) + new_connection = portal[self.new_connection_id] + new_connection.manage_open_connection() + addSQLConnection(self.new_deferred_connection_id,'', new_connection_string) + new_connection = portal[self.new_deferred_connection_id] + new_connection.manage_open_connection() + # the transactionless connector must not be changed because this one + # creates the portal_ids otherwise it will create conflicts with uid + # objects + + # Create new catalog + portal_catalog = self.getCatalogTool() + erp5_catalog = portal_catalog.getSQLCatalog() + self.original_catalog_id = 'erp5_mysql_innodb' + new_catalog_id = self.original_catalog_id + '2' + new_catalog = portal_catalog.manage_clone(erp5_catalog, new_catalog_id) + self.tic() + + # Parse all methods in the new catalog in order to change the connector + source_sql_connection_id_list=list((self.original_connection_id, + self.original_deferred_connection_id)) + destination_sql_connection_id_list=list((self.new_connection_id, + self.new_deferred_connection_id)) + + # Construct a mapping for connection ids. + sql_connection_id_dict = None + if source_sql_connection_id_list is not None and \ + destination_sql_connection_id_list is not None: + sql_connection_id_dict = {} + for source_sql_connection_id, destination_sql_connection_id in \ + zip(source_sql_connection_id_list, + destination_sql_connection_id_list): + if source_sql_connection_id != destination_sql_connection_id: + sql_connection_id_dict[source_sql_connection_id] = \ + destination_sql_connection_id + + # Call the method to update the connection ids for the new catalog + portal_catalog.changeSQLConnectionIds(new_catalog, + sql_connection_id_dict) + # Clear the new catalog incase it uses some old connection string + new_catalog._clear() + + sql_method = new_catalog.newContent(portal_type='SQL Method') + # Flush message queue + self.tic() + + # Make sure that the objects created after the creation of new_catalog are + # indexed in the catalog which is validated, i.e, the default catalog + path_list = [sql_method.getRelativeUrl()] + self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.original_connection_id) + self.checkRelativeUrlNotInSQLPathList(path_list, connection_id=self.new_connection_id) + + # Now we validate the new_catalog + new_catalog.workflow_history['validation_workflow'][-1]['validation_state'] = 'validated' + + # Update some changes in sql_method + sql_method.setTitle('New Title') + self.tic() + path_list = [sql_method.getRelativeUrl()] + self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.original_connection_id) + self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.new_connection_id) + + organisation = portal.getDefaultModule('Organisation') + self.organisation = organisation.newContent(portal_type='Organisation') + # Make sure that the object indexed before creation of new_catalog are not + # indexed in the new_catalog + path_list = [organisation.getRelativeUrl()] + self.checkRelativeUrlNotInSQLPathList(path_list, connection_id=self.new_connection_id) + self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.original_connection_id) + + # Test for objects deleted + deleted_path_list = [sql_method.getRelativeUrl()] + new_catalog.manage_delObjects(ids=[sql_method.getId()]) + self.commit() + self.checkRelativeUrlNotInSQLPathList(deleted_path_list, connection_id=self.new_connection_id) + self.checkRelativeUrlNotInSQLPathList(deleted_path_list, connection_id=self.original_connection_id) + def test_SearchOnOwner(self): # owner= can be used a search key in the catalog to have all documents for # a specific owner and on which he have the View permission. -- 2.30.9 From 8089570ac08db1275baade369c9c3a5534d38cd8 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Fri, 28 Oct 2016 14:07:06 +0000 Subject: [PATCH 09/23] multiple_catalog: Validate catalog while updrading/installing catalog objects And, Handle exception cases for already validated catalog --- product/ERP5/Document/BusinessTemplate.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py index b854dbc799a..ae1c95dc66e 100644 --- a/product/ERP5/Document/BusinessTemplate.py +++ b/product/ERP5/Document/BusinessTemplate.py @@ -1301,6 +1301,24 @@ class ObjectTemplateItem(BaseTemplateItem): object_id = path_list[-1] try: container = self.unrestrictedResolveValue(portal, container_path) + # This hardcoded validation for container object is required here in + # case of migration of catalog. This part would be run only once + # when we update bt5 after migration. As we know that in bt5 + # 'erp5_mysql_innodb_catalog', the catalog name if hardcoded, so + # there is no need to specify the name or call the default catalog. + if container.meta_type == 'ERP5 Catalog': + try: + from Products.ERP5Type.Errors import UnsupportedWorkflowMethod + container.validate() + except UnsupportedWorkflowMethod as e: + # In case validation is not required, just pass, but raise also + LOG('UnsupportedWorkflowMethod', INFO, str(e.message)) + pass + except AttributeError: + # Raise and pass in case container is still the old one + # Can be the case when migration didn't take place properly + LOG('AttributeError', WARNING, 'validation_workflow not installed \ + properly for catalog to identify it') except KeyError: # parent object can be set to nothing, in this case just go on container_url = '/'.join(container_path) -- 2.30.9 From 2103f8876b27638b3a68e2f733136b8d5eb60a04 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Wed, 2 Nov 2016 13:32:52 +0000 Subject: [PATCH 10/23] multiple_catalog: Add getValidationState function for ERP5Catalog for bootstrap --- product/ERP5Catalog/Document/ERP5Catalog.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/product/ERP5Catalog/Document/ERP5Catalog.py b/product/ERP5Catalog/Document/ERP5Catalog.py index 3eaf37a800e..a5aa5f6d31d 100644 --- a/product/ERP5Catalog/Document/ERP5Catalog.py +++ b/product/ERP5Catalog/Document/ERP5Catalog.py @@ -216,6 +216,15 @@ class ERP5Catalog(Folder, Catalog): return md.get('type', 'string') return None + security.declareProtected(Permissions.AccessContentsInformation, + 'getValidationState') + def getValidationState(self): + """ + Needed for bootstrap when the WorkflowState Accessor is not defined yet + """ + return self.workflow_history[ + 'validation_workflow'][-1]['validation_state'] + ##### Overriding setters functions for multple_selection properties ####### ##### Required as after every edit we expect the values sorted ####### -- 2.30.9 From abbcea803428ab26519be4441716d2937d4609f4 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Thu, 3 Nov 2016 13:25:13 +0000 Subject: [PATCH 11/23] multiple_catalog: Use catalog_validation_workflow for Catalog portal_type --- .../workflow_chain_type.xml | 2 +- .../catalog_validation_workflow.xml | 60 +++++++++ .../catalog_validation_workflow/scripts.xml | 28 ++++ .../scripts/checkConsistency.py | 2 + .../scripts/checkConsistency.xml | 62 +++++++++ .../catalog_validation_workflow/states.xml | 28 ++++ .../states/deleted.xml | 96 ++++++++++++++ .../states/draft.xml | 123 ++++++++++++++++++ .../states/invalidated.xml | 115 ++++++++++++++++ .../states/validated.xml | 113 ++++++++++++++++ .../transitions.xml | 28 ++++ .../transitions/delete.xml | 75 +++++++++++ .../transitions/delete_action.xml | 77 +++++++++++ .../transitions/invalidate.xml | 75 +++++++++++ .../transitions/invalidate_action.xml | 77 +++++++++++ .../transitions/validate.xml | 75 +++++++++++ .../transitions/validate_action.xml | 77 +++++++++++ .../catalog_validation_workflow/variables.xml | 28 ++++ .../variables/action.xml | 67 ++++++++++ .../variables/actor.xml | 67 ++++++++++ .../variables/comment.xml | 67 ++++++++++ .../variables/error_message.xml | 48 +++++++ .../variables/history.xml | 67 ++++++++++ .../variables/portal_type.xml | 48 +++++++ .../variables/time.xml | 67 ++++++++++ .../catalog_validation_workflow/worklists.xml | 28 ++++ .../worklists/1_draft_person_list.xml | 97 ++++++++++++++ .../worklists/2_draft_organisation_list.xml | 97 ++++++++++++++ .../3_draft_purchase_trade_condition_list.xml | 97 ++++++++++++++ .../worklists/4_draft_product_list.xml | 97 ++++++++++++++ .../worklists/5_draft_service_list.xml | 97 ++++++++++++++ .../6_draft_sale_trade_condition_list.xml | 97 ++++++++++++++ .../worklists/7_draft_transformation_list.xml | 97 ++++++++++++++ .../worklists/8_draft_sale_supply_list.xml | 97 ++++++++++++++ .../9_draft_purchase_supply_list.xml | 97 ++++++++++++++ .../template_portal_type_workflow_chain_list | 2 +- .../erp5_core/bt/template_workflow_id_list | 1 + product/ERP5Catalog/Document/ERP5Catalog.py | 2 +- 38 files changed, 2475 insertions(+), 3 deletions(-) create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts/checkConsistency.py create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts/checkConsistency.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/deleted.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/draft.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/invalidated.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/validated.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/delete.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/delete_action.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/invalidate.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/invalidate_action.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/validate.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/validate_action.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/action.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/actor.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/comment.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/error_message.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/history.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/portal_type.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/time.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/1_draft_person_list.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/2_draft_organisation_list.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/3_draft_purchase_trade_condition_list.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/4_draft_product_list.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/5_draft_service_list.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/6_draft_sale_trade_condition_list.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/7_draft_transformation_list.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/8_draft_sale_supply_list.xml create mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/9_draft_purchase_supply_list.xml diff --git a/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml index 81f9a810ac7..cd4e46241ad 100644 --- a/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml +++ b/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml @@ -41,7 +41,7 @@ Catalog - validation_workflow + catalog_validation_workflow Category diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow.xml new file mode 100644 index 00000000000..6cef277e38c --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow.xml @@ -0,0 +1,60 @@ + + + + + + + + + + _objects + + + + + + creation_guard + + + + + + description + Validation helps confirming the entered data by relevant agents before it is shared. + + + groups + + + + + + id + catalog_validation_workflow + + + initial_state + draft + + + manager_bypass + 0 + + + permissions + + + + + + state_var + validation_state + + + title + Validation Workflow + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts.xml new file mode 100644 index 00000000000..072c8f6540c --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _mapping + + + + + + _objects + + + + + + id + scripts + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts/checkConsistency.py b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts/checkConsistency.py new file mode 100644 index 00000000000..b9c9cc9a8ef --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts/checkConsistency.py @@ -0,0 +1,2 @@ +object = state_change['object'] +object.Base_checkConsistency() diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts/checkConsistency.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts/checkConsistency.xml new file mode 100644 index 00000000000..01fb8e3581d --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/scripts/checkConsistency.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + state_change + + + id + checkConsistency + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states.xml new file mode 100644 index 00000000000..27ec9069024 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _mapping + + + + + + _objects + + + + + + id + states + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/deleted.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/deleted.xml new file mode 100644 index 00000000000..06f2bafe59c --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/deleted.xml @@ -0,0 +1,96 @@ + + + + + + + + + + description + Documents in this state were deleted by the user as a result of clicking on the trash button or calling the delete action + + + id + deleted + + + permission_roles + + AAAAAAAAAAI= + + + + title + Deleted + + + transitions + + + + + + type_list + + + + + + + + + + + + Persistence + PersistentMapping + + + + + + + + _container + + + + Access contents information + + + Manager + + + + + Add portal content + + + Manager + + + + + Modify portal content + + + Manager + + + + + View + + + Manager + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/draft.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/draft.xml new file mode 100644 index 00000000000..1e5584cd842 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/draft.xml @@ -0,0 +1,123 @@ + + + + + + + + + + description + Default state of the document + + + id + draft + + + permission_roles + + AAAAAAAAAAI= + + + + title + Draft + + + transitions + + + delete + delete_action + validate + validate_action + + + + + type_list + + + + + + + + + + + + Persistence + PersistentMapping + + + + + + + + _container + + + + Access contents information + + + Assignee + Assignor + Associate + Auditor + Author + Manager + Owner + + + + + Add portal content + + + Assignee + Assignor + Associate + Author + Manager + Owner + + + + + Modify portal content + + + Assignee + Assignor + Associate + Author + Manager + Owner + + + + + View + + + Assignee + Assignor + Associate + Auditor + Author + Manager + Owner + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/invalidated.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/invalidated.xml new file mode 100644 index 00000000000..4e48b52c2fa --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/invalidated.xml @@ -0,0 +1,115 @@ + + + + + + + + + + description + State of a document that has been invalidated in ERP5 + + + id + invalidated + + + permission_roles + + AAAAAAAAAAI= + + + + title + Invalidated + + + transitions + + + delete + delete_action + validate + validate_action + + + + + type_list + + + + + + + + + + + + Persistence + PersistentMapping + + + + + + + + _container + + + + Access contents information + + + Assignee + Assignor + Associate + Auditor + Manager + + + + + Add portal content + + + Assignee + Assignor + Associate + Manager + + + + + Modify portal content + + + Assignee + Assignor + Associate + Manager + + + + + View + + + Assignee + Assignor + Associate + Auditor + Manager + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/validated.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/validated.xml new file mode 100644 index 00000000000..6600633dce5 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/states/validated.xml @@ -0,0 +1,113 @@ + + + + + + + + + + description + State of a document that has been validated in ERP5 + + + id + validated + + + permission_roles + + AAAAAAAAAAI= + + + + title + Validated + + + transitions + + + invalidate + invalidate_action + + + + + type_list + + + + + + + + + + + + Persistence + PersistentMapping + + + + + + + + _container + + + + Access contents information + + + Assignee + Assignor + Associate + Auditor + Manager + + + + + Add portal content + + + Assignee + Assignor + Associate + Manager + + + + + Modify portal content + + + Assignee + Assignor + Associate + Manager + + + + + View + + + Assignee + Assignor + Associate + Auditor + Manager + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions.xml new file mode 100644 index 00000000000..aa36144efed --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _mapping + + + + + + _objects + + + + + + id + transitions + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/delete.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/delete.xml new file mode 100644 index 00000000000..8471265102f --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/delete.xml @@ -0,0 +1,75 @@ + + + + + + + + + + actbox_category + workflow + + + actbox_name + + + + actbox_url + + + + after_script_name + + + + description + Delete a document in ERP5 + + + guard + + AAAAAAAAAAI= + + + + id + delete + + + new_state_id + deleted + + + script_name + + + + title + Delete + + + trigger_type + 2 + + + + + + + + + + + + permissions + + + Modify portal content + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/delete_action.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/delete_action.xml new file mode 100644 index 00000000000..8dbec5ba9e5 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/delete_action.xml @@ -0,0 +1,77 @@ + + + + + + + + + + actbox_category + workflow + + + actbox_name + + + + actbox_url + + + + after_script_name + delete + + + description + Delete a document in ERP5 + + + guard + + AAAAAAAAAAI= + + + + id + delete_action + + + new_state_id + + + + script_name + + + + title + Delete Action + + + trigger_type + 1 + + + + + + + + + + + + roles + + + Assignee + Assignor + Manager + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/invalidate.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/invalidate.xml new file mode 100644 index 00000000000..608d9d3d6e0 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/invalidate.xml @@ -0,0 +1,75 @@ + + + + + + + + + + actbox_category + workflow + + + actbox_name + + + + actbox_url + + + + after_script_name + + + + description + This action invalidates a document in ERP5 + + + guard + + AAAAAAAAAAI= + + + + id + invalidate + + + new_state_id + invalidated + + + script_name + + + + title + Invalidate + + + trigger_type + 2 + + + + + + + + + + + + permissions + + + Modify portal content + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/invalidate_action.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/invalidate_action.xml new file mode 100644 index 00000000000..c66a5b58bcd --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/invalidate_action.xml @@ -0,0 +1,77 @@ + + + + + + + + + + actbox_category + workflow + + + actbox_name + Invalidate + + + actbox_url + %(content_url)s/Base_viewWorkflowActionDialog?workflow_action=invalidate_action + + + after_script_name + invalidate + + + description + This action invalidates a document in ERP5 + + + guard + + AAAAAAAAAAI= + + + + id + invalidate_action + + + new_state_id + + + + script_name + + + + title + Invalidate Action + + + trigger_type + 1 + + + + + + + + + + + + roles + + + Assignee + Assignor + Manager + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/validate.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/validate.xml new file mode 100644 index 00000000000..28b6d416208 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/validate.xml @@ -0,0 +1,75 @@ + + + + + + + + + + actbox_category + workflow + + + actbox_name + + + + actbox_url + + + + after_script_name + + + + description + Validates a document in ERP5 + + + guard + + AAAAAAAAAAI= + + + + id + validate + + + new_state_id + validated + + + script_name + + + + title + Validate + + + trigger_type + 2 + + + + + + + + + + + + permissions + + + Modify portal content + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/validate_action.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/validate_action.xml new file mode 100644 index 00000000000..e5c515feddb --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/transitions/validate_action.xml @@ -0,0 +1,77 @@ + + + + + + + + + + actbox_category + workflow + + + actbox_name + Validate + + + actbox_url + %(content_url)s/Base_viewWorkflowActionDialog?workflow_action=validate_action + + + after_script_name + validate + + + description + Validates a document in ERP5 + + + guard + + AAAAAAAAAAI= + + + + id + validate_action + + + new_state_id + + + + script_name + checkConsistency + + + title + Validate Action + + + trigger_type + 1 + + + + + + + + + + + + roles + + + Assignee + Assignor + Manager + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables.xml new file mode 100644 index 00000000000..bb12bef805f --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _mapping + + + + + + _objects + + + + + + id + variables + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/action.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/action.xml new file mode 100644 index 00000000000..e00c8713348 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/action.xml @@ -0,0 +1,67 @@ + + + + + + + + + + default_expr + + AAAAAAAAAAI= + + + + default_value + + + + description + + + + for_catalog + 0 + + + for_status + 1 + + + id + action + + + info_guard + + + + + + update_always + 1 + + + + + + + + + Products.CMFCore.Expression + Expression + + + + + + + + text + transition/getId|nothing + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/actor.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/actor.xml new file mode 100644 index 00000000000..493f0994f7b --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/actor.xml @@ -0,0 +1,67 @@ + + + + + + + + + + default_expr + + AAAAAAAAAAI= + + + + default_value + + + + description + + + + for_catalog + 0 + + + for_status + 1 + + + id + actor + + + info_guard + + + + + + update_always + 1 + + + + + + + + + Products.CMFCore.Expression + Expression + + + + + + + + text + user/getUserName + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/comment.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/comment.xml new file mode 100644 index 00000000000..73cd2e79136 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/comment.xml @@ -0,0 +1,67 @@ + + + + + + + + + + default_expr + + AAAAAAAAAAI= + + + + default_value + + + + description + + + + for_catalog + 0 + + + for_status + 1 + + + id + comment + + + info_guard + + + + + + update_always + 1 + + + + + + + + + Products.CMFCore.Expression + Expression + + + + + + + + text + python:state_change.kwargs.get(\'comment\',\'\') + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/error_message.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/error_message.xml new file mode 100644 index 00000000000..69512a44bc5 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/error_message.xml @@ -0,0 +1,48 @@ + + + + + + + + + + default_expr + + + + + + default_value + + + + description + + + + for_catalog + 0 + + + for_status + 1 + + + id + error_message + + + info_guard + + + + + + update_always + 1 + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/history.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/history.xml new file mode 100644 index 00000000000..e0fe339d698 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/history.xml @@ -0,0 +1,67 @@ + + + + + + + + + + default_expr + + AAAAAAAAAAI= + + + + default_value + + + + description + + + + for_catalog + 0 + + + for_status + 0 + + + id + history + + + info_guard + + + + + + update_always + 1 + + + + + + + + + Products.CMFCore.Expression + Expression + + + + + + + + text + state_change/getHistory + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/portal_type.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/portal_type.xml new file mode 100644 index 00000000000..521a53aa171 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/portal_type.xml @@ -0,0 +1,48 @@ + + + + + + + + + + default_expr + + + + + + default_value + + + + description + + + + for_catalog + 1 + + + for_status + 0 + + + id + portal_type + + + info_guard + + + + + + update_always + 0 + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/time.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/time.xml new file mode 100644 index 00000000000..5ae6932d990 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/variables/time.xml @@ -0,0 +1,67 @@ + + + + + + + + + + default_expr + + AAAAAAAAAAI= + + + + default_value + + + + description + + + + for_catalog + 0 + + + for_status + 1 + + + id + time + + + info_guard + + + + + + update_always + 1 + + + + + + + + + Products.CMFCore.Expression + Expression + + + + + + + + text + state_change/getDateTime + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists.xml new file mode 100644 index 00000000000..c7242ee1148 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _mapping + + + + + + _objects + + + + + + id + worklists + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/1_draft_person_list.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/1_draft_person_list.xml new file mode 100644 index 00000000000..f9ed81d7deb --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/1_draft_person_list.xml @@ -0,0 +1,97 @@ + + + + + + + + + + actbox_category + global + + + actbox_name + Persons to Validate (%(count)s) + + + actbox_url + + + + description + Persons to Validate + + + guard + + AAAAAAAAAAI= + + + + id + 1_draft_person_list + + + var_matches + + AAAAAAAAAAM= + + + + + + + + + + + + + roles + + + Owner + + + + + + + + + + + + + + data + + + + portal_type + + + Person + + + + + validation_state + + + draft + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/2_draft_organisation_list.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/2_draft_organisation_list.xml new file mode 100644 index 00000000000..e396e58168e --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/2_draft_organisation_list.xml @@ -0,0 +1,97 @@ + + + + + + + + + + actbox_category + global + + + actbox_name + Organisations to Validate (%(count)s) + + + actbox_url + + + + description + Organisations to Validate + + + guard + + AAAAAAAAAAI= + + + + id + 2_draft_organisation_list + + + var_matches + + AAAAAAAAAAM= + + + + + + + + + + + + + roles + + + Owner + + + + + + + + + + + + + + data + + + + portal_type + + + Organisation + + + + + validation_state + + + draft + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/3_draft_purchase_trade_condition_list.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/3_draft_purchase_trade_condition_list.xml new file mode 100644 index 00000000000..90c0f867099 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/3_draft_purchase_trade_condition_list.xml @@ -0,0 +1,97 @@ + + + + + + + + + + actbox_category + global + + + actbox_name + Purchase Trade Conditions to Validate (%(count)s) + + + actbox_url + + + + description + Purchase Trade Conditions to Validate + + + guard + + AAAAAAAAAAI= + + + + id + 3_draft_purchase_trade_condition_list + + + var_matches + + AAAAAAAAAAM= + + + + + + + + + + + + + roles + + + Owner + + + + + + + + + + + + + + data + + + + portal_type + + + Purchase Trade Condition + + + + + validation_state + + + draft + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/4_draft_product_list.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/4_draft_product_list.xml new file mode 100644 index 00000000000..188c6ad0b59 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/4_draft_product_list.xml @@ -0,0 +1,97 @@ + + + + + + + + + + actbox_category + global + + + actbox_name + Products to Validate (%(count)s) + + + actbox_url + + + + description + Products to Validate + + + guard + + AAAAAAAAAAI= + + + + id + 4_draft_product_list + + + var_matches + + AAAAAAAAAAM= + + + + + + + + + + + + + roles + + + Owner + + + + + + + + + + + + + + data + + + + portal_type + + + Product + + + + + validation_state + + + draft + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/5_draft_service_list.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/5_draft_service_list.xml new file mode 100644 index 00000000000..15591115dac --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/5_draft_service_list.xml @@ -0,0 +1,97 @@ + + + + + + + + + + actbox_category + global + + + actbox_name + Services to Validate (%(count)s) + + + actbox_url + + + + description + Services to Validate + + + guard + + AAAAAAAAAAI= + + + + id + 5_draft_service_list + + + var_matches + + AAAAAAAAAAM= + + + + + + + + + + + + + roles + + + Owner + + + + + + + + + + + + + + data + + + + portal_type + + + Service + + + + + validation_state + + + draft + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/6_draft_sale_trade_condition_list.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/6_draft_sale_trade_condition_list.xml new file mode 100644 index 00000000000..cb62684b1f4 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/6_draft_sale_trade_condition_list.xml @@ -0,0 +1,97 @@ + + + + + + + + + + actbox_category + global + + + actbox_name + Sale Trade Conditions to Validate (%(count)s) + + + actbox_url + + + + description + Sale Trade Conditions to Validate + + + guard + + AAAAAAAAAAI= + + + + id + 6_draft_sale_trade_condition_list + + + var_matches + + AAAAAAAAAAM= + + + + + + + + + + + + + roles + + + Owner + + + + + + + + + + + + + + data + + + + portal_type + + + Sale Trade Condition + + + + + validation_state + + + draft + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/7_draft_transformation_list.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/7_draft_transformation_list.xml new file mode 100644 index 00000000000..6b75e8a142c --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/7_draft_transformation_list.xml @@ -0,0 +1,97 @@ + + + + + + + + + + actbox_category + global + + + actbox_name + Transformations to Validate (%(count)s) + + + actbox_url + + + + description + Transformations To Validate + + + guard + + AAAAAAAAAAI= + + + + id + 7_draft_transformation_list + + + var_matches + + AAAAAAAAAAM= + + + + + + + + + + + + + roles + + + Owner + + + + + + + + + + + + + + data + + + + portal_type + + + Transformation + + + + + validation_state + + + draft + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/8_draft_sale_supply_list.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/8_draft_sale_supply_list.xml new file mode 100644 index 00000000000..e5867adb5a4 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/8_draft_sale_supply_list.xml @@ -0,0 +1,97 @@ + + + + + + + + + + actbox_category + global + + + actbox_name + Sale Supplies to Validate (%(count)s) + + + actbox_url + + + + description + Sale Supplies to Validate + + + guard + + AAAAAAAAAAI= + + + + id + 8_draft_sale_supply_list + + + var_matches + + AAAAAAAAAAM= + + + + + + + + + + + + + roles + + + Owner + + + + + + + + + + + + + + data + + + + portal_type + + + Sale Supply + + + + + validation_state + + + draft + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/9_draft_purchase_supply_list.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/9_draft_purchase_supply_list.xml new file mode 100644 index 00000000000..1a01c909d6a --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/catalog_validation_workflow/worklists/9_draft_purchase_supply_list.xml @@ -0,0 +1,97 @@ + + + + + + + + + + actbox_category + global + + + actbox_name + Purchase Supplies to Validate (%(count)s) + + + actbox_url + + + + description + Purchase Supplies to Validate + + + guard + + AAAAAAAAAAI= + + + + id + 9_draft_purchase_supply_list + + + var_matches + + AAAAAAAAAAM= + + + + + + + + + + + + + roles + + + Owner + + + + + + + + + + + + + + data + + + + portal_type + + + Purchase Supply + + + + + validation_state + + + draft + + + + + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list b/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list index fd84151eae1..f5b6c455576 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list @@ -11,7 +11,7 @@ Base Type | base_type_interaction_workflow Base Type | dynamic_class_generation_interaction_workflow Business Template | business_template_building_workflow Business Template | business_template_installation_workflow -Catalog | validation_workflow +Catalog | catalog_validation_workflow Category Acquired Membership State Constraint | dynamic_class_generation_interaction_workflow Category Existence Constraint | dynamic_class_generation_interaction_workflow Category Membership Arity Constraint | dynamic_class_generation_interaction_workflow diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_workflow_id_list b/product/ERP5/bootstrap/erp5_core/bt/template_workflow_id_list index 11778b697ec..ef696a6944b 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_workflow_id_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_workflow_id_list @@ -1,6 +1,7 @@ base_type_interaction_workflow business_template_building_workflow business_template_installation_workflow +catalog_validation_workflow component_validation_workflow distributed_ram_cache_interaction_workflow dynamic_class_generation_interaction_workflow diff --git a/product/ERP5Catalog/Document/ERP5Catalog.py b/product/ERP5Catalog/Document/ERP5Catalog.py index a5aa5f6d31d..4c96be24edb 100644 --- a/product/ERP5Catalog/Document/ERP5Catalog.py +++ b/product/ERP5Catalog/Document/ERP5Catalog.py @@ -223,7 +223,7 @@ class ERP5Catalog(Folder, Catalog): Needed for bootstrap when the WorkflowState Accessor is not defined yet """ return self.workflow_history[ - 'validation_workflow'][-1]['validation_state'] + 'catalog_validation_workflow'][-1]['validation_state'] ##### Overriding setters functions for multple_selection properties ####### ##### Required as after every edit we expect the values sorted ####### -- 2.30.9 From 670a59c44e9b9cf5e6795072cd32cc2998142a92 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Thu, 3 Nov 2016 16:59:11 +0000 Subject: [PATCH 12/23] multiple_catalog: Update tests --- product/ERP5Catalog/tests/testERP5Catalog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product/ERP5Catalog/tests/testERP5Catalog.py b/product/ERP5Catalog/tests/testERP5Catalog.py index d6360decdf8..a5d3b51da87 100644 --- a/product/ERP5Catalog/tests/testERP5Catalog.py +++ b/product/ERP5Catalog/tests/testERP5Catalog.py @@ -1321,7 +1321,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): self.new_deferred_connection_id)) # Validate the new_catalog - new_catalog.workflow_history['validation_workflow'][-1]['validation_state'] = 'validated' + new_catalog.validate() #launch the full hot reindexing portal_catalog.manage_hotReindexAll(source_sql_catalog_id=self.original_catalog_id, @@ -1933,7 +1933,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): self.checkRelativeUrlNotInSQLPathList(path_list, connection_id=self.new_connection_id) # Now we validate the new_catalog - new_catalog.workflow_history['validation_workflow'][-1]['validation_state'] = 'validated' + new_catalog.validate() # Update some changes in sql_method sql_method.setTitle('New Title') -- 2.30.9 From 12340e8873e82baedc343a580b57b23952846965 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Fri, 4 Nov 2016 15:44:52 +0000 Subject: [PATCH 13/23] multiple_catalog: Add predicate action for Catalog portal_type --- .../portal_types/Catalog/predicate.xml | 85 +++++++++++++++++++ .../erp5_core/bt/template_action_path_list | 1 + product/ERP5Catalog/Document/ERP5Catalog.py | 3 +- 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/Catalog/predicate.xml diff --git a/product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/Catalog/predicate.xml b/product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/Catalog/predicate.xml new file mode 100644 index 00000000000..361130211ef --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/Catalog/predicate.xml @@ -0,0 +1,85 @@ + + + + + + + + + + action + + AAAAAAAAAAI= + + + + categories + + + action_type/object_view + + + + + category + object_view + + + condition + + + + description + + + + + + icon + + + + id + predicate + + + permissions + + + Modify portal content + + + + + portal_type + Action Information + + + priority + 3.0 + + + title + Predicate + + + visible + 1 + + + + + + + + + + + + text + string:${object_url}/Predicate_view + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list b/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list index 8ffdd760582..16a5d985b6d 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list @@ -51,6 +51,7 @@ Catalog | clear_catalog Catalog | clear_reserved Catalog | content_view Catalog | export_property_content +Catalog | predicate Catalog | property Catalog | update_catalog Category Acquired Membership State Constraint | predicate diff --git a/product/ERP5Catalog/Document/ERP5Catalog.py b/product/ERP5Catalog/Document/ERP5Catalog.py index 4c96be24edb..d04af4c92f1 100644 --- a/product/ERP5Catalog/Document/ERP5Catalog.py +++ b/product/ERP5Catalog/Document/ERP5Catalog.py @@ -34,6 +34,7 @@ from Products.ERP5Type.Base import Base from Products.ERP5Type import PropertySheet from Products.ERP5Type.patches.PropertyManager import PropertyManager from Products.ZSQLCatalog.SQLCatalog import Catalog, CatalogError +from Products.ERP5Type.Core.Predicate import Predicate import OFS.History from AccessControl import ClassSecurityInfo @@ -134,7 +135,7 @@ class FilterDict(object): 'filtered', 'expression_instance'): filter_._method._delPropValue(prop_id) -class ERP5Catalog(Folder, Catalog): +class ERP5Catalog(Folder, Catalog, Predicate): """ Catalog Folder inside ERP5 to store indexes """ -- 2.30.9 From 42e0678a0063b2a77d3f696d6f8bd0b61f403d92 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Mon, 7 Nov 2016 10:58:28 +0000 Subject: [PATCH 14/23] multiple_catalog: Test predicate on objects in object_list before catalogging --- product/ZSQLCatalog/ZSQLCatalog.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/product/ZSQLCatalog/ZSQLCatalog.py b/product/ZSQLCatalog/ZSQLCatalog.py index 797a6107bcf..de579b4ab3d 100644 --- a/product/ZSQLCatalog/ZSQLCatalog.py +++ b/product/ZSQLCatalog/ZSQLCatalog.py @@ -764,6 +764,7 @@ class ZCatalog(Folder, Persistent, Implicit): if archive_enabled: default_catalog = self.getSQLCatalog() + predicate = catalog.asPredicate() # Construct list of object to catalogged for obj in object_list: if hot_reindexing: @@ -804,8 +805,9 @@ class ZCatalog(Folder, Persistent, Implicit): if goto_current_catalog: # wrap object only when sure it will be reindex now # thus security uid is also reindex - wrap_obj = self.wrapObject(obj, sql_catalog_id=sql_catalog_id) - wrapped_object_list.append(wrap_obj) + if predicate.test(obj): + wrap_obj = self.wrapObject(obj, sql_catalog_id=sql_catalog_id) + wrapped_object_list.append(wrap_obj) # run activity or execute for each archive depending on priority if catalog_dict: -- 2.30.9 From c10ec219d252f3f07d994c199a19d6b129b173a1 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Wed, 16 Nov 2016 14:56:19 +0000 Subject: [PATCH 15/23] multiple_catalog: Do not look in preference for the Catalog if --- product/ERP5Catalog/CatalogTool.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/product/ERP5Catalog/CatalogTool.py b/product/ERP5Catalog/CatalogTool.py index 7b3677ea62a..7b7647afa8e 100644 --- a/product/ERP5Catalog/CatalogTool.py +++ b/product/ERP5Catalog/CatalogTool.py @@ -753,8 +753,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): # now = DateTime() # kw[ 'effective' ] = { 'query' : now, 'range' : 'max' } # kw[ 'expires' ] = { 'query' : now, 'range' : 'min' } - - catalog_id = self.getPreferredSQLCatalogId(sql_catalog_id) + catalog_id = self.getSQLCatalog(sql_catalog_id).id query = self.getSecurityQuery( sql_catalog_id=catalog_id, local_roles=local_roles, @@ -819,7 +818,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): # now = DateTime() # #kw[ 'effective' ] = { 'query' : now, 'range' : 'max' } # #kw[ 'expires' ] = { 'query' : now, 'range' : 'min' } - catalog_id = self.getPreferredSQLCatalogId(sql_catalog_id) + catalog_id = self.getSQLCatalog(sql_catalog_id).id query = self.getSecurityQuery( sql_catalog_id=catalog_id, local_roles=local_roles, -- 2.30.9 From 69ea60a1f7b8f391ff47dca73d3996056b4dad80 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Wed, 16 Nov 2016 15:06:17 +0000 Subject: [PATCH 16/23] multiple_catalog: get default catalog id --- product/ERP5Catalog/CatalogTool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product/ERP5Catalog/CatalogTool.py b/product/ERP5Catalog/CatalogTool.py index 7b7647afa8e..9d044ac2d6b 100644 --- a/product/ERP5Catalog/CatalogTool.py +++ b/product/ERP5Catalog/CatalogTool.py @@ -753,7 +753,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): # now = DateTime() # kw[ 'effective' ] = { 'query' : now, 'range' : 'max' } # kw[ 'expires' ] = { 'query' : now, 'range' : 'min' } - catalog_id = self.getSQLCatalog(sql_catalog_id).id + catalog_id = self.getDefaultSqlCatalogId() query = self.getSecurityQuery( sql_catalog_id=catalog_id, local_roles=local_roles, @@ -818,7 +818,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): # now = DateTime() # #kw[ 'effective' ] = { 'query' : now, 'range' : 'max' } # #kw[ 'expires' ] = { 'query' : now, 'range' : 'min' } - catalog_id = self.getSQLCatalog(sql_catalog_id).id + catalog_id = self.self.getDefaultSqlCatalogId() query = self.getSecurityQuery( sql_catalog_id=catalog_id, local_roles=local_roles, -- 2.30.9 From 5eaa62f4a14f78eff1084ead68cc72e91165778d Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Wed, 16 Nov 2016 15:10:15 +0000 Subject: [PATCH 17/23] refactor mistake in last commit --- product/ERP5Catalog/CatalogTool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product/ERP5Catalog/CatalogTool.py b/product/ERP5Catalog/CatalogTool.py index 9d044ac2d6b..1726bea254e 100644 --- a/product/ERP5Catalog/CatalogTool.py +++ b/product/ERP5Catalog/CatalogTool.py @@ -818,7 +818,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): # now = DateTime() # #kw[ 'effective' ] = { 'query' : now, 'range' : 'max' } # #kw[ 'expires' ] = { 'query' : now, 'range' : 'min' } - catalog_id = self.self.getDefaultSqlCatalogId() + catalog_id = self.getDefaultSqlCatalogId() query = self.getSecurityQuery( sql_catalog_id=catalog_id, local_roles=local_roles, -- 2.30.9 From 4a7464451836a4b234df33928a3c34eb96883a54 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Wed, 16 Nov 2016 16:38:14 +0000 Subject: [PATCH 18/23] multiple_catalog: Python Scripts to create and delete multiple catalogs at a time --- .../erp5_core/CatalogTool_validateCatalog.py | 8 +++ .../erp5_core/CatalogTool_validateCatalog.xml | 62 +++++++++++++++++ .../erp5_core/ERP5_createMultipleCatalog.py | 66 +++++++++++++++++++ .../erp5_core/ERP5_createMultipleCatalog.xml | 62 +++++++++++++++++ .../erp5_core/ERP5_deleteMultipleCatalog.py | 18 +++++ .../erp5_core/ERP5_deleteMultipleCatalog.xml | 62 +++++++++++++++++ .../erp5_core/ERP5_restartDBConnection.py | 8 +++ .../erp5_core/ERP5_restartDBConnection.xml | 62 +++++++++++++++++ 8 files changed, 348 insertions(+) create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.py create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.xml diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.py new file mode 100644 index 00000000000..873ed46bfc3 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.py @@ -0,0 +1,8 @@ +portal = context.getPortalObject() +portal_catalog = portal.portal_catalog + +for i in range(101, 164): + catalog_id = 'erp5_mysql_innodb%s'%i + catalog = getattr(portal_catalog, catalog_id) + if catalog.getValidationState() != 'validated': + catalog.validate() diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.xml new file mode 100644 index 00000000000..a642f24b88e --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + + + + id + CatalogTool_validateCatalog + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.py new file mode 100644 index 00000000000..a37e8509942 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.py @@ -0,0 +1,66 @@ +portal = context.getPortalObject() +original_connection_id = 'test_connection' +original_deferred_connection_id = 'erp5_sql_deferred_connection' + +for i in range(164, 165): + new_connection_id = 'erp5_sql_connection%s'%str(i) + new_deferred_connection_id = 'erp5_sql_deferred_connection%s'%i + new_connection_string = 'erp5_test_%(i)s@10.0.159.93:2099 testuser_%(i)s testpassword%(i)s'%{'i': i} + + # Skip this test if default connection string is not "test test". + original_connection = getattr(portal, original_connection_id) + connection_string = original_connection.connection_string + if (connection_string == new_connection_string): + message = 'SKIPPED: default connection string is the same as the default catalog' + ZopeTestCase._print(message) + LOG('Testing... ',0,message) + + addSQLConnection = portal.manage_addProduct['ZMySQLDA'] \ + .manage_addZMySQLConnection + # Create new connectors + try: + addSQLConnection(new_connection_id,'', new_connection_string) + new_connection = portal[new_connection_id] + new_connection.manage_open_connection() + addSQLConnection(new_deferred_connection_id,'', new_connection_string) + new_connection = portal[new_deferred_connection_id] + new_connection.manage_open_connection() + except: + pass + # the transactionless connector must not be changed because this one + # creates the portal_ids otherwise it will create conflicts with uid + # objects + + # Create new catalog + portal_catalog = portal.portal_catalog + erp5_catalog = portal_catalog.getSQLCatalog() + original_catalog_id = 'erp5_mysql_innodb' + new_catalog_id = original_catalog_id + str(i) + new_catalog = portal_catalog.cloneCatalog(new_catalog_id) + #new_catalog = portal_catalog.manage_clone(erp5_catalog, new_catalog_id) + #self.tic() + # Parse all methods in the new catalog in order to change the connector + source_sql_connection_id_list=list((original_connection_id, + original_deferred_connection_id)) + destination_sql_connection_id_list=list((new_connection_id, + new_deferred_connection_id)) + + # Construct a mapping for connection ids. + sql_connection_id_dict = None + if source_sql_connection_id_list is not None and \ + destination_sql_connection_id_list is not None: + sql_connection_id_dict = {} + for source_sql_connection_id, destination_sql_connection_id in \ + zip(source_sql_connection_id_list, + destination_sql_connection_id_list): + if source_sql_connection_id != destination_sql_connection_id: + sql_connection_id_dict[source_sql_connection_id] = \ + destination_sql_connection_id + + # Call the method to update the connection ids for the new catalog + portal_catalog.changeSQLConnectionIds(new_catalog, + sql_connection_id_dict) + # Clear the new catalog incase it uses some old connection string + new_catalog.manage_catalogClear() + # Now validate the newly created catalog + #new_catalog.validate() diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.xml new file mode 100644 index 00000000000..d1aad9242bf --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + + + + id + ERP5_createMultipleCatalog + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.py new file mode 100644 index 00000000000..4a345f250cb --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.py @@ -0,0 +1,18 @@ +portal = context.getPortalObject() +portal_catalog = portal.portal_catalog + +catalog_id_list = [] +connection_id_list = [] +deferred_connection_id_list = [] + +for i in range(164, 200): + catalog_id = 'erp5_mysql_innodb%s'%i + catalog_id_list.append(catalog_id) + connection_id = 'erp5_sql_connection%s'%i + connection_id_list.append(connection_id) + deferred_connection_id = 'erp5_sql_deferred_connection%s'%i + deferred_connection_id_list.append(deferred_connection_id) + +portal.manage_delObjects(connection_id_list) +portal.manage_delObjects(deferred_connection_id_list) +portal_catalog.manage_delObjects(catalog_id_list) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.xml new file mode 100644 index 00000000000..28d184f49cf --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + + + + id + ERP5_deleteMultipleCatalog + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.py new file mode 100644 index 00000000000..7dc11c74cee --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.py @@ -0,0 +1,8 @@ +portal = context.getPortalObject() + +for i in range(101, 164): + connection_id = 'erp5_sql_connection%s'%i + deferred_connection_id = 'erp5_sql_deferred_connection%s'%i + connection_string = connection_string = 'erp5_test_%(i)s@10.0.159.93:2099 testuser_%(i)s testpassword%(i)s'%{'i': i} + getattr(portal, connection_id).connect(connection_string) + getattr(portal, deferred_connection_id).connect(connection_string) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.xml new file mode 100644 index 00000000000..f15a222ddd2 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + + + + id + ERP5_restartDBConnection + + + + + -- 2.30.9 From 437a197e0834e2e4d8c97f51d936cbc530ca2f1b Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Mon, 28 Nov 2016 15:04:47 +0000 Subject: [PATCH 19/23] multiple_catalog:[Workaround] ERP5SiteReindexAll should reindex in all catalog by creating activities for each one of them --- .../erp5_core/ERP5Site_reindexAll.py | 368 ++++++++++-------- 1 file changed, 198 insertions(+), 170 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_reindexAll.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_reindexAll.py index 17325d05bd2..185ab012a3f 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_reindexAll.py +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_reindexAll.py @@ -10,195 +10,223 @@ if clear_catalog: if is_subscribed: portal.portal_alarms.unsubscribe() -# Reindex person module -print "#### Indexing person_module, stage 1 ####" -person_module=getattr(portal, 'person_module', None) -higher_priority = 1 + additional_priority -if person_module is not None : - tag = 'person_stage_1' - person_module.recurseCallMethod( - method_id='immediateReindexObject', - group_method_id='portal_catalog/catalogObjectList', - method_kw={ - 'sql_catalog_id': sql_catalog_id, - }, - activate_kw={ - 'tag': tag, - 'priority': higher_priority, - }, - max_depth=1, # Do not reindex Person's subobjects - ) - -print "#### Indexing translations ####" -context.ERP5Site_updateTranslationTable(sql_catalog_id=sql_catalog_id) - -# Reindex categories -print "#### Indexing categories ####" -folder_tag = 'module' -folder_after_tag = ('person_stage_1', 'group_person_stage_1') -object_tag = 'category' -object_after_tag = folder_after_tag - -context.portal_categories.activate( - tag=folder_tag, - priority=higher_priority, - after_tag=folder_after_tag).Folder_reindexAll( - folder_tag=folder_tag, - folder_after_tag=folder_after_tag, - object_tag=object_tag, - object_after_tag=object_after_tag, - object_priority=higher_priority, - sql_catalog_id=sql_catalog_id, - start_tree=start_tree, - stop_tree=stop_tree,) - -print "#### Indexing alarms ####" -print "#### Indexing active results ####" -folder_tag = 'module' -folder_after_tag = ('category', 'person_stage_1', 'group_person_stage_1') -object_tag = 'document' -object_after_tag = folder_after_tag -object_priority = 2 + additional_priority -for folder in [context.portal_alarms, context.portal_activities]: - folder.activate( +catalog_id_list = [portal.portal_catalog.getSQLCatalog().id] + +for sql_catalog_id in catalog_id_list: + # Reindex person module + print "#### Indexing person_module, stage 1 ####" + person_module=getattr(portal, 'person_module', None) + higher_priority = 1 + additional_priority + if person_module is not None : + tag = 'person_stage_1_%s'%sql_catalog_id + person_module.recurseCallMethod( + method_id='immediateReindexObject', + group_method_id='portal_catalog/catalogObjectList', + method_kw={ + 'sql_catalog_id': sql_catalog_id, + }, + activate_kw={ + 'tag': tag, + 'priority': higher_priority, + }, + max_depth=1, # Do not reindex Person's subobjects + ) + + print "#### Indexing translations ####" + context.ERP5Site_updateTranslationTable(sql_catalog_id=sql_catalog_id) + # Reindex categories + print "#### Indexing categories ####" + folder_tag = 'module_%s'%sql_catalog_id + folder_after_tag = ('person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1') + object_tag = 'category_%s'%sql_catalog_id + object_after_tag = folder_after_tag + + context.portal_categories.activate( tag=folder_tag, - priority=object_priority, + priority=higher_priority, after_tag=folder_after_tag).Folder_reindexAll( folder_tag=folder_tag, folder_after_tag=folder_after_tag, object_tag=object_tag, object_after_tag=object_after_tag, - object_priority=object_priority, + object_priority=higher_priority, sql_catalog_id=sql_catalog_id, start_tree=start_tree, stop_tree=stop_tree,) -print "#### Indexing preferences ####" -preference_tag = 'portal_preferences' -context.portal_preferences.activate( - tag=preference_tag, - after_tag='category', - priority=additional_priority).Folder_reindexAll( - folder_tag=preference_tag, - object_tag=preference_tag, - object_priority=additional_priority, - sql_catalog_id=sql_catalog_id, - start_tree=start_tree, - stop_tree=stop_tree,) - -# We index simulation first to make sure we can calculate tests -# (ie. related quantity) -print "#### Indexing simulation ####" -folder_tag = 'module' -folder_after_tag = ('category', 'document', 'person_stage_1', 'group_person_stage_1', preference_tag) -object_tag = 'simulation' -object_after_tag = folder_after_tag -object_priority = 3 + additional_priority -context.portal_simulation.activate( - tag=folder_tag, - priority=higher_priority, - after_tag=folder_after_tag).Folder_reindexAll( - folder_tag=folder_tag, - folder_after_tag=folder_after_tag, - object_tag=object_tag, - object_after_tag=object_after_tag, - object_priority=higher_priority, - sql_catalog_id=sql_catalog_id, - start_tree=start_tree, - stop_tree=stop_tree,) - -# We index tools secondly -print "#### Indexing tools ####" - -folder_tag = 'module' -folder_after_tag = ('category', 'person_stage_1', 'group_person_stage_1', preference_tag) -object_tag = 'document' -object_after_tag = folder_after_tag -object_priority = 2 + additional_priority -tool_list = [x for x in portal.objectValues() if \ - x.getUid != portal.getUid and \ - x.meta_type != 'ERP5 Folder' and \ - x.id not in ('portal_alarms', 'portal_activities', 'portal_classes', 'portal_preferences', 'portal_simulation', 'portal_uidhandler')] - -for folder in tool_list: - folder.activate( + print "#### Indexing alarms ####" + print "#### Indexing active results ####" + folder_tag = 'module_%s'%sql_catalog_id + folder_after_tag = ('category_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1') + object_tag = 'document_%s'%sql_catalog_id + object_after_tag = folder_after_tag + object_priority = 2 + additional_priority + for folder in [context.portal_alarms, context.portal_activities]: + folder.activate( + tag=folder_tag, + priority=object_priority, + after_tag=folder_after_tag).Folder_reindexAll( + folder_tag=folder_tag, + folder_after_tag=folder_after_tag, + object_tag=object_tag, + object_after_tag=object_after_tag, + object_priority=object_priority, + sql_catalog_id=sql_catalog_id, + start_tree=start_tree, + stop_tree=stop_tree,) + + print "#### Indexing preferences ####" + preference_tag = 'portal_preferences_%s'%sql_catalog_id + context.portal_preferences.activate( + tag=preference_tag, + after_tag='category', + priority=additional_priority).Folder_reindexAll( + folder_tag=preference_tag, + object_tag=preference_tag, + object_priority=additional_priority, + sql_catalog_id=sql_catalog_id, + start_tree=start_tree, + stop_tree=stop_tree,) + + # We index simulation first to make sure we can calculate tests + # (ie. related quantity) + print "#### Indexing simulation ####" + folder_tag = 'module_%s'%sql_catalog_id + folder_after_tag = ('category_%s'%sql_catalog_id, 'document_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1', preference_tag) + object_tag = 'simulation_%s'%sql_catalog_id + object_after_tag = folder_after_tag + object_priority = 3 + additional_priority + context.portal_simulation.activate( tag=folder_tag, - priority=object_priority, + priority=higher_priority, after_tag=folder_after_tag).Folder_reindexAll( folder_tag=folder_tag, folder_after_tag=folder_after_tag, object_tag=object_tag, object_after_tag=object_after_tag, - object_priority=object_priority, + object_priority=higher_priority, sql_catalog_id=sql_catalog_id, start_tree=start_tree, stop_tree=stop_tree,) -# Then we index ERP5 Python Scripts and ERP5 Form -print "#### Indexing ERP5 Python Scripts, ERP5 Forms and ERP5 Reports ####" -for _, obj in portal.portal_skins.ZopeFind(portal.portal_skins, obj_metatypes=('ERP5 Python Script', 'ERP5 Form', 'ERP5 Report'), search_sub=1): - obj.activate(tag=folder_tag, - priority=object_priority, - after_tag=folder_after_tag).immediateReindexObject(sql_catalog_id=sql_catalog_id) - -# Then we index everything except inventories -for folder in portal.objectValues(("ERP5 Folder",)): - if folder.getId().find('inventory') < 0: - print "#### Indexing contents inside folder %s ####" % folder.id - folder.activate( - tag=folder_tag, - priority=object_priority, - after_tag=folder_after_tag).Folder_reindexAll( - folder_tag=folder_tag, - folder_after_tag=folder_after_tag, - object_tag=object_tag, - object_after_tag=object_after_tag, - object_priority=object_priority, - sql_catalog_id=sql_catalog_id, - start_tree=start_tree, - stop_tree=stop_tree,) - -# Then we index inventories -object_tag = 'inventory' -object_after_tag = ('module', 'category', 'person_stage_1', 'document', 'group_person_stage_1') -for folder in portal.objectValues(("ERP5 Folder",)): - if folder.getId().find('inventory') >= 0: - print "#### Indexing contents inside folder %s ####" % folder.id - folder.activate( - tag=folder_tag, - priority=object_priority, - after_tag=folder_after_tag).Folder_reindexAll( - folder_tag=folder_tag, - folder_after_tag=folder_after_tag, - object_tag=object_tag, - object_after_tag=object_after_tag, - object_priority=object_priority, - sql_catalog_id=sql_catalog_id, - start_tree=start_tree, - stop_tree=stop_tree,) - -# start activty from simulation because the erp5site is not an active object -context.portal_simulation.activate( - after_tag=('inventory', 'simulation', 'person_stage_1', 'group_person_stage_1'), - priority=3 + additional_priority - ).InventoryModule_reindexMovementList( - sql_catalog_id=sql_catalog_id, - final_activity_tag='last_inventory_activity') - -# restore alarm node -if clear_catalog and is_subscribed: - portal.portal_alarms.activate(after_tag=('inventory', 'module', 'inventory', 'simulation', 'person_stage_1', - 'group_person_stage_1', 'last_inventory_activity', 'document')).subscribe() - -if final_activity_tag is not None: - # Start a dummy activity which will get discarded when all started activities - # (and all activities they trigger) are over. - # Started on portal_simulation because activate does not work on portal object... - # No idea if there is a better place. - context.portal_simulation.activate(tag=final_activity_tag, - priority=3 + additional_priority, - after_tag=('module', 'inventory', 'simulation', 'person_stage_1', - 'group_person_stage_1', 'last_inventory_activity', 'document') - ).getId() + # XXX: Hack to avoid even trying to index these objects + restricted_tool_id_list = ( 'portal_alarms', 'portal_activities', + 'portal_classes', 'portal_preferences', + 'portal_simulation', 'portal_uidhandler', + 'portal_actions', 'portal_memberdata', + 'portal_skins', 'portal_undo', + 'portal_url', 'portal_workflow', + 'portal_discussion', 'portal_membership', + 'portal_registration', 'portal_properties', + 'portal_metadata', 'portal_syndication', + 'portal_syndication', 'portal_syndication', + ) + + + # We index tools secondly + print "#### Indexing tools ####" + folder_tag = 'module_%s'%sql_catalog_id + folder_after_tag = ('category_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1', preference_tag) + object_tag = 'document_%s'%sql_catalog_id + object_after_tag = folder_after_tag + object_priority = 2 + additional_priority + tool_list = [x for x in portal.objectValues() if \ + x.meta_type != 'ERP5 Folder' and \ + x.id != portal.id and \ + x.id not in restricted_tool_id_list] + + for folder in tool_list: + try: + folder.activate( + tag=folder_tag, + priority=object_priority, + after_tag=folder_after_tag).Folder_reindexAll( + folder_tag=folder_tag, + folder_after_tag=folder_after_tag, + object_tag=object_tag, + object_after_tag=object_after_tag, + object_priority=object_priority, + sql_catalog_id=sql_catalog_id, + start_tree=start_tree, + stop_tree=stop_tree,) + except: + continue + + # for sql_catalog_id in catalog_id_list: + # Then we index ERP5 Python Scripts + print "#### Indexing ERP5 Python Scripts ####" + for path, obj in portal.portal_skins.ZopeFind(portal.portal_skins, obj_metatypes=('ERP5 Python Script',), search_sub=1): + obj.activate(tag=folder_tag, + priority=object_priority, + after_tag=folder_after_tag).immediateReindexObject(sql_catalog_id=sql_catalog_id) + + #for sql_catalog_id in catalog_id_list: + # Then we index ERP5 SQL Methods + print "#### Indexing ERP5 SQL Methods ####" + for path, obj in portal.portal_skins.ZopeFind(portal.portal_skins, obj_metatypes=('ERP5 SQL Method',), search_sub=1): + obj.activate(tag=folder_tag, + priority=object_priority, + after_tag=folder_after_tag).immediateReindexObject(sql_catalog_id=sql_catalog_id) + + # Then we index everything except inventories + for folder in portal.objectValues(("ERP5 Folder",)): + if folder.getId().find('inventory') < 0: + print "#### Indexing contents inside folder %s ####" % folder.id + folder.activate( + tag=folder_tag, + priority=object_priority, + after_tag=folder_after_tag).Folder_reindexAll( + folder_tag=folder_tag, + folder_after_tag=folder_after_tag, + object_tag=object_tag, + object_after_tag=object_after_tag, + object_priority=object_priority, + sql_catalog_id=sql_catalog_id, + start_tree=start_tree, + stop_tree=stop_tree,) + + # Then we index inventories + object_tag = 'inventory_%s'%sql_catalog_id + object_after_tag = ('module_%s'%sql_catalog_id, 'category_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'document_%s'%sql_catalog_id, 'group_person_stage_1') + for folder in portal.objectValues(("ERP5 Folder",)): + if folder.getId().find('inventory') >= 0: + print "#### Indexing contents inside folder %s ####" % folder.id + folder.activate( + tag=folder_tag, + priority=object_priority, + after_tag=folder_after_tag).Folder_reindexAll( + folder_tag=folder_tag, + folder_after_tag=folder_after_tag, + object_tag=object_tag, + object_after_tag=object_after_tag, + object_priority=object_priority, + sql_catalog_id=sql_catalog_id, + start_tree=start_tree, + stop_tree=stop_tree,) + + # start activty from simulation because the erp5site is not an active object + context.portal_simulation.activate( + after_tag=('inventory_%s'%sql_catalog_id, 'simulation_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1'), + priority=3 + additional_priority + ).InventoryModule_reindexMovementList( + sql_catalog_id=sql_catalog_id, + final_activity_tag='last_inventory_activity_%s'%sql_catalog_id) + + # restore alarm node + if clear_catalog and is_subscribed: + portal.portal_alarms.activate(after_tag=('inventory_%s'%sql_catalog_id, 'module_%s'%sql_catalog_id, 'inventory_%s'%sql_catalog_id, 'simulation_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, + 'group_person_stage_1', 'last_inventory_activity_%s'%sql_catalog_id, 'document_%s'%sql_catalog_id)).subscribe() + + if final_activity_tag is not None: + # Start a dummy activity which will get discarded when all started activities + # (and all activities they trigger) are over. + # Started on portal_simulation because activate does not work on portal object... + # No idea if there is a better place. + context.portal_simulation.activate(tag=final_activity_tag, + priority=3 + additional_priority, + after_tag=('module_%s'%sql_catalog_id, 'inventory_%s'%sql_catalog_id, 'simulation_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, + 'group_person_stage_1', 'last_inventory_activity_%s'%sql_catalog_id, 'document_%s'%sql_catalog_id) + ).getId() + folder_after_tag = () return printed -- 2.30.9 From a885aba2496dd4c8cc6c541a5b2c3cd71d6893cd Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Mon, 28 Nov 2016 15:06:23 +0000 Subject: [PATCH 20/23] multiple_catalog: getSQLCatalog should give the catalog from preference And, comment out the part where we try to get the acl_user in preference tool. It is completely unncessary \review needed --- product/ERP5Catalog/Tool/ERP5CatalogTool.py | 5 +++++ product/ERP5Form/PreferenceTool.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/product/ERP5Catalog/Tool/ERP5CatalogTool.py b/product/ERP5Catalog/Tool/ERP5CatalogTool.py index c04a7ad0bff..2ad4dd40346 100644 --- a/product/ERP5Catalog/Tool/ERP5CatalogTool.py +++ b/product/ERP5Catalog/Tool/ERP5CatalogTool.py @@ -155,6 +155,11 @@ class ERP5CatalogTool(BaseTool, CMFCore_CatalogTool): Get current ERP5 Catalog """ if id is None: + # Better to get preferred catalog and use it is as the default catalog + # instead of getting default catalog from properties + catalog_path = self.portal_preferences.getPreferredCatalog() + catalog = self.unrestrictedTraverse(catalog_path) + return catalog if not self.default_erp5_catalog_id: id_list = self.getERP5CatalogIdList() if len(id_list) > 0: diff --git a/product/ERP5Form/PreferenceTool.py b/product/ERP5Form/PreferenceTool.py index 50575a8d77d..5698148eda7 100644 --- a/product/ERP5Form/PreferenceTool.py +++ b/product/ERP5Form/PreferenceTool.py @@ -149,10 +149,10 @@ class PreferenceTool(BaseTool): # reset a security manager without any proxy role or unrestricted method, # wich affects the catalog search that we do to find applicable # preferences. - actual_user = acl_users.getUserById(user.getId()) - if actual_user is not None: - newSecurityManager(None, actual_user.__of__(acl_users)) - tv_key = 'PreferenceTool._getSortedPreferenceList/%s/%s' % (user.getId(), + #actual_user = acl_users.getUser(str(user)) + #if actual_user is not None: + # newSecurityManager(None, actual_user.__of__(acl_users)) + tv_key = 'PreferenceTool._getSortedPreferenceList/%s/%s' % (user, sql_catalog_id) if tv.get(tv_key, None) is None: prefs = [] -- 2.30.9 From c380aa5f67676b2024fe4e101fefc383b9b2cb4b Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Mon, 28 Nov 2016 15:14:58 +0000 Subject: [PATCH 21/23] multiple_catalog: Add action for catalog_prefence in Preference object --- .../portal_types/Preference/view_catalog.xml | 85 ++++++++++++ .../property_sheet_list.xml | 5 +- .../erp5_core/Preference_viewCatalog.xml | 131 ++++++++++++++++++ .../my_preferred_catalog.xml | 123 ++++++++++++++++ .../erp5_core/bt/template_action_path_list | 1 + .../template_portal_type_property_sheet_list | 3 +- 6 files changed, 346 insertions(+), 2 deletions(-) create mode 100644 product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/Preference/view_catalog.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Preference_viewCatalog.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Preference_viewCatalog/my_preferred_catalog.xml diff --git a/product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/Preference/view_catalog.xml b/product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/Preference/view_catalog.xml new file mode 100644 index 00000000000..16ab17c4a4b --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/ActionTemplateItem/portal_types/Preference/view_catalog.xml @@ -0,0 +1,85 @@ + + + + + + + + + + action + + AAAAAAAAAAI= + + + + categories + + + action_type/object_view + + + + + category + object_view + + + condition + + + + description + + + + + + icon + + + + id + view_catalog + + + permissions + + + View + + + + + portal_type + Action Information + + + priority + 8.0 + + + title + Catalog Preference + + + visible + 1 + + + + + + + + + + + + text + string:${object_url}/Preference_viewCatalog + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/PortalTypePropertySheetTemplateItem/property_sheet_list.xml b/product/ERP5/bootstrap/erp5_core/PortalTypePropertySheetTemplateItem/property_sheet_list.xml index e255a4565ae..53035aca76c 100644 --- a/product/ERP5/bootstrap/erp5_core/PortalTypePropertySheetTemplateItem/property_sheet_list.xml +++ b/product/ERP5/bootstrap/erp5_core/PortalTypePropertySheetTemplateItem/property_sheet_list.xml @@ -41,6 +41,9 @@ SortIndex + + CatalogPreference + ConstraintType @@ -78,4 +81,4 @@ SimpleItem Task - \ No newline at end of file + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Preference_viewCatalog.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Preference_viewCatalog.xml new file mode 100644 index 00000000000..ec8ef1e47dd --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Preference_viewCatalog.xml @@ -0,0 +1,131 @@ + + + + + + + + + + _objects + + + + + + action + Base_edit + + + description + + + + edit_order + + + + + + encoding + UTF-8 + + + enctype + + + + group_list + + + left + right + center + bottom + hidden + + + + + groups + + + + bottom + + + + + + center + + + + + + hidden + + + + + + left + + + my_preferred_catalog + + + + + right + + + + + + + + + id + Preference_viewCatalog + + + method + POST + + + name + Preference_viewCatalog + + + pt + form_view + + + row_length + 4 + + + stored_encoding + UTF-8 + + + title + Catalog Preference + + + unicode_mode + 0 + + + update_action + + + + update_action_title + + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Preference_viewCatalog/my_preferred_catalog.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Preference_viewCatalog/my_preferred_catalog.xml new file mode 100644 index 00000000000..998753d22aa --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Preference_viewCatalog/my_preferred_catalog.xml @@ -0,0 +1,123 @@ + + + + + + + + + + delegated_list + + + description + items + title + + + + + id + my_preferred_catalog + + + message_values + + + + external_validator_failed + The input failed the external validator. + + + + + + overrides + + + + field_id + + + + form_id + + + + + + + tales + + + + description + + + + field_id + + + + form_id + + + + items + + AAAAAAAAAAI= + + + + title + + + + + + + values + + + + description + Preferred Catalog + + + field_id + my_list_field + + + form_id + Base_viewFieldLibrary + + + items + + + + + + title + Catalog + + + + + + + + + + + + + + + _text + python:[(\'\', \'\')]+here.portal_catalog.getERP5CatalogIdList() + + + + + diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list b/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list index 16a5d985b6d..c233ac1f158 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_action_path_list @@ -102,6 +102,7 @@ Preference Type | update_local_roles Preference Type | view Preference | html_style_preferences Preference | view +Preference | view_catalog Preference | view_template Property Existence Constraint | predicate Property Existence Constraint | view diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_property_sheet_list b/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_property_sheet_list index 84e8bc87302..1e0ff02986c 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_property_sheet_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_property_sheet_list @@ -12,6 +12,7 @@ Category Related Membership State Constraint | ConstraintType Content Existence Constraint | ConstraintType Document Component | SortIndex Extension Component | SortIndex +Preference | CatalogPreference Property Existence Constraint | ConstraintType Property Type Validity Constraint | ConstraintType Python Script | CatalogFilter @@ -29,4 +30,4 @@ TALES Constraint | ConstraintType Test Component | SortIndex Trash Bin | Base Trash Bin | SimpleItem -Trash Bin | Task \ No newline at end of file +Trash Bin | Task -- 2.30.9 From 4e31b780aec82c2b302ab0214efcb56c053621d4 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Mon, 28 Nov 2016 16:18:13 +0000 Subject: [PATCH 22/23] multiple_catalog: Add preferred_catalog property in CatalogPreference property sheet --- .../preferred_catalog_property.xml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 product/ERP5/bootstrap/erp5_property_sheets/PropertySheetTemplateItem/portal_property_sheets/CatalogPreference/preferred_catalog_property.xml diff --git a/product/ERP5/bootstrap/erp5_property_sheets/PropertySheetTemplateItem/portal_property_sheets/CatalogPreference/preferred_catalog_property.xml b/product/ERP5/bootstrap/erp5_property_sheets/PropertySheetTemplateItem/portal_property_sheets/CatalogPreference/preferred_catalog_property.xml new file mode 100644 index 00000000000..a2aa66399da --- /dev/null +++ b/product/ERP5/bootstrap/erp5_property_sheets/PropertySheetTemplateItem/portal_property_sheets/CatalogPreference/preferred_catalog_property.xml @@ -0,0 +1,36 @@ + + + + + + + + + + categories + + + elementary_type/string + + + + + description + The catalog the user wants to use + + + id + preferred_catalog_property + + + portal_type + Standard Property + + + preference + 1 + + + + + -- 2.30.9 From ec1d2dfc40a561bfb288256e61ae243572acb674 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Mon, 12 Dec 2016 12:09:10 +0000 Subject: [PATCH 23/23] multiple_catalog: Debug --- product/ERP5Catalog/Tool/ERP5CatalogTool.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/product/ERP5Catalog/Tool/ERP5CatalogTool.py b/product/ERP5Catalog/Tool/ERP5CatalogTool.py index 2ad4dd40346..2c448af3802 100644 --- a/product/ERP5Catalog/Tool/ERP5CatalogTool.py +++ b/product/ERP5Catalog/Tool/ERP5CatalogTool.py @@ -157,9 +157,9 @@ class ERP5CatalogTool(BaseTool, CMFCore_CatalogTool): if id is None: # Better to get preferred catalog and use it is as the default catalog # instead of getting default catalog from properties - catalog_path = self.portal_preferences.getPreferredCatalog() - catalog = self.unrestrictedTraverse(catalog_path) - return catalog + #catalog_path = self.portal_preferences.getPreferredCatalog() + #catalog = self.unrestrictedTraverse(catalog_path) + #return catalog if not self.default_erp5_catalog_id: id_list = self.getERP5CatalogIdList() if len(id_list) > 0: -- 2.30.9