Commit 7511be13 authored by Julien Muchembled's avatar Julien Muchembled

Many fixes in testPackingList

- merge patches from testERP5Simulation
- resurrect some solvers that were deleted by mistake
- configure PPL builder like SPL builder for specialise

Also remove expected broken test in testLegacyTradeModelLine

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@38111 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 277adf8b
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SolverTypeInformation" module="Products.ERP5Type.Document.SolverTypeInformation"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_property_domain_dict</string> </key>
<value>
<dictionary>
<item>
<key> <string>short_title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>acquire_local_roles</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The FIFO solver reduces delivered quantity by reducing the quantity of simulation movements from the last order.</string> </value>
</item>
<item>
<key> <string>factory</string> </key>
<value> <string>addFIFODeliverySolver</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<tuple>
<string>delivery_solver</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>FIFO Delivery Solver</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Solver Type</string> </value>
</item>
<item>
<key> <string>solver_action_title</string> </key>
<value> <string>First In, First Out</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TranslationInformation" module="Products.ERP5Type.TranslationProviderBase"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>domain_name</string> </key>
<value> <string>erp5_content</string> </value>
</item>
<item>
<key> <string>property_name</string> </key>
<value> <string>short_title</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="TranslationInformation" module="Products.ERP5Type.TranslationProviderBase"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>domain_name</string> </key>
<value> <string>erp5_content</string> </value>
</item>
<item>
<key> <string>property_name</string> </key>
<value> <string>title</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SolverTypeInformation" module="Products.ERP5Type.Document.SolverTypeInformation"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_property_domain_dict</string> </key>
<value>
<dictionary>
<item>
<key> <string>short_title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>acquire_local_roles</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The LIFO solver reduces delivered quantity by reducing the quantity of simulation movements from the last order.</string> </value>
</item>
<item>
<key> <string>factory</string> </key>
<value> <string>addLIFODeliverySolver</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<tuple>
<string>delivery_solver</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>LIFO Delivery Solver</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Solver Type</string> </value>
</item>
<item>
<key> <string>solver_action_title</string> </key>
<value> <string>Last In, First Out</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TranslationInformation" module="Products.ERP5Type.TranslationProviderBase"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>domain_name</string> </key>
<value> <string>erp5_content</string> </value>
</item>
<item>
<key> <string>property_name</string> </key>
<value> <string>short_title</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="TranslationInformation" module="Products.ERP5Type.TranslationProviderBase"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>domain_name</string> </key>
<value> <string>erp5_content</string> </value>
</item>
<item>
<key> <string>property_name</string> </key>
<value> <string>title</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SolverTypeInformation" module="Products.ERP5Type.Document.SolverTypeInformation"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_property_domain_dict</string> </key>
<value>
<dictionary>
<item>
<key> <string>short_title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>acquire_local_roles</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The Minimise Price solver reduces delivered quantity by reducing the quantity of simulation movements from the last order.</string> </value>
</item>
<item>
<key> <string>factory</string> </key>
<value> <string>addMinimisePriceDeliverySolver</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<tuple>
<string>delivery_solver</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Minimise Price Delivery Solver</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Solver Type</string> </value>
</item>
<item>
<key> <string>solver_action_title</string> </key>
<value> <string>Minimise Price</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TranslationInformation" module="Products.ERP5Type.TranslationProviderBase"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>domain_name</string> </key>
<value> <string>erp5_content</string> </value>
</item>
<item>
<key> <string>property_name</string> </key>
<value> <string>short_title</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="TranslationInformation" module="Products.ERP5Type.TranslationProviderBase"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>domain_name</string> </key>
<value> <string>erp5_content</string> </value>
</item>
<item>
<key> <string>property_name</string> </key>
<value> <string>title</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -23,6 +23,12 @@ portal_solvers/Accept Solver ...@@ -23,6 +23,12 @@ portal_solvers/Accept Solver
portal_solvers/Accept Solver/* portal_solvers/Accept Solver/*
portal_solvers/Adopt Solver portal_solvers/Adopt Solver
portal_solvers/Adopt Solver/* portal_solvers/Adopt Solver/*
portal_solvers/FIFO Delivery Solver
portal_solvers/FIFO Delivery Solver/*
portal_solvers/LIFO Delivery Solver
portal_solvers/LIFO Delivery Solver/*
portal_solvers/Minimise Price Delivery Solver
portal_solvers/Minimise Price Delivery Solver/*
portal_solvers/Production Reduction Solver portal_solvers/Production Reduction Solver
portal_solvers/Production Reduction Solver/* portal_solvers/Production Reduction Solver/*
portal_solvers/Quantity Cancel Solver portal_solvers/Quantity Cancel Solver
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
<string>destination_account</string> <string>destination_account</string>
<string>source_function</string> <string>source_function</string>
<string>destination_function</string> <string>destination_function</string>
<string>specialise</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -44,15 +44,6 @@ class TestERP5SimulationMixin(TestInvoiceMixin): ...@@ -44,15 +44,6 @@ class TestERP5SimulationMixin(TestInvoiceMixin):
def afterSetUp(self, quiet=1, run=1): def afterSetUp(self, quiet=1, run=1):
TestInvoiceMixin.afterSetUp(self) TestInvoiceMixin.afterSetUp(self)
portal_rules = self.portal.portal_rules
for rule in portal_rules.objectValues(portal_type='Order Root Simulation Rule'):
if rule.getValidationState() == 'validated':
rule.invalidate()
self.validateNewRules()
self.setUpBusinessProcess()
def setUpBusinessProcess(self):
business_process = self.portal.business_process_module.erp5_default_business_process business_process = self.portal.business_process_module.erp5_default_business_process
pay_business_link = business_process['pay'] pay_business_link = business_process['pay']
pay_business_link.setSource('account_module/bank') pay_business_link.setSource('account_module/bank')
...@@ -125,296 +116,6 @@ class TestERP5SimulationMixin(TestInvoiceMixin): ...@@ -125,296 +116,6 @@ class TestERP5SimulationMixin(TestInvoiceMixin):
if new_order_rule.getValidationState() != 'validated': if new_order_rule.getValidationState() != 'validated':
new_order_rule.validate() new_order_rule.validate()
def stepCreateOrder(self,sequence=None, sequence_list=None, **kw):
"""
Create a empty order
"""
organisation = sequence.get('organisation')
project = sequence.get('project')
# person = sequence.get('person')
portal = self.getPortal()
order_module = portal.getDefaultModule(portal_type=self.order_portal_type)
order = order_module.newContent(portal_type=self.order_portal_type)
order.edit(
title = "Order%s" % order.getId(),
specialise='business_process_module/erp5_default_business_process',
start_date = self.datetime + 10,
stop_date = self.datetime + 20,
)
if organisation is not None:
order.edit(source_value=organisation,
source_section_value=organisation,
destination_value=organisation,
destination_section_value=organisation,
# Added for test Packing List Copy
source_decision_value=organisation,
destination_decision_value=organisation,
source_administration_value=organisation,
destination_administration_value=organisation,
)
if project is not None:
order.edit(source_project_value=project,
destination_project_value=project,
)
sequence.edit( order = order )
def _acceptDecisionQuantity(self, document):
solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(document)
quantity_solver_decision = filter(
lambda x:x.getCausalityValue().getTestedProperty()=='quantity',
solver_process.contentValues())[0]
# use Quantity Accept Solver.
quantity_solver_decision.setSolverValue(self.portal.portal_solvers['Accept Solver'])
# configure for Accept Solver.
kw = {'tested_property_list':['quantity',]}
quantity_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def _acceptDivergenceOnInvoice(self, invoice, divergence_list):
print invoice, divergence_list
return self._acceptDecisionQuantity(invoice)
def stepAcceptDecisionQuantity(self,sequence=None, sequence_list=None):
"""
Solve quantity divergence by using solver tool.
"""
packing_list = sequence.get('packing_list')
self._acceptDecisionQuantity(packing_list)
def stepAcceptDecisionQuantityInvoice(self, sequence=None,
sequence_list=None):
"""
Solve quantity divergence by using solver tool.
"""
invoice = sequence.get('invoice')
self._acceptDecisionQuantity(invoice)
def stepAcceptDecisionResource(self,sequence=None, sequence_list=None):
"""
Solve quantity divergence by using solver tool.
"""
packing_list = sequence.get('packing_list')
solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(packing_list)
resource_solver_decision = filter(
lambda x:x.getCausalityValue().getTestedProperty()=='resource',
solver_process.contentValues())[0]
# use Resource Replacement Solver.
resource_solver_decision.setSolverValue(self.portal.portal_solvers['Accept Solver'])
# configure for Accept Solver.
kw = {'tested_property_list':['resource',]}
resource_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def stepSplitAndDeferPackingList(self, sequence=None, sequence_list=None):
"""
Do the split and defer action
"""
packing_list = sequence.get('packing_list')
solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(packing_list)
quantity_solver_decision = filter(
lambda x:x.getCausalityValue().getTestedProperty()=='quantity',
solver_process.contentValues())[0]
# use Quantity Split Solver.
quantity_solver_decision.setSolverValue(self.portal.portal_solvers['Quantity Split Solver'])
# configure for Quantity Split Solver.
kw = {'delivery_solver':'FIFO Delivery Solver',
'start_date':self.datetime + 15,
'stop_date':self.datetime + 25}
quantity_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
# build split deliveries manually. XXX ad-hoc
previous_tag = None
for delivery_builder in packing_list.getBuilderList():
this_builder_tag = '%s_split_%s' % (packing_list.getPath(),
delivery_builder.getId())
after_tag = []
if previous_tag:
after_tag.append(previous_tag)
delivery_builder.activate(
after_method_id=('solve',
'immediateReindexObject',
'recursiveImmediateReindexObject',), # XXX too brutal.
after_tag=after_tag,
).build(explanation_uid=packing_list.getCausalityValue().getUid())
def _adoptPrevisionQuantity(self, packing_list):
"""
Solve quantity divergence by using solver tool.
"""
solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(packing_list)
quantity_solver_decision = filter(
lambda x:x.getCausalityValue().getTestedProperty()=='quantity',
solver_process.contentValues())[0]
# use Quantity Adoption Solver.
quantity_solver_decision.setSolverValue(self.portal.portal_solvers['Adopt Solver'])
# configure for Adopt Solver.
kw = {'tested_property_list':['quantity',]}
quantity_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def _adoptDivergenceOnInvoice(self, invoice, divergence_list):
print invoice, divergence_list
return self._adoptPrevisionQuantity(invoice)
def _adoptDivergenceOnPackingList(self, packing_list, divergence_list):
print packing_list, divergence_list
return self._adoptPrevisionQuantity(packing_list)
def stepAdoptPrevisionQuantity(self,sequence=None, sequence_list=None):
"""
Solve quantity divergence by using solver tool.
"""
packing_list = sequence.get('packing_list')
self._adoptPrevisionQuantity(packing_list)
def stepNewPackingListAdoptPrevisionQuantity(self, sequence=None,
sequence_list=None):
"""
Solve quantity divergence by using solver tool.
"""
packing_list = sequence.get('new_packing_list')
self._adoptPrevisionQuantity(packing_list)
def stepAdoptPrevisionResource(self,sequence=None, sequence_list=None):
"""
Solve resource divergence by using solver tool.
"""
packing_list = sequence.get('packing_list')
solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(packing_list)
resource_solver_decision = filter(
lambda x:x.getCausalityValue().getTestedProperty()=='resource',
solver_process.contentValues())[0]
# use Resource Adopt Solver.
resource_solver_decision.setSolverValue(self.portal.portal_solvers['Adopt Solver'])
# configure for Adopt Solver.
kw = {'tested_property_list':['resource',]}
resource_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def stepCheckPackingListLineWithSameResource(self,sequence=None, sequence_list=None):
"""
Look if the packing list has new previsions
"""
old_packing_list_line = sequence.get('packing_list_line')
packing_list_line = old_packing_list_line.aq_parent[str(int(old_packing_list_line.getId())-1)]
resource = sequence.get('resource')
for line in sequence.get('packing_list').getMovementList():
self.assertEquals(line.getResourceValue(), resource)
self.assertEquals(line.getQuantity(), self.default_quantity)
self.assertEquals(line.getCausalityList(),
[x.getParentValue().getParentValue().getDelivery() for x in \
line.getDeliveryRelatedValueList()])
def stepUnifyDestinationWithDecision(self,sequence=None, sequence_list=None):
"""
Check if simulation movement are disconnected
"""
packing_list = sequence.get('packing_list')
solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(packing_list)
for destination_solver_decision in filter(
lambda x:x.getCausalityValue().getTestedProperty()=='destination',
solver_process.contentValues()):
# use Destination Replacement Solver.
destination_solver_decision.setSolverValue(self.portal.portal_solvers['Accept Solver'])
# configure for Accept Solver.
kw = {'tested_property_list':['destination',]}
destination_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def _unifyStartDateWithDecision(self, document):
solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(document)
for start_date_solver_decision in filter(
lambda x:x.getCausalityValue().getTestedProperty()=='start_date',
solver_process.contentValues()):
# use StartDate Replacement Solver.
start_date_solver_decision.setSolverValue(self.portal.portal_solvers['Unify Solver'])
# configure for Unify Solver.
kw = {'tested_property_list':['start_date',],
'value':document.getStartDate()}
start_date_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def stepUnifyStartDateWithDecision(self,sequence=None, sequence_list=None):
packing_list = sequence.get('packing_list')
self._unifyStartDateWithDecision(packing_list)
def stepUnifyStartDateWithDecisionInvoice(self,sequence=None, sequence_list=None):
invoice = sequence.get('invoice')
self._unifyStartDateWithDecision(invoice)
def stepUnifyStartDateWithPrevision(self,sequence=None, sequence_list=None):
"""
Check if simulation movement are disconnected
"""
packing_list = sequence.get('packing_list')
applied_rule = sequence.get('applied_rule')
simulation_line_list = applied_rule.objectValues()
start_date = simulation_line_list[-1].getStartDate()
solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(packing_list)
for start_date_solver_decision in filter(
lambda x:x.getCausalityValue().getTestedProperty()=='start_date',
solver_process.contentValues()):
# use StartDate Replacement Solver.
start_date_solver_decision.setSolverValue(self.portal.portal_solvers['Unify Solver'])
# configure for Unify Solver.
kw = {'tested_property_list':['start_date',],
'value':start_date}
start_date_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def stepCheckPackingListLineWithDifferentResource(self,sequence=None, sequence_list=None):
"""
Look if the packing list has new previsions
"""
packing_list_line = sequence.get('packing_list_line')
new_resource = sequence.get('resource')
self.assertEquals(packing_list_line.getQuantity(), self.default_quantity*2)
self.assertEquals(packing_list_line.getResourceValue(), new_resource)
simulation_line_list = packing_list_line.getDeliveryRelatedValueList()
order_line_list = sum([x.getParentValue().getParentValue().getDeliveryList() for x in simulation_line_list], [])
self.assertEquals(sorted(packing_list_line.getCausalityList()),
sorted(order_line_list))
def stepCheckSimulationMovementHasRecordedQuantity(self, sequence=None,
sequence_list=None):
movement_list = sequence.get('packing_list').objectValues(
portal_type=self.packing_list_line_portal_type)
self._checkRecordedProperty(movement_list, 'quantity', True)
def stepCheckSimulationMovementHasNoRecordedQuantity(self, sequence=None,
sequence_list=None):
movement_list = sequence.get('packing_list').objectValues(
portal_type=self.packing_list_line_portal_type)
self._checkRecordedProperty(movement_list, 'quantity', False)
def stepCheckSimulationMovementHasRecordedResource(self, sequence=None,
sequence_list=None):
movement_list = sequence.get('packing_list').objectValues(
portal_type=self.packing_list_line_portal_type)
self._checkRecordedProperty(movement_list, 'resource', True)
def stepCheckSimulationMovementHasNoRecordedResource(self, sequence=None,
sequence_list=None):
movement_list = sequence.get('packing_list').objectValues(
portal_type=self.packing_list_line_portal_type)
self._checkRecordedProperty(movement_list, 'resource', False)
class TestERP5Simulation(TestERP5SimulationMixin, ERP5TypeTestCase): class TestERP5Simulation(TestERP5SimulationMixin, ERP5TypeTestCase):
run_all_test = 1 run_all_test = 1
quiet = 0 quiet = 0
...@@ -576,25 +277,6 @@ class TestERP5Simulation(TestERP5SimulationMixin, ERP5TypeTestCase): ...@@ -576,25 +277,6 @@ class TestERP5Simulation(TestERP5SimulationMixin, ERP5TypeTestCase):
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
class TestERP5SimulationPackingList(TestERP5SimulationMixin, TestPackingList):
pass
for failing_method in [
# This test does not work as it is because of the different behaviour of
# Adopt Solver.
'test_05d_SimulationChangeResourceOnOneSimulationMovementForMergedLine',
# Those tests currently fail because they are making assertions on an applied
# rule which with the new simulation structure is not the same as in the
# original test packing list
'test_06_SimulationChangeStartDate',
'test_07_SimulationChangeStartDateWithTwoOrderLine',
'test_07a_SimulationChangeStartDateWithTwoOrderLine',
]:
setattr(TestERP5SimulationPackingList, failing_method,
expectedFailure(getattr(TestERP5SimulationPackingList, failing_method)))
class TestERP5SimulationInvoice(TestERP5SimulationMixin, TestSaleInvoice): class TestERP5SimulationInvoice(TestERP5SimulationMixin, TestSaleInvoice):
quiet = TestSaleInvoice.quiet quiet = TestSaleInvoice.quiet
......
...@@ -964,11 +964,11 @@ class TestInvoiceMixin(TestPackingListMixin, ...@@ -964,11 +964,11 @@ class TestInvoiceMixin(TestPackingListMixin,
sequence_list=None): sequence_list=None):
invoice = sequence.get('invoice') invoice = sequence.get('invoice')
self._solveDeliveryGroupDivergence(invoice, 'start_date', self._solveDeliveryGroupDivergence(invoice, 'start_date',
invoice.getRelativeUrl()) 'Unify Solver', value=invoice.getStartDate())
def stepAcceptDecisionQuantityInvoice(self,sequence=None, sequence_list=None): def stepAcceptDecisionQuantityInvoice(self,sequence=None, sequence_list=None):
invoice = sequence.get('invoice') invoice = sequence.get('invoice')
self._solveDivergence(invoice, 'quantity', 'accept') self._solveDivergence(invoice, 'quantity', 'Accept Solver')
def stepAcceptDecisionInvoice(self, sequence=None, sequence_list=None, def stepAcceptDecisionInvoice(self, sequence=None, sequence_list=None,
**kw): **kw):
...@@ -2313,11 +2313,8 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent( ...@@ -2313,11 +2313,8 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent(
def _acceptDivergenceOnInvoice(self, invoice, divergence_list): def _acceptDivergenceOnInvoice(self, invoice, divergence_list):
builder_list = invoice.getBuilderList() print invoice, divergence_list
self.assertEquals(2, len(builder_list)) self._solveDivergence(invoice, 'quantity', 'Accept Solver')
for builder in builder_list:
builder.solveDivergence(invoice.getRelativeUrl(),
divergence_to_accept_list=divergence_list)
def test_accept_quantity_divergence_on_invoice_with_stopped_packing_list( def test_accept_quantity_divergence_on_invoice_with_stopped_packing_list(
self, quiet=quiet): self, quiet=quiet):
...@@ -2373,11 +2370,8 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent( ...@@ -2373,11 +2370,8 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent(
self.assertEquals('solved', packing_list.getCausalityState()) self.assertEquals('solved', packing_list.getCausalityState())
def _adoptDivergenceOnInvoice(self, invoice, divergence_list): def _adoptDivergenceOnInvoice(self, invoice, divergence_list):
builder_list = invoice.getBuilderList() print invoice, divergence_list
self.assertEquals(2, len(builder_list)) self._solveDivergence(invoice, 'quantity', 'Adopt Solver')
for builder in builder_list:
builder.solveDivergence(invoice.getRelativeUrl(),
divergence_to_adopt_list=divergence_list)
def test_adopt_quantity_divergence_on_invoice_line_with_stopped_packing_list( def test_adopt_quantity_divergence_on_invoice_line_with_stopped_packing_list(
self, quiet=quiet): self, quiet=quiet):
......
...@@ -294,16 +294,33 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -294,16 +294,33 @@ class TestPackingListMixin(TestOrderMixin):
Do the split and defer action Do the split and defer action
""" """
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
kw = {'listbox':[ solver_process_tool = self.portal.portal_solver_processes
{'listbox_key':line.getRelativeUrl(), solver_process = solver_process_tool.newSolverProcess(packing_list)
'choice':'SplitAndDefer'} for line in packing_list.getMovementList() \ quantity_solver_decision, = [x for x in solver_process.contentValues()
if line.isDivergent()]} if x.getCausalityValue().getTestedProperty() == 'quantity']
self.portal.portal_workflow.doActionFor( # use Quantity Split Solver.
packing_list, quantity_solver_decision.setSolverValue(self.portal.portal_solvers['Quantity Split Solver'])
'split_and_defer_action', # configure for Quantity Split Solver.
start_date=self.datetime + 15, kw = {'delivery_solver':'FIFO Delivery Solver',
stop_date=self.datetime + 25, 'start_date':self.datetime + 15,
**kw) 'stop_date':self.datetime + 25}
quantity_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
# build split deliveries manually. XXX ad-hoc
previous_tag = None
for delivery_builder in packing_list.getBuilderList():
this_builder_tag = '%s_split_%s' % (packing_list.getPath(),
delivery_builder.getId())
after_tag = []
if previous_tag:
after_tag.append(previous_tag)
delivery_builder.activate(
after_method_id=('solve',
'immediateReindexObject',
'recursiveImmediateReindexObject',), # XXX too brutal.
after_tag=after_tag,
).build(explanation_uid=packing_list.getCausalityValue().getUid())
def stepSplitAndDeferDoNothingPackingList(self, sequence=None, sequence_list=None, **kw): def stepSplitAndDeferDoNothingPackingList(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -627,7 +644,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -627,7 +644,7 @@ class TestPackingListMixin(TestOrderMixin):
Check if simulation movement are disconnected Check if simulation movement are disconnected
""" """
packing_list = sequence.get('new_packing_list') packing_list = sequence.get('new_packing_list')
self._solveDivergence(packing_list, 'quantity', 'adopt') self._solveDivergence(packing_list, 'quantity', 'Adopt Solver')
def stepUnifyDestinationWithDecision(self,sequence=None, sequence_list=None, **kw): def stepUnifyDestinationWithDecision(self,sequence=None, sequence_list=None, **kw):
""" """
...@@ -635,7 +652,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -635,7 +652,7 @@ class TestPackingListMixin(TestOrderMixin):
""" """
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
self._solveDeliveryGroupDivergence(packing_list, 'destination', self._solveDeliveryGroupDivergence(packing_list, 'destination',
packing_list.getRelativeUrl()) 'Accept Solver')
def stepUnifyStartDateWithDecision(self,sequence=None, sequence_list=None, **kw): def stepUnifyStartDateWithDecision(self,sequence=None, sequence_list=None, **kw):
""" """
...@@ -643,15 +660,13 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -643,15 +660,13 @@ class TestPackingListMixin(TestOrderMixin):
""" """
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
self._solveDeliveryGroupDivergence(packing_list, 'start_date', self._solveDeliveryGroupDivergence(packing_list, 'start_date',
packing_list.getRelativeUrl()) 'Unify Solver', value=packing_list.getStartDate())
def stepUnifyStopDateWithDecision(self,sequence=None, sequence_list=None, **kw): def stepUnifyStopDateWithDecision(self,sequence=None, sequence_list=None, **kw):
""" """
Solve divergence on stop date using unify Solve divergence on stop date using unify
""" """
packing_list = sequence.get('packing_list') raise NotImplementedError
self._solveDeliveryGroupDivergence(packing_list, 'stop_date',
packing_list.getRelativeUrl())
def stepUnifyStartDateWithPrevision(self,sequence=None, sequence_list=None, **kw): def stepUnifyStartDateWithPrevision(self,sequence=None, sequence_list=None, **kw):
""" """
...@@ -661,58 +676,55 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -661,58 +676,55 @@ class TestPackingListMixin(TestOrderMixin):
applied_rule = sequence.get('applied_rule') applied_rule = sequence.get('applied_rule')
simulation_movement_list = applied_rule.objectValues() simulation_movement_list = applied_rule.objectValues()
self._solveDeliveryGroupDivergence(packing_list, 'start_date', self._solveDeliveryGroupDivergence(packing_list, 'start_date',
simulation_movement_list[-1].getRelativeUrl()) 'Unify Solver', value=simulation_movement_list[-1].getStartDate())
def stepUnifyStopDateWithPrevision(self,sequence=None, sequence_list=None, **kw): def stepUnifyStopDateWithPrevision(self,sequence=None, sequence_list=None, **kw):
""" """
Solve divergence on stop date using unify Solve divergence on stop date using unify
""" """
packing_list = sequence.get('packing_list') raise NotImplementedError
applied_rule = sequence.get('applied_rule')
simulation_movement_list = applied_rule.objectValues() def _solveDeliveryGroupDivergence(self, document, property, solver, **kw):
self._solveDeliveryGroupDivergence(packing_list, 'stop_date', solver_process_tool = self.portal.portal_solver_processes
simulation_movement_list[-1].getRelativeUrl()) solver_process = solver_process_tool.newSolverProcess(document)
for solver_decision in solver_process.contentValues():
def _solveDeliveryGroupDivergence(self, obj, property, target_url): if solver_decision.getCausalityValue().getTestedProperty() == property:
kw = {'delivery_group_listbox': # use Quantity Accept Solver.
{property:{'choice':target_url}}} solver_decision.setSolverValue(self.portal.portal_solvers[solver])
self.portal.portal_workflow.doActionFor( # configure for Accept Solver.
obj, solver_decision.updateConfiguration(tested_property_list=[property],
'solve_divergence_action',
**kw) **kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def stepAcceptDecisionResource(self,sequence=None, sequence_list=None, **kw): def stepAcceptDecisionResource(self,sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
self._solveDivergence(packing_list, 'resource', 'accept') self._solveDivergence(packing_list, 'resource', 'Accept Solver')
def stepAcceptDecisionQuantity(self,sequence=None, sequence_list=None, **kw): def stepAcceptDecisionQuantity(self,sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
self._solveDivergence(packing_list, 'quantity', 'accept') self._solveDivergence(packing_list, 'quantity', 'Accept Solver')
def stepAdoptPrevisionResource(self,sequence=None, sequence_list=None, **kw): def stepAdoptPrevisionResource(self,sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
self._solveDivergence(packing_list, 'resource', 'adopt') self._solveDivergence(packing_list, 'resource', 'Adopt Solver')
def stepAdoptPrevisionQuantity(self,sequence=None, sequence_list=None, **kw): def stepAdoptPrevisionQuantity(self,sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
self._solveDivergence(packing_list, 'quantity', 'adopt') self._solveDivergence(packing_list, 'quantity', 'Adopt Solver')
def _solveDivergence(self, obj, property, decision, group='line'): def _solveDivergence(self, document, property, solver):
""" """Solve divergence by using solver tool"""
Solve divergences for a given property by taking decision. solver_process_tool = self.portal.portal_solver_processes
FIXME: Only "line" level divergence are supported solver_process = solver_process_tool.newSolverProcess(document)
""" solver_decision, = [x for x in solver_process.contentValues()
kw = {'%s_group_listbox' % group:{}} if x.getCausalityValue().getTestedProperty() == property]
for divergence in obj.getDivergenceList(): # use Quantity Accept Solver.
if divergence.getProperty('tested_property') != property: solver_decision.setSolverValue(self.portal.portal_solvers[solver])
continue # configure for Accept Solver.
sm_url = divergence.getProperty('simulation_movement').getRelativeUrl() solver_decision.updateConfiguration(tested_property_list=[property])
kw['line_group_listbox']['%s&%s' % (sm_url, property)] = { solver_process.buildTargetSolverList()
'choice':decision} solver_process.solve()
self.portal.portal_workflow.doActionFor(
obj,
'solve_divergence_action',
**kw)
def stepCheckPackingListLineWithNewQuantityPrevision(self,sequence=None, sequence_list=None, **kw): def stepCheckPackingListLineWithNewQuantityPrevision(self,sequence=None, sequence_list=None, **kw):
""" """
...@@ -734,41 +746,27 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -734,41 +746,27 @@ class TestPackingListMixin(TestOrderMixin):
""" """
packing_list_line = sequence.get('packing_list_line') packing_list_line = sequence.get('packing_list_line')
new_resource = sequence.get('resource') new_resource = sequence.get('resource')
self.assertEquals(packing_list_line.getQuantity(), self.default_quantity) self.assertEquals(packing_list_line.getQuantity(), self.default_quantity*2)
self.assertNotEquals(packing_list_line.getResourceValue(), new_resource) self.assertEquals(packing_list_line.getResourceValue(), new_resource)
simulation_movement_list = packing_list_line.getDeliveryRelatedValueList() simulation_line_list = packing_list_line.getDeliveryRelatedValueList()
order_line_list = [x.getParentValue().getParentValue().getDelivery() \ order_line_list = sum([x.getParentValue().getParentValue().getDeliveryList()
for x in simulation_movement_list] for x in simulation_line_list], [])
self.assertEquals(sorted(packing_list_line.getCausalityList()), self.assertEquals(sorted(packing_list_line.getCausalityList()),
sorted(order_line_list)) sorted(order_line_list))
new_packing_list_line = packing_list_line.aq_parent[str(int(packing_list_line.getId())+1)]
self.assertEquals(new_packing_list_line.getQuantity(), self.default_quantity)
self.assertEquals(new_packing_list_line.getResourceValue(), new_resource)
simulation_movement_list = new_packing_list_line.getDeliveryRelatedValueList()
order_line_list = [x.getParentValue().getParentValue().getDelivery() \
for x in simulation_movement_list]
self.assertEquals(sorted(new_packing_list_line.getCausalityList()),
sorted(order_line_list))
def stepCheckPackingListLineWithSameResource(self,sequence=None, sequence_list=None, **kw): def stepCheckPackingListLineWithSameResource(self,sequence=None, sequence_list=None, **kw):
""" """
Look if the packing list has new previsions Look if the packing list has new previsions
""" """
order_line = sequence.get('order_line') old_packing_list_line = sequence.get('packing_list_line')
packing_list_line = order_line.getCausalityRelatedValue() packing_list_line = old_packing_list_line.aq_parent[str(int(old_packing_list_line.getId())-1)]
old_packing_list_line = [x for x in \
sequence.get('packing_list').objectValues() \
if x != packing_list_line][0]
resource = sequence.get('resource') resource = sequence.get('resource')
self.assertEquals(old_packing_list_line.getQuantity(), 0) for line in sequence.get('packing_list').getMovementList():
self.assertNotEquals(old_packing_list_line.getResourceValue(), resource) self.assertEquals(line.getResourceValue(), resource)
self.assertEquals(packing_list_line.getQuantity(), self.default_quantity * 2) self.assertEquals(line.getQuantity(), self.default_quantity)
self.assertEquals(packing_list_line.getResourceValue(), resource) self.assertEquals(line.getCausalityList(),
simulation_movement_list = packing_list_line.getDeliveryRelatedValueList() [x.getParentValue().getParentValue().getDelivery()
order_line_list = [x.getParentValue().getParentValue().getDelivery() \ for x in line.getDeliveryRelatedValueList()])
for x in simulation_movement_list]
self.assertEquals(sorted(packing_list_line.getCausalityList()),
sorted(order_line_list))
def stepCheckNewPackingListAfterStartDateAdopt(self,sequence=None, sequence_list=None, **kw): def stepCheckNewPackingListAfterStartDateAdopt(self,sequence=None, sequence_list=None, **kw):
""" """
...@@ -996,26 +994,26 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -996,26 +994,26 @@ class TestPackingListMixin(TestOrderMixin):
def stepCheckSimulationMovementHasRecordedQuantity(self, sequence=None, def stepCheckSimulationMovementHasRecordedQuantity(self, sequence=None,
sequence_list=None): sequence_list=None):
movement_list = sequence.get('order').objectValues( movement_list = sequence.get('packing_list').objectValues(
portal_type=self.order_line_portal_type) portal_type=self.packing_list_line_portal_type)
self._checkRecordedProperty(movement_list, 'quantity', True) self._checkRecordedProperty(movement_list, 'quantity', True)
def stepCheckSimulationMovementHasNoRecordedQuantity(self, sequence=None, def stepCheckSimulationMovementHasNoRecordedQuantity(self, sequence=None,
sequence_list=None): sequence_list=None):
movement_list = sequence.get('order').objectValues( movement_list = sequence.get('packing_list').objectValues(
portal_type=self.order_line_portal_type) portal_type=self.packing_list_line_portal_type)
self._checkRecordedProperty(movement_list, 'quantity', False) self._checkRecordedProperty(movement_list, 'quantity', False)
def stepCheckSimulationMovementHasRecordedResource(self, sequence=None, def stepCheckSimulationMovementHasRecordedResource(self, sequence=None,
sequence_list=None): sequence_list=None):
movement_list = sequence.get('order').objectValues( movement_list = sequence.get('packing_list').objectValues(
portal_type=self.order_line_portal_type) portal_type=self.packing_list_line_portal_type)
self._checkRecordedProperty(movement_list, 'resource', True) self._checkRecordedProperty(movement_list, 'resource', True)
def stepCheckSimulationMovementHasNoRecordedResource(self, sequence=None, def stepCheckSimulationMovementHasNoRecordedResource(self, sequence=None,
sequence_list=None): sequence_list=None):
movement_list = sequence.get('order').objectValues( movement_list = sequence.get('packing_list').objectValues(
portal_type=self.order_line_portal_type) portal_type=self.packing_list_line_portal_type)
self._checkRecordedProperty(movement_list, 'resource', False) self._checkRecordedProperty(movement_list, 'resource', False)
class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
...@@ -1179,6 +1177,8 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1179,6 +1177,8 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
# This test does not work as it is because of the different behaviour of
# Adopt Solver.
def test_05d_SimulationChangeResourceOnOneSimulationMovementForMergedLine(self, quiet=quiet, run=run_all_test): def test_05d_SimulationChangeResourceOnOneSimulationMovementForMergedLine(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
...@@ -1246,6 +1246,10 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1246,6 +1246,10 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
# The 3 following tests currently fail because they are making assertions on
# an applied rule which with the new simulation structure is not the same as
# in the original test packing list.
def test_06_SimulationChangeStartDate(self, quiet=quiet, run=run_all_test): def test_06_SimulationChangeStartDate(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
...@@ -1793,7 +1797,7 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase): ...@@ -1793,7 +1797,7 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase):
self.added_target_solver_list = [] self.added_target_solver_list = []
def beforeTearDown(self, quiet=1, run=1): def beforeTearDown(self, quiet=1, run=1):
self.portal.portal_rules.default_delivery_simulation_rule.default_quantity_tester.edit( self.portal.portal_rules.new_delivery_simulation_rule.quantity_tester.edit(
solver=()) solver=())
solver_process_type_info = self.portal.portal_types['Solver Process'] solver_process_type_info = self.portal.portal_types['Solver Process']
solver_process_type_info.setTypeAllowedContentTypeList(self.original_allowed_content_types) solver_process_type_info.setTypeAllowedContentTypeList(self.original_allowed_content_types)
......
...@@ -576,7 +576,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -576,7 +576,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
transaction.commit() transaction.commit()
self.tic() self.tic()
def test_01b_InvoiceModifyQuantityAndSolveDivergency(self): def test_01b_NewSimulation_InvoiceModifyQuantityAndSolveDivergency(self):
invoice = self.test_01_OrderWithSimpleTaxedAndDiscountedLines('invoice') invoice = self.test_01_OrderWithSimpleTaxedAndDiscountedLines('invoice')
for line in invoice.getMovementList(): for line in invoice.getMovementList():
......
...@@ -38,6 +38,10 @@ from Products.ERP5.tests.testTradeModelLine import * ...@@ -38,6 +38,10 @@ from Products.ERP5.tests.testTradeModelLine import *
TestTradeModelLine.trade_model_path_portal_type = None TestTradeModelLine.trade_model_path_portal_type = None
TestTradeModelLine.business_link_portal_type = None TestTradeModelLine.business_link_portal_type = None
for name in list(TestTradeModelLine.__dict__):
if '_NewSimulation_' in name:
delattr(TestTradeModelLine, name)
def createBusinessProcess(self, *args, **kw): def createBusinessProcess(self, *args, **kw):
business_process = super(TestTradeModelLine, self) \ business_process = super(TestTradeModelLine, self) \
.createBusinessProcess(*args, **kw) .createBusinessProcess(*args, **kw)
......
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