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