Commit d89813a7 authored by Jean-Paul Smets's avatar Jean-Paul Smets

OpenOrderRule tries to delegate if possible the implementation of expand to...

OpenOrderRule tries to delegate if possible the implementation of expand to the OpenOrderExpander (an OpenOrder or SubscriptionItem subclass) if available. This way, it is easy to encapsulate OpenOrder logic in an Item and combine many different Open Order logic in the same site without touching the code of the Open Order class. For example, Payroll simulation will be implemented by creating an EmploymentContractItem (subsclass of SubscriptionItem) for every worker's contract. The EmploymentContractItem generated in the simulation future Parysheer LInes for work which are themselves expanded using the appropriate Paysheet Model, as defined in the career. 

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26442 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 971e6270
...@@ -32,7 +32,6 @@ from Products.ERP5.Document.DeliveryRule import DeliveryRule ...@@ -32,7 +32,6 @@ from Products.ERP5.Document.DeliveryRule import DeliveryRule
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
from DateTime import DateTime from DateTime import DateTime
class OpenOrderRule(DeliveryRule): class OpenOrderRule(DeliveryRule):
""" """
Order Rule object make sure an Order in the simulation Order Rule object make sure an Order in the simulation
...@@ -73,8 +72,12 @@ class OpenOrderRule(DeliveryRule): ...@@ -73,8 +72,12 @@ class OpenOrderRule(DeliveryRule):
delivered child, and is in order, it can be modified. delivered child, and is in order, it can be modified.
Else, it cannot be modified. Else, it cannot be modified.
""" """
movement_type = 'Simulation Movement'
order = applied_rule.getDefaultCausalityValue() order = applied_rule.getDefaultCausalityValue()
if getattr(order, 'expandOpenOrderRule', None) is not None:
# Delegate implementation of expand to the SubscriptionItem or
# to the OpenOrder instance
return order.expandOpenOrderRule(applied_rule, force=force, **kw)
movement_type = 'Simulation Movement'
if order is not None: if order is not None:
order_movement_list = order.getMovementList( order_movement_list = order.getMovementList(
portal_type=order.getPortalOrderMovementTypeList()) portal_type=order.getPortalOrderMovementTypeList())
...@@ -184,4 +187,4 @@ class OpenOrderRule(DeliveryRule): ...@@ -184,4 +187,4 @@ class OpenOrderRule(DeliveryRule):
for periodicity_line in periodicity_line_list: for periodicity_line in periodicity_line_list:
result.extend(periodicity_line.getDatePeriodList(schedule_start_date, result.extend(periodicity_line.getDatePeriodList(schedule_start_date,
schedule_stop_date)) schedule_stop_date))
return result return result
\ No newline at end of file
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