Commit 2b4fce56 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Remove the use of status attribute and use workflow for checking status

parent e5349cfd
...@@ -171,7 +171,6 @@ class BusinessManager(Folder): ...@@ -171,7 +171,6 @@ class BusinessManager(Folder):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
template_format_version = 3 template_format_version = 3
status = 'uninstalled'
# Factory Type Information # Factory Type Information
factory_type_information = \ factory_type_information = \
...@@ -206,24 +205,27 @@ class BusinessManager(Folder): ...@@ -206,24 +205,27 @@ class BusinessManager(Folder):
def getShortRevision(self): def getShortRevision(self):
return None return None
def getStatus(self): security.declareProtected(Permissions.AccessContentsInformation,
'getBuildingState')
def getBuildingState(self, default=None, id_only=1):
""" """
installed :BI(s) are installed in OFS. Returns the current state in building
uninstalled :Values for BI(s) at the current version removed from OFS.
reduced :No two BI of same path exist at different layers.
flatenned :BI(s) should be at the zeroth layer.
built :BI(s) do have values from the OS DB.
""" """
return self.status portal_workflow = getToolByName(self, 'portal_workflow')
wf = portal_workflow.getWorkflowById(
def getInstallationState(self): 'business_manager_building_workflow')
return self.status return wf._getWorkflowStateOf(self, id_only=id_only )
def setStatus(self, status=None): security.declareProtected(Permissions.AccessContentsInformation,
if not status: 'getInstallationState')
raise ValueError, 'No status provided' def getInstallationState(self, default=None, id_only=1):
else: """
self.status = status Returns the current state in installation
"""
portal_workflow = getToolByName(self.getPortalObject(), 'portal_workflow')
wf = portal_workflow.getWorkflowById(
'business_manager_installation_workflow')
return wf._getWorkflowStateOf(self, id_only=id_only )
def applytoERP5(self, DB): def applytoERP5(self, DB):
"""Apply the flattened/reduced Business Manager to the DB""" """Apply the flattened/reduced Business Manager to the DB"""
...@@ -257,7 +259,7 @@ class BusinessManager(Folder): ...@@ -257,7 +259,7 @@ class BusinessManager(Folder):
""" """
Export the object as zexp file Export the object as zexp file
""" """
if not self.getStatus() == 'built': if not self.getBuildingState() == 'built':
raise ValueError, 'Manager not built properly' raise ValueError, 'Manager not built properly'
f = StringIO() f = StringIO()
...@@ -440,7 +442,6 @@ class BusinessManager(Folder): ...@@ -440,7 +442,6 @@ class BusinessManager(Folder):
kwargs['removable_property_list'] = removable_property_dict.get(item_path, []) kwargs['removable_property_list'] = removable_property_dict.get(item_path, [])
kwargs['remove_sub_objects'] = item_path in removable_sub_object_path_list kwargs['remove_sub_objects'] = item_path in removable_sub_object_path_list
path_item.build(self, **kwargs) path_item.build(self, **kwargs)
self.status = 'built'
return self return self
def flattenBusinessManager(self): def flattenBusinessManager(self):
...@@ -543,7 +544,6 @@ class BusinessManager(Folder): ...@@ -543,7 +544,6 @@ class BusinessManager(Folder):
reduced_path_item_list.append(prioritized_path_item[0]) reduced_path_item_list.append(prioritized_path_item[0])
self._path_item_list = reduced_path_item_list self._path_item_list = reduced_path_item_list
self.setStatus('reduced')
def _simplifyValueIntersection(self, added_value, subtracted_value): def _simplifyValueIntersection(self, added_value, subtracted_value):
""" """
......
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