Commit e416ed7d authored by Julien Muchembled's avatar Julien Muchembled

wip

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41260 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8c1e8880
...@@ -187,8 +187,7 @@ class BusinessProcess(Path, XMLObject): ...@@ -187,8 +187,7 @@ class BusinessProcess(Path, XMLObject):
raise ValueError('explanation must not be a Root Applied Rule') raise ValueError('explanation must not be a Root Applied Rule')
trade_date = trade_model_path.getTradeDate() trade_date = trade_model_path.getTradeDate()
if not trade_date: assert trade_date, 'a trade_date must be defined on the Trade Model Path'
raise ValueError('a trade_date must be defined on every Trade Model Path')
reference_date_method_id = trade_model_path.getReferenceDateMethodId() reference_date_method_id = trade_model_path.getReferenceDateMethodId()
if not reference_date_method_id: if not reference_date_method_id:
...@@ -801,10 +800,10 @@ class BusinessProcess(Path, XMLObject): ...@@ -801,10 +800,10 @@ class BusinessProcess(Path, XMLObject):
# applied rules which are not root applied rules. # applied rules which are not root applied rules.
# XXX-JPS could be extended with a rule property instead # XXX-JPS could be extended with a rule property instead
# of supports only in root applied rule case # of supports only in root applied rule case
start_date, stop_date = self.getExpectedTradeModelPathStartAndStopDate( if trade_model_path.getTradeDate():
property_dict['start_date'], property_dict['stop_date'] = \
self.getExpectedTradeModelPathStartAndStopDate(
explanation, trade_model_path, delay_mode=delay_mode) explanation, trade_model_path, delay_mode=delay_mode)
property_dict['start_date'] = start_date
property_dict['stop_date'] = stop_date
else: else:
raise TypeError("Explanation must be an Applied Rule in expand process") # Nothing to do raise TypeError("Explanation must be an Applied Rule in expand process") # Nothing to do
return property_dict return property_dict
......
...@@ -47,23 +47,46 @@ class TestTaskReporting(ERP5ReportTestCase): ...@@ -47,23 +47,46 @@ class TestTaskReporting(ERP5ReportTestCase):
@reindex @reindex
def _makeOneTask(self, simulation_state='planned', **kw): def _makeOneTask(self, simulation_state='planned', **kw):
"""Create a task, support many options""" """Create a task, support many options"""
task_module = self.getPortalObject().task_module task = self.portal.task_module.newContent(portal_type='Task',
task = task_module.newContent(portal_type='Task', **kw) specialise=self.business_process)
task._edit(**kw)
if simulation_state == 'planned': if simulation_state == 'planned':
task.plan() task.plan()
if simulation_state == 'confirmed': if simulation_state == 'confirmed':
task.confirm() task.confirm()
def getRule(self, **kw):
return self.portal.portal_rules.searchFolder(
sort_on='version', sort_order='descending', **kw)[0].getObject()
def createBusinessProcess(self):
module = self.portal.business_process_module
id = self.__class__.__name__
try:
business_process = module[id]
except KeyError:
default = module.erp5_default_business_process
business_process = module.newContent(id, default.getPortalType(),
specialise_value=default)
delivery_path, = default.getTradeModelPathValueList(
trade_phase='default/delivery')
business_process.newContent(portal_type=delivery_path.getPortalType(),
reference=delivery_path.getReference(),
trade_phase=delivery_path.getTradePhase())
return business_process.getRelativeUrl()
def afterSetUp(self): def afterSetUp(self):
"""Setup the fixture. """Setup the fixture.
""" """
self.portal = self.getPortal() for rule_id in ('default_order_rule',
'default_delivery_rule',
for rule_id in ['default_order_rule', 'default_delivery_rule']: 'default_delivering_rule'):
rule = getattr(self.portal.portal_rules, rule_id) rule = self.getRule(reference=rule_id)
if rule.getValidationState() == 'draft': if rule.getValidationState() != 'validated':
rule.validate() rule.validate()
self.business_process = self.createBusinessProcess()
# create organisations # create organisations
if not self.portal.organisation_module.has_key('Organisation_1'): if not self.portal.organisation_module.has_key('Organisation_1'):
org = self.portal.organisation_module.newContent( org = self.portal.organisation_module.newContent(
...@@ -153,15 +176,13 @@ class TestTaskReporting(ERP5ReportTestCase): ...@@ -153,15 +176,13 @@ class TestTaskReporting(ERP5ReportTestCase):
"""Remove all documents. """Remove all documents.
""" """
transaction.abort() transaction.abort()
portal = self.portal
portal = self.getPortal()
portal.task_module.manage_delObjects( portal.task_module.manage_delObjects(
list(portal.task_module.objectIds())) list(portal.task_module.objectIds()))
portal.task_report_module.manage_delObjects( portal.task_report_module.manage_delObjects(
list(portal.task_report_module.objectIds())) list(portal.task_report_module.objectIds()))
portal.portal_simulation.manage_delObjects( portal.portal_simulation.manage_delObjects(
list(portal.portal_simulation.objectIds())) list(portal.portal_simulation.objectIds()))
transaction.commit() transaction.commit()
self.tic() self.tic()
......
...@@ -32,6 +32,8 @@ from Products.ERP5.tests.testProject import * ...@@ -32,6 +32,8 @@ from Products.ERP5.tests.testProject import *
test_suite_list.append(test_suite) test_suite_list.append(test_suite)
from Products.ERP5.tests.testTask import * from Products.ERP5.tests.testTask import *
test_suite_list.append(test_suite) test_suite_list.append(test_suite)
from Products.ERP5.tests.testTaskReporting import *
test_suite_list.append(test_suite)
from Products.ERP5.tests.testTaskReportDivergence import * from Products.ERP5.tests.testTaskReportDivergence import *
test_suite_list.append(test_suite) test_suite_list.append(test_suite)
...@@ -43,6 +45,10 @@ Legacy_getBusinessTemplateList(TestProject) ...@@ -43,6 +45,10 @@ Legacy_getBusinessTemplateList(TestProject)
TestTaskMixin.business_process = None TestTaskMixin.business_process = None
Legacy_getBusinessTemplateList(TestTaskMixin) Legacy_getBusinessTemplateList(TestTaskMixin)
TestTaskReporting.createBusinessProcess = lambda self: None
Legacy_getBusinessTemplateList(TestTaskReporting)
def test_suite(): def test_suite():
suite = test_suite_list[0]() suite = test_suite_list[0]()
for test_suite in test_suite_list[1:]: for test_suite in test_suite_list[1:]:
......
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