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):
raise ValueError('explanation must not be a Root Applied Rule')
trade_date = trade_model_path.getTradeDate()
if not trade_date:
raise ValueError('a trade_date must be defined on every Trade Model Path')
assert trade_date, 'a trade_date must be defined on the Trade Model Path'
reference_date_method_id = trade_model_path.getReferenceDateMethodId()
if not reference_date_method_id:
......@@ -801,10 +800,10 @@ class BusinessProcess(Path, XMLObject):
# applied rules which are not root applied rules.
# XXX-JPS could be extended with a rule property instead
# 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)
property_dict['start_date'] = start_date
property_dict['stop_date'] = stop_date
else:
raise TypeError("Explanation must be an Applied Rule in expand process") # Nothing to do
return property_dict
......
......@@ -47,23 +47,46 @@ class TestTaskReporting(ERP5ReportTestCase):
@reindex
def _makeOneTask(self, simulation_state='planned', **kw):
"""Create a task, support many options"""
task_module = self.getPortalObject().task_module
task = task_module.newContent(portal_type='Task', **kw)
task = self.portal.task_module.newContent(portal_type='Task',
specialise=self.business_process)
task._edit(**kw)
if simulation_state == 'planned':
task.plan()
if simulation_state == 'confirmed':
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):
"""Setup the fixture.
"""
self.portal = self.getPortal()
for rule_id in ['default_order_rule', 'default_delivery_rule']:
rule = getattr(self.portal.portal_rules, rule_id)
if rule.getValidationState() == 'draft':
for rule_id in ('default_order_rule',
'default_delivery_rule',
'default_delivering_rule'):
rule = self.getRule(reference=rule_id)
if rule.getValidationState() != 'validated':
rule.validate()
self.business_process = self.createBusinessProcess()
# create organisations
if not self.portal.organisation_module.has_key('Organisation_1'):
org = self.portal.organisation_module.newContent(
......@@ -153,15 +176,13 @@ class TestTaskReporting(ERP5ReportTestCase):
"""Remove all documents.
"""
transaction.abort()
portal = self.getPortal()
portal = self.portal
portal.task_module.manage_delObjects(
list(portal.task_module.objectIds()))
portal.task_report_module.manage_delObjects(
list(portal.task_report_module.objectIds()))
portal.portal_simulation.manage_delObjects(
list(portal.portal_simulation.objectIds()))
transaction.commit()
self.tic()
......
......@@ -32,6 +32,8 @@ from Products.ERP5.tests.testProject import *
test_suite_list.append(test_suite)
from Products.ERP5.tests.testTask import *
test_suite_list.append(test_suite)
from Products.ERP5.tests.testTaskReporting import *
test_suite_list.append(test_suite)
from Products.ERP5.tests.testTaskReportDivergence import *
test_suite_list.append(test_suite)
......@@ -43,6 +45,10 @@ Legacy_getBusinessTemplateList(TestProject)
TestTaskMixin.business_process = None
Legacy_getBusinessTemplateList(TestTaskMixin)
TestTaskReporting.createBusinessProcess = lambda self: None
Legacy_getBusinessTemplateList(TestTaskReporting)
def test_suite():
suite = test_suite_list[0]()
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