Commit f9437a32 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

to support both new and old simulation hierarchy.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32524 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bfacd806
...@@ -58,7 +58,12 @@ ...@@ -58,7 +58,12 @@
parent = movement.getParentValue()\n parent = movement.getParentValue()\n
if parent.getPortalType() == \'Applied Rule\':\n if parent.getPortalType() == \'Applied Rule\':\n
parent_rule = parent.getSpecialiseValue()\n parent_rule = parent.getSpecialiseValue()\n
if parent_rule.getPortalType() not in [\'Order Rule\', \'Delivery Rule\']:\n parent_rule_portal_type = parent_rule.getPortalType()\n
if parent_rule_portal_type not in [\'Order Rule\', \'Delivery Rule\', \'Delivering Simulation Rule\']:\n
return False\n
# XXX can we create invoicing rule for Production Order?\n
if parent_rule_portal_type in [\'Delivering Simulation Rule\',] and \\\n
parent_rule.getParentValue().getParentValue().getPortalType() not in [\'Order Simulation Rule\']:\n
return False\n return False\n
\n \n
source_section = movement.getSourceSection()\n source_section = movement.getSourceSection()\n
...@@ -110,6 +115,7 @@ return True\n ...@@ -110,6 +115,7 @@ return True\n
<string>_getattr_</string> <string>_getattr_</string>
<string>parent</string> <string>parent</string>
<string>parent_rule</string> <string>parent_rule</string>
<string>parent_rule_portal_type</string>
<string>False</string> <string>False</string>
<string>source_section</string> <string>source_section</string>
<string>destination_section</string> <string>destination_section</string>
......
330 331
\ No newline at end of file \ No newline at end of file
...@@ -209,6 +209,7 @@ class AppliedRule(XMLObject): ...@@ -209,6 +209,7 @@ class AppliedRule(XMLObject):
.getRootSpecialiseValue(portal_type_list) .getRootSpecialiseValue(portal_type_list)
if specialise_value is not None: if specialise_value is not None:
return specialise_value return specialise_value
# 'order' category is deprecated. it is kept for compatibility.
if order is not None: if order is not None:
specialise_value = order.getExplanationValue() \ specialise_value = order.getExplanationValue() \
.getRootSpecialiseValue(portal_type_list) .getRootSpecialiseValue(portal_type_list)
......
...@@ -58,11 +58,13 @@ class CausalityAssignmentMovementGroup(MovementGroup): ...@@ -58,11 +58,13 @@ class CausalityAssignmentMovementGroup(MovementGroup):
property_dict = {} property_dict = {}
parent = movement parent = movement
# Go upper into the simulation tree in order to find an order link # Go upper into the simulation tree in order to find an order link
while parent.getOrderValue() is None and not(parent.isRootAppliedRule()): while not parent.isRootAppliedRule():
parent = parent.getParentValue() parent = parent.getParentValue()
causality_list = property_dict.get('causality_list', []) causality_list = property_dict.get('causality_list', [])
for order_movement in parent.getOrderList(): # 'order' category is deprecated. it is kept for compatibility.
if order_movement not in causality_list: movement_list = parent.getOrderList() or parent.getDeliveryList()
causality_list.append(order_movement) for delivery_movement in movement_list:
if delivery_movement not in causality_list:
causality_list.append(delivery_movement)
property_dict['causality_list'] = causality_list property_dict['causality_list'] = causality_list
return property_dict return property_dict
...@@ -197,6 +197,7 @@ class DeliveryRule(Rule): ...@@ -197,6 +197,7 @@ class DeliveryRule(Rule):
def _getExpandablePropertyUpdateDict(self, applied_rule, movement, def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict): business_path, current_property_dict):
"""Delivery specific update dict""" """Delivery specific update dict"""
# 'order' category is deprecated. it is kept for compatibility.
return { return {
'order': movement.getRelativeUrl(), 'order': movement.getRelativeUrl(),
'delivery': movement.getRelativeUrl(), 'delivery': movement.getRelativeUrl(),
......
...@@ -89,6 +89,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -89,6 +89,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
delivery = simulation_movement.getDeliveryValue() delivery = simulation_movement.getDeliveryValue()
if delivery is not None: if delivery is not None:
resource = delivery.getProperty('price_currency', None) resource = delivery.getProperty('price_currency', None)
# 'order' category is deprecated. it is kept for compatibility.
if (resource is None) and \ if (resource is None) and \
(simulation_movement.getParentValue().getParentValue() \ (simulation_movement.getParentValue().getParentValue() \
== portal_simulation) : == portal_simulation) :
......
...@@ -595,6 +595,7 @@ class Movement(XMLObject, Amount): ...@@ -595,6 +595,7 @@ class Movement(XMLObject, Amount):
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'isSimulated') 'isSimulated')
def isSimulated(self): def isSimulated(self):
# 'order' category is deprecated. it is kept for compatibility.
return (len(self.getDeliveryRelatedValueList()) > 0) or\ return (len(self.getDeliveryRelatedValueList()) > 0) or\
(len(self.getOrderRelatedValueList()) > 0) (len(self.getOrderRelatedValueList()) > 0)
...@@ -605,6 +606,7 @@ class Movement(XMLObject, Amount): ...@@ -605,6 +606,7 @@ class Movement(XMLObject, Amount):
""" """
Returns the quantity of related order(s) Returns the quantity of related order(s)
""" """
# XXX deprecated
return self.getQuantity() return self.getQuantity()
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
...@@ -629,6 +631,7 @@ class Movement(XMLObject, Amount): ...@@ -629,6 +631,7 @@ class Movement(XMLObject, Amount):
""" """
Returns the list of start date of related order(s) Returns the list of start date of related order(s)
""" """
# XXX deprecated
return [self.getStartDate()] return [self.getStartDate()]
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
...@@ -653,6 +656,7 @@ class Movement(XMLObject, Amount): ...@@ -653,6 +656,7 @@ class Movement(XMLObject, Amount):
""" """
Returns the list of stop date of related order(s) Returns the list of stop date of related order(s)
""" """
# XXX deprecated
return [self.getStopDate()] return [self.getStopDate()]
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
...@@ -677,6 +681,7 @@ class Movement(XMLObject, Amount): ...@@ -677,6 +681,7 @@ class Movement(XMLObject, Amount):
""" """
Returns the source of related orders Returns the source of related orders
""" """
# XXX deprecated
return self.getSourceList() return self.getSourceList()
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
...@@ -701,6 +706,7 @@ class Movement(XMLObject, Amount): ...@@ -701,6 +706,7 @@ class Movement(XMLObject, Amount):
""" """
Returns the destination of related orders Returns the destination of related orders
""" """
# XXX deprecated
return self.getDestinationList() return self.getDestinationList()
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
...@@ -725,6 +731,7 @@ class Movement(XMLObject, Amount): ...@@ -725,6 +731,7 @@ class Movement(XMLObject, Amount):
""" """
Returns the source_section of related orders Returns the source_section of related orders
""" """
# XXX deprecated
return self.getSourceSectionList() return self.getSourceSectionList()
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
...@@ -749,6 +756,7 @@ class Movement(XMLObject, Amount): ...@@ -749,6 +756,7 @@ class Movement(XMLObject, Amount):
""" """
Returns the destination_section of related orders Returns the destination_section of related orders
""" """
# XXX deprecated
return self.getDestinationSectionList() return self.getDestinationSectionList()
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
......
...@@ -125,21 +125,28 @@ class Order(Delivery): ...@@ -125,21 +125,28 @@ class Order(Delivery):
""" """
Warning: does not work if it was not catalogued immediately Warning: does not work if it was not catalogued immediately
""" """
# 'order' category is deprecated. it is kept for compatibility.
for my_simulation_movement in self.getOrderRelatedValueList( for my_simulation_movement in self.getOrderRelatedValueList(
portal_type='Simulation Movement'): portal_type='Simulation Movement') or \
self.getDeliveryRelatedValueList(
portal_type='Simulation Movement'):
# And apply # And apply
getattr(my_simulation_movement, method_id)(**kw) getattr(my_simulation_movement, method_id)(**kw)
for m in self.contentValues(filter={'portal_type': \ for m in self.contentValues(filter={'portal_type': \
self.getPortalMovementTypeList()}): self.getPortalMovementTypeList()}):
# Find related in simulation # Find related in simulation
for my_simulation_movement in m.getOrderRelatedValueList( for my_simulation_movement in m.getOrderRelatedValueList(
portal_type='Simulation Movement'): portal_type='Simulation Movement') or \
m.getDeliveryRelatedValueList(
portal_type='Simulation Movement'):
# And apply # And apply
getattr(my_simulation_movement, method_id)(**kw) getattr(my_simulation_movement, method_id)(**kw)
for c in m.contentValues(filter={'portal_type': for c in m.contentValues(filter={'portal_type':
self.getPortalMovementTypeList()}): self.getPortalMovementTypeList()}):
for my_simulation_movement in c.getOrderRelatedValueList( for my_simulation_movement in c.getOrderRelatedValueList(
portal_type='Simulation Movement'): portal_type='Simulation Movement') or \
c.getDeliveryRelatedValueList(
portal_type='Simulation Movement'):
# And apply # And apply
getattr(my_simulation_movement, method_id)(**kw) getattr(my_simulation_movement, method_id)(**kw)
...@@ -156,14 +163,21 @@ class Order(Delivery): ...@@ -156,14 +163,21 @@ class Order(Delivery):
Returns simulation movements related to a cell or line Returns simulation movements related to a cell or line
of this order of this order
""" """
result = self.getOrderRelatedValueList(portal_type='Simulation Movement') # XXX The name should be getDeliveryRelatedMovementList, but this
# method seems to be not used at all.
result = self.getOrderRelatedValueList(
portal_type='Simulation Movement') or \
self.getDeliveryRelatedValueList(portal_type='Simulation Movement')
for m in self.contentValues(filter={'portal_type': \ for m in self.contentValues(filter={'portal_type': \
self.getPortalMovementTypeList()}): self.getPortalMovementTypeList()}):
# Find related in simulation # Find related in simulation
result += m.getOrderRelatedValueList(portal_type='Simulation Movement') result += m.getOrderRelatedValueList(
portal_type='Simulation Movement') or \
m.getDeliveryRelatedValueList(portal_type='Simulation Movement')
for c in m.contentValues(filter={'portal_type': 'Delivery Cell'}): for c in m.contentValues(filter={'portal_type': 'Delivery Cell'}):
result += c.getOrderRelatedValueList( \ result += c.getOrderRelatedValueList(
portal_type='Simulation Movement') portal_type='Simulation Movement') or \
c.getDeliveryRelatedValueList(portal_type='Simulation Movement')
return result return result
def manage_beforeDelete(self, item, container): def manage_beforeDelete(self, item, container):
......
...@@ -67,14 +67,17 @@ class OrderLine(DeliveryLine): ...@@ -67,14 +67,17 @@ class OrderLine(DeliveryLine):
""" """
Warning: does not work if it was not catalogued immediately Warning: does not work if it was not catalogued immediately
""" """
# XXX This method seems to be not used at all.
# Find related in simulation # Find related in simulation
for my_simulation_movement in self.getOrderRelatedValueList( for my_simulation_movement in self.getOrderRelatedValueList(
portal_type = 'Simulation Movement'): portal_type = 'Simulation Movement') or \
self.getDeliveryRelatedValueList(portal_type = 'Simulation Movement'):
# And apply # And apply
getattr(my_simulation_movement, method_id)() getattr(my_simulation_movement, method_id)()
for c in self.contentValues(filter={'portal_type': 'Delivery Cell'}): for c in self.contentValues(filter={'portal_type': 'Delivery Cell'}):
for my_simulation_movement in c.getOrderRelatedValueList( for my_simulation_movement in c.getOrderRelatedValueList(
portal_type = 'Simulation Movement'): portal_type = 'Simulation Movement') or \
c.getDeliveryRelatedValueList(portal_type = 'Simulation Movement'):
# And apply # And apply
getattr(my_simulation_movement, method_id)() getattr(my_simulation_movement, method_id)()
......
...@@ -65,6 +65,7 @@ class PaymentRule(Rule): ...@@ -65,6 +65,7 @@ class PaymentRule(Rule):
if payment_condition_list: if payment_condition_list:
return payment_condition_list return payment_condition_list
# 'order' category is deprecated. it is kept for compatibility.
order_movement = movement.getOrderValue() order_movement = movement.getOrderValue()
if order_movement is not None: if order_movement is not None:
explanation = order_movement.getExplanationValue() explanation = order_movement.getExplanationValue()
......
...@@ -43,7 +43,10 @@ class RequirementMovementGroup(MovementGroup): ...@@ -43,7 +43,10 @@ class RequirementMovementGroup(MovementGroup):
return True, property_dict return True, property_dict
def _getRequirementList(self, movement): def _getRequirementList(self, movement):
# 'order' category is deprecated. it is kept for compatibility.
order_value = movement.getOrderValue() order_value = movement.getOrderValue()
if order_value is None:
order_value = movement.getDeliveryValue()
requirement_list = [] requirement_list = []
if order_value is not None: if order_value is not None:
if 'Line' in order_value.getPortalType(): if 'Line' in order_value.getPortalType():
......
...@@ -165,6 +165,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin): ...@@ -165,6 +165,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
delivery = self.getDeliveryValue() delivery = self.getDeliveryValue()
if delivery is not None: if delivery is not None:
return delivery.getSimulationState() return delivery.getSimulationState()
# 'order' category is deprecated. it is kept for compatibility.
order = self.getOrderValue() order = self.getOrderValue()
if order is not None: if order is not None:
return order.getSimulationState() return order.getSimulationState()
...@@ -186,6 +187,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin): ...@@ -186,6 +187,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
delivery = self.getDeliveryValue() delivery = self.getDeliveryValue()
if delivery is not None: if delivery is not None:
return delivery.getTranslatedSimulationStateTitle() return delivery.getTranslatedSimulationStateTitle()
# 'order' category is deprecated. it is kept for compatibility.
order = self.getOrderValue() order = self.getOrderValue()
if order is not None: if order is not None:
return order.getTranslatedSimulationStateTitle() return order.getTranslatedSimulationStateTitle()
...@@ -331,16 +333,24 @@ class SimulationMovement(Movement, PropertyRecordableMixin): ...@@ -331,16 +333,24 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getOrderStartDate') 'getOrderStartDate')
def getOrderStartDate(self): def getOrderStartDate(self):
# 'order' category is deprecated. it is kept for compatibility.
order_value = self.getOrderValue() order_value = self.getOrderValue()
if order_value is not None: if order_value is not None:
return order_value.getStartDate() return order_value.getStartDate()
delivery_value = self.getDeliveryValue()
if delivery_value is not None:
return delivery_value.getStartDate()
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getOrderStopDate') 'getOrderStopDate')
def getOrderStopDate(self): def getOrderStopDate(self):
# 'order' category is deprecated. it is kept for compatibility.
order_value = self.getOrderValue() order_value = self.getOrderValue()
if order_value is not None: if order_value is not None:
return order_value.getStopDate() return order_value.getStopDate()
delivery_value = self.getDeliveryValue()
if delivery_value is not None:
return delivery_value.getStopDate()
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getDeliveryStartDateList') 'getDeliveryStartDateList')
......
...@@ -99,7 +99,10 @@ class TaxLineDeliveryMovementGroup(MovementGroup): ...@@ -99,7 +99,10 @@ class TaxLineDeliveryMovementGroup(MovementGroup):
# in case of invoice rule (ie. starting from Invoice) # in case of invoice rule (ie. starting from Invoice)
if delivery_line is None: if delivery_line is None:
# 'order' category is deprecated. it is kept for compatibility.
delivery_line = applied_rule.getParentValue().getOrderValue() delivery_line = applied_rule.getParentValue().getOrderValue()
if delivery_line is not None:
delivery_line = applied_rule.getParentValue().getDeliveryValue()
# in case of invoicing rule (ie. starting from Order) # in case of invoicing rule (ie. starting from Order)
if delivery_line is None: if delivery_line is None:
......
...@@ -145,7 +145,10 @@ class TransformationModelRuleMixin(Base): ...@@ -145,7 +145,10 @@ class TransformationModelRuleMixin(Base):
if movement is None and applied_rule is not None: if movement is None and applied_rule is not None:
movement = applied_rule.getParentValue() movement = applied_rule.getParentValue()
# 'order' category is deprecated. it is kept for compatibility.
order_movement = movement.getRootSimulationMovement().getOrderValue() order_movement = movement.getRootSimulationMovement().getOrderValue()
if order_movement is None:
order_movement = movement.getRootSimulationMovement().getDeliveryValue()
explanation = self.getExplanationValue(movement=movement, explanation = self.getExplanationValue(movement=movement,
applied_rule=applied_rule) applied_rule=applied_rule)
# find the line of order recursively # find the line of order recursively
...@@ -196,8 +199,12 @@ class TransformationModelRuleMixin(Base): ...@@ -196,8 +199,12 @@ class TransformationModelRuleMixin(Base):
if applied_rule is not None: if applied_rule is not None:
return applied_rule.getRootAppliedRule().getCausalityValue() return applied_rule.getRootAppliedRule().getCausalityValue()
else: else:
return movement.getRootSimulationMovement()\ root_simulation_movement = movement.getRootSimulationMovement()
.getOrderValue().getExplanationValue() # 'order' category is deprecated. it is kept for compatibility.
order = root_simulation_movement.getOrderValue()
if order is None:
order = root_simulation_movement.getDeliveryValue()
return order.getExplanationValue()
def getHeadProductionPathValueList(self, transformation, business_process): def getHeadProductionPathValueList(self, transformation, business_process):
""" """
......
...@@ -107,8 +107,11 @@ class TransformationSourcingRuleMixin(ExtensionClass.Base): ...@@ -107,8 +107,11 @@ class TransformationSourcingRuleMixin(ExtensionClass.Base):
""" """
Get transformation related to used by the applied rule. Get transformation related to used by the applied rule.
""" """
production_order_movement = movement.getRootSimulationMovement().\ root_simulation_movement = movement.getRootSimulationMovement()
getOrderValue() # 'order' category is deprecated. it is kept for compatibility.
production_order_movement = root_simulation_movement.getOrderValue()
if production_order_movement is None:
production_order_movement = root_simulation_movement.getDeliveryValue()
# XXX Acquisition can be use instead # XXX Acquisition can be use instead
parent_uid = production_order_movement.getParentUid() parent_uid = production_order_movement.getParentUid()
explanation_uid = production_order_movement.getExplanationUid() explanation_uid = production_order_movement.getExplanationUid()
......
...@@ -77,6 +77,7 @@ class SplitAndDefer(CopyToTarget): ...@@ -77,6 +77,7 @@ class SplitAndDefer(CopyToTarget):
id=new_id, id=new_id,
quantity=movement_quantity - new_movement_quantity, quantity=movement_quantity - new_movement_quantity,
activate_kw=self.activate_kw, activate_kw=self.activate_kw,
# 'order' category is deprecated. it is kept for compatibility.
order=simulation_movement.getOrder(), order=simulation_movement.getOrder(),
**self.additional_parameters **self.additional_parameters
) )
...@@ -110,6 +111,8 @@ class SplitAndDefer(CopyToTarget): ...@@ -110,6 +111,8 @@ class SplitAndDefer(CopyToTarget):
efficiency=simulation_movement.getEfficiency(), efficiency=simulation_movement.getEfficiency(),
start_date=simulation_movement.getStartDate(), start_date=simulation_movement.getStartDate(),
stop_date=simulation_movement.getStopDate(), stop_date=simulation_movement.getStopDate(),
# 'order' category is deprecated. it is kept for
# compatibility.
order=simulation_movement.getOrder(), order=simulation_movement.getOrder(),
resource=simulation_movement.getResource(), resource=simulation_movement.getResource(),
......
...@@ -57,6 +57,7 @@ class SplitQuantity(CopyToTarget): ...@@ -57,6 +57,7 @@ class SplitQuantity(CopyToTarget):
start_date=simulation_movement.getStartDate(), start_date=simulation_movement.getStartDate(),
stop_date=simulation_movement.getStopDate(), stop_date=simulation_movement.getStopDate(),
# XXX resource # XXX resource
# 'order' category is deprecated. it is kept for compatibility.
order = simulation_movement.getOrder(), order = simulation_movement.getOrder(),
quantity = self.quantity, quantity = self.quantity,
source = simulation_movement.getSource(), source = simulation_movement.getSource(),
......
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