Commit 7139dc1e authored by Arnaud Fontaine's avatar Arnaud Fontaine Committed by Romain Courteaud

WIP

parent ccdff868
......@@ -43,6 +43,21 @@ END_STATE_TITLE = 'End'
## TODO-ERP5Workflow: Initially part of Workflow implementation done for
## ERP5Configurator but not used by ERP5 Workflow...
def initializeDocument(workflow, document):
"""
Set initial state on the Document
"""
state_bc_id = workflow.getStateBaseCategory()
document.setCategoryMembership(state_bc_id, workflow.getSource())
object = workflow.getStateChangeInformation(document, workflow.getSourceValue())
# Initialize workflow history
status_dict = {state_bc_id: workflow.getSource()}
variable_list = workflow.contentValues(portal_type='Workflow Variable')
for variable in variable_list:
status_dict[variable.getTitle()] = variable.getVariableValue(object=object)
workflow._updateWorkflowHistory(document, status_dict)
def _generateHistoryKey(workflow):
"""
Generate a key used in the workflow history.
......
......@@ -62,6 +62,18 @@ class CategoryTool(CMFCategoryTool, BaseTool):
objectValues = BaseTool.objectValues
def _isBootstrapRequired(self):
return 'before_script' not in self
def _bootstrap(self):
from Products.ERP5.ERP5Site import ERP5Generator
ERP5Generator.bootstrap(self, 'erp5_core', 'CategoryTemplateItem', (
'before_script',
'before_commit_script',
'activate_script',
'after_script',
))
# Filter content (ZMI))
def filtered_meta_types(self, user=None):
# Filters the list of available meta types.
......
......@@ -497,6 +497,9 @@ class ERP5TypeInformation(XMLObject,
"""Getter for 'type_workflow' property"""
return list(self.workflow_list)
def _setTypeWorkflowList(self, type_workflow_list):
self.workflow_list = type_workflow_list
security.declareProtected(Permissions.ModifyPortalContent,
'setTypeWorkflowList')
def setTypeWorkflowList(self, type_workflow_list):
......
......@@ -67,7 +67,7 @@ class PropertySheetTool(BaseTool):
'template_tool_component_id_property')
def _isBootstrapRequired(self):
if not self.has_key('BaseType'):
if not self.has_key('Interaction'):
return True
bt_has_key = self.BusinessTemplate.has_key
......
......@@ -101,7 +101,7 @@ class TypesTool(TypeProvider):
security.declareObjectProtected(Permissions.AccessContentsInformation)
def _isBootstrapRequired(self):
if not self.has_key('Standard Property'):
if not self.has_key('Interaction Workflow'):
return True
# bootstrap is not required, but we may have a few bugfixes to apply
# so that the user can upgrade Business Templates
......@@ -133,7 +133,11 @@ class TypesTool(TypeProvider):
'Standard Property',
'Acquired Property',
# workflow (initializePortalTypeDynamicWorkflowMethods)
'State',
'Transition',
'Workflow Script',
'Workflow Variable',
'Worklist',
'Workflow',
'Interaction',
'Interaction Workflow',
......@@ -143,6 +147,8 @@ class TypesTool(TypeProvider):
'Catalog Tool',
))
ERP5Generator.bootstrap_allow_type(self, 'Catalog Tool')
ERP5Generator.bootstrap_allow_type(self, 'Workflow')
ERP5Generator.bootstrap_allow_type(self, 'Interaction Workflow')
def listContentTypes(self, container=None):
"""List content types from all providers
......
......@@ -434,10 +434,11 @@ def synchronizeDynamicModules(context, force=False):
from Products.ERP5Type.Tool.PropertySheetTool import PropertySheetTool
from Products.ERP5Type.Tool.TypesTool import TypesTool
from Products.ERP5Type.Tool.ComponentTool import ComponentTool
from Products.ERP5.Tool.CategoryTool import CategoryTool
from Products.ERP5Type.Tool.WorkflowTool import WorkflowTool
from Products.ERP5Catalog.Tool.ERP5CatalogTool import ERP5CatalogTool
try:
for tool_class in TypesTool, PropertySheetTool, ComponentTool, ERP5CatalogTool, WorkflowTool:
for tool_class in TypesTool, PropertySheetTool, ComponentTool, ERP5CatalogTool, CategoryTool, WorkflowTool:
# if the instance has no property sheet tool, or incomplete
# property sheets, we need to import some data to bootstrap
# (only likely to happen on the first run ever)
......
......@@ -1229,7 +1229,8 @@ def convertToERP5Workflow(self, temp_object=False):
trash_tool = getattr(portal, 'portal_trash', None)
if trash_tool is not None:
# move old workflow to trash tool;
LOG(" | Move old workflow '%s' into a trash bin", 0, self.id)
LOG("convertToERP5Workflow", 0,
"Move old workflow '%s' into a trash bin" % self.id)
workflow_tool._delOb(self.id)
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
trashbin = UnrestrictedMethod(trash_tool.newTrashBin)(self.id)
......
......@@ -205,6 +205,7 @@ def WorkflowTool_bootstrap(self):
WorkflowTool._isBootstrapRequired = WorkflowTool_isBootstrapRequired
WorkflowTool._bootstrap = WorkflowTool_bootstrap
WorkflowTool.getWorkflowValueListFor = WorkflowTool.getWorkflowsFor
def _deleteChainsByType(self, pt, wf_id):
self._chains_by_type[pt] = tuple(wf for wf in self._chains_by_type[pt] if wf!=wf_id)
......
......@@ -944,14 +944,6 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
light_install = self.enableLightInstall()
create_activities = self.enableActivityTool()
hot_reindexing = self.enableHotReindexing()
for x, y in (("erp5_core_proxy_field_legacy", "erp5_base"),
("erp5_stock_cache", "erp5_pdm")):
if x not in template_list:
try:
template_list.insert(template_list.index(y), x)
except ValueError:
pass
self.setUpERP5Site(business_template_list=template_list,
light_install=light_install,
create_activities=create_activities,
......@@ -1274,9 +1266,8 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
self.dynamicWorkflowConversion()
portal.portal_types.resetDynamicDocumentsOnceAtTransactionBoundary()
self.getPortal().erp5_sql_connection.manage_test("update message_queue set processing_node=0, priority=1 where processing_node=-1")
self.getPortal().erp5_sql_connection.manage_test("update message set processing_node=0, priority=2 where processing_node=-1")
self.tic(not quiet)
# Log out
if not quiet:
ZopeTestCase._print('Logout ... \n')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment