Commit e8524a08 authored by Sebastien Robin's avatar Sebastien Robin

simulation: remove concept of mirror movement (continue)

Remove broken concept of Mapping Properties that was used on legacy
simulation. We do not want to use this concept any more, any mapping
should be done by rule themself. Removing mapping properties leads
to more generic concepts and much simpler code.

With legacy simulation, in case of returned sale packing list
(in case we want to invoice in same sale invoice usual sale packing
list and returned sale packing list) :
AR (delivering_rule):
  -> SM (source/A, destination/B)
    -> AR (invoicing_rule, having mapped_property mapping
           source to destination and vice versa)
      -> SM (source/A, destination/B) builders and solvers
         where doing sm.getMappedProperty('source') which was equivalent
         to sm.getProperty('destination'), thus the mapping was done
         in live time

Now in such case, we should implement mapping directly at rule level,
and this should give:
AR (delivering_rule):
  -> SM (source/A, destination/B)
    -> AR (invoicing_rule, reversing source and destination)
      -> SM (source/B, destination/A) here we directly have properties
         we wish, no need of hacks on builders and solvers
parent f915a2e0
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
<item>Category Membership Divergence Tester</item> <item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item> <item>DateTime Divergence Tester</item>
<item>Float Divergence Tester</item> <item>Float Divergence Tester</item>
<item>Mapped Property</item>
<item>Net Converted Quantity Divergence Tester</item> <item>Net Converted Quantity Divergence Tester</item>
<item>Predicate</item> <item>Predicate</item>
<item>Specialise Divergence Tester</item> <item>Specialise Divergence Tester</item>
......
...@@ -27,7 +27,6 @@ Organisation | Cash Register ...@@ -27,7 +27,6 @@ Organisation | Cash Register
Payment Simulation Rule | Category Membership Divergence Tester Payment Simulation Rule | Category Membership Divergence Tester
Payment Simulation Rule | DateTime Divergence Tester Payment Simulation Rule | DateTime Divergence Tester
Payment Simulation Rule | Float Divergence Tester Payment Simulation Rule | Float Divergence Tester
Payment Simulation Rule | Mapped Property
Payment Simulation Rule | Net Converted Quantity Divergence Tester Payment Simulation Rule | Net Converted Quantity Divergence Tester
Payment Simulation Rule | Predicate Payment Simulation Rule | Predicate
Payment Simulation Rule | Specialise Divergence Tester Payment Simulation Rule | Specialise Divergence Tester
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<item>Category Membership Divergence Tester</item> <item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item> <item>DateTime Divergence Tester</item>
<item>Float Divergence Tester</item> <item>Float Divergence Tester</item>
<item>Mapped Property</item>
<item>Net Converted Quantity Divergence Tester</item> <item>Net Converted Quantity Divergence Tester</item>
<item>Specialise Divergence Tester</item> <item>Specialise Divergence Tester</item>
<item>String Divergence Tester</item> <item>String Divergence Tester</item>
...@@ -17,7 +16,6 @@ ...@@ -17,7 +16,6 @@
<item>Category Membership Divergence Tester</item> <item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item> <item>DateTime Divergence Tester</item>
<item>Float Divergence Tester</item> <item>Float Divergence Tester</item>
<item>Mapped Property</item>
<item>Net Converted Quantity Divergence Tester</item> <item>Net Converted Quantity Divergence Tester</item>
<item>Predicate</item> <item>Predicate</item>
<item>Specialise Divergence Tester</item> <item>Specialise Divergence Tester</item>
...@@ -33,7 +31,6 @@ ...@@ -33,7 +31,6 @@
<item>Category Membership Divergence Tester</item> <item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item> <item>DateTime Divergence Tester</item>
<item>Float Divergence Tester</item> <item>Float Divergence Tester</item>
<item>Mapped Property</item>
<item>Net Converted Quantity Divergence Tester</item> <item>Net Converted Quantity Divergence Tester</item>
<item>Specialise Divergence Tester</item> <item>Specialise Divergence Tester</item>
<item>String Divergence Tester</item> <item>String Divergence Tester</item>
......
...@@ -3,7 +3,6 @@ Invoice Line | Invoice Line ...@@ -3,7 +3,6 @@ Invoice Line | Invoice Line
Invoice Simulation Rule | Category Membership Divergence Tester Invoice Simulation Rule | Category Membership Divergence Tester
Invoice Simulation Rule | DateTime Divergence Tester Invoice Simulation Rule | DateTime Divergence Tester
Invoice Simulation Rule | Float Divergence Tester Invoice Simulation Rule | Float Divergence Tester
Invoice Simulation Rule | Mapped Property
Invoice Simulation Rule | Net Converted Quantity Divergence Tester Invoice Simulation Rule | Net Converted Quantity Divergence Tester
Invoice Simulation Rule | Specialise Divergence Tester Invoice Simulation Rule | Specialise Divergence Tester
Invoice Simulation Rule | String Divergence Tester Invoice Simulation Rule | String Divergence Tester
...@@ -11,7 +10,6 @@ Invoice Simulation Rule | Variation Divergence Tester ...@@ -11,7 +10,6 @@ Invoice Simulation Rule | Variation Divergence Tester
Invoice Transaction Simulation Rule | Category Membership Divergence Tester Invoice Transaction Simulation Rule | Category Membership Divergence Tester
Invoice Transaction Simulation Rule | DateTime Divergence Tester Invoice Transaction Simulation Rule | DateTime Divergence Tester
Invoice Transaction Simulation Rule | Float Divergence Tester Invoice Transaction Simulation Rule | Float Divergence Tester
Invoice Transaction Simulation Rule | Mapped Property
Invoice Transaction Simulation Rule | Net Converted Quantity Divergence Tester Invoice Transaction Simulation Rule | Net Converted Quantity Divergence Tester
Invoice Transaction Simulation Rule | Predicate Invoice Transaction Simulation Rule | Predicate
Invoice Transaction Simulation Rule | Specialise Divergence Tester Invoice Transaction Simulation Rule | Specialise Divergence Tester
...@@ -23,7 +21,6 @@ Rule Tool | Trade Model Simulation Rule ...@@ -23,7 +21,6 @@ Rule Tool | Trade Model Simulation Rule
Trade Model Simulation Rule | Category Membership Divergence Tester Trade Model Simulation Rule | Category Membership Divergence Tester
Trade Model Simulation Rule | DateTime Divergence Tester Trade Model Simulation Rule | DateTime Divergence Tester
Trade Model Simulation Rule | Float Divergence Tester Trade Model Simulation Rule | Float Divergence Tester
Trade Model Simulation Rule | Mapped Property
Trade Model Simulation Rule | Net Converted Quantity Divergence Tester Trade Model Simulation Rule | Net Converted Quantity Divergence Tester
Trade Model Simulation Rule | Specialise Divergence Tester Trade Model Simulation Rule | Specialise Divergence Tester
Trade Model Simulation Rule | String Divergence Tester Trade Model Simulation Rule | String Divergence Tester
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
<item>Category Membership Divergence Tester</item> <item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item> <item>DateTime Divergence Tester</item>
<item>Float Divergence Tester</item> <item>Float Divergence Tester</item>
<item>Mapped Property</item>
<item>Net Converted Quantity Divergence Tester</item> <item>Net Converted Quantity Divergence Tester</item>
<item>Specialise Divergence Tester</item> <item>Specialise Divergence Tester</item>
<item>String Divergence Tester</item> <item>String Divergence Tester</item>
...@@ -45,7 +44,6 @@ ...@@ -45,7 +44,6 @@
<item>Category Membership Divergence Tester</item> <item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item> <item>DateTime Divergence Tester</item>
<item>Float Divergence Tester</item> <item>Float Divergence Tester</item>
<item>Mapped Property</item>
<item>Net Converted Quantity Divergence Tester</item> <item>Net Converted Quantity Divergence Tester</item>
<item>Specialise Divergence Tester</item> <item>Specialise Divergence Tester</item>
<item>String Divergence Tester</item> <item>String Divergence Tester</item>
......
...@@ -13,7 +13,6 @@ Rule Tool | Transformation Sourcing Simulation Rule ...@@ -13,7 +13,6 @@ Rule Tool | Transformation Sourcing Simulation Rule
Transformation Simulation Rule | Category Membership Divergence Tester Transformation Simulation Rule | Category Membership Divergence Tester
Transformation Simulation Rule | DateTime Divergence Tester Transformation Simulation Rule | DateTime Divergence Tester
Transformation Simulation Rule | Float Divergence Tester Transformation Simulation Rule | Float Divergence Tester
Transformation Simulation Rule | Mapped Property
Transformation Simulation Rule | Net Converted Quantity Divergence Tester Transformation Simulation Rule | Net Converted Quantity Divergence Tester
Transformation Simulation Rule | Specialise Divergence Tester Transformation Simulation Rule | Specialise Divergence Tester
Transformation Simulation Rule | String Divergence Tester Transformation Simulation Rule | String Divergence Tester
...@@ -21,7 +20,6 @@ Transformation Simulation Rule | Variation Divergence Tester ...@@ -21,7 +20,6 @@ Transformation Simulation Rule | Variation Divergence Tester
Transformation Sourcing Simulation Rule | Category Membership Divergence Tester Transformation Sourcing Simulation Rule | Category Membership Divergence Tester
Transformation Sourcing Simulation Rule | DateTime Divergence Tester Transformation Sourcing Simulation Rule | DateTime Divergence Tester
Transformation Sourcing Simulation Rule | Float Divergence Tester Transformation Sourcing Simulation Rule | Float Divergence Tester
Transformation Sourcing Simulation Rule | Mapped Property
Transformation Sourcing Simulation Rule | Net Converted Quantity Divergence Tester Transformation Sourcing Simulation Rule | Net Converted Quantity Divergence Tester
Transformation Sourcing Simulation Rule | Specialise Divergence Tester Transformation Sourcing Simulation Rule | Specialise Divergence Tester
Transformation Sourcing Simulation Rule | String Divergence Tester Transformation Sourcing Simulation Rule | String Divergence Tester
......
...@@ -70,7 +70,6 @@ ...@@ -70,7 +70,6 @@
<value> <value>
<list> <list>
<string>listbox</string> <string>listbox</string>
<string>mapped_property_listbox</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -90,7 +89,6 @@ ...@@ -90,7 +89,6 @@
<string>listbox_divergence_provider</string> <string>listbox_divergence_provider</string>
<string>listbox_matching_provider</string> <string>listbox_matching_provider</string>
<string>listbox_updating_provider</string> <string>listbox_updating_provider</string>
<string>mapped_property_listbox_mapping_property_list</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>columns</string>
<string>portal_types</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>mapped_property_listbox</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>mapping_property_list</string>
<string>Mapped Property</string>
</tuple>
<tuple>
<string>description</string>
<string>Description</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_listbox</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value>
<list>
<tuple>
<string>Mapped Property</string>
<string>Mapped Property</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Mapped Properties</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>mapped_property_listbox_mapping_property_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_lines_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -82,5 +82,5 @@ class AcceptSolver(ConfigurablePropertySolverMixin): ...@@ -82,5 +82,5 @@ class AcceptSolver(ConfigurablePropertySolverMixin):
for property_id, value in value_dict.iteritems(): for property_id, value in value_dict.iteritems():
if not simulation_movement.isPropertyRecorded(property_id): if not simulation_movement.isPropertyRecorded(property_id):
simulation_movement.recordProperty(property_id) simulation_movement.recordProperty(property_id)
simulation_movement.setMappedProperty(property_id, value) simulation_movement.setProperty(property_id, value)
simulation_movement.expand(activate_kw=activate_kw) simulation_movement.expand(activate_kw=activate_kw)
...@@ -44,7 +44,7 @@ class CategoryMovementGroup(PropertyMovementGroup): ...@@ -44,7 +44,7 @@ class CategoryMovementGroup(PropertyMovementGroup):
def _getPropertyDict(self, movement, **kw): def _getPropertyDict(self, movement, **kw):
property_dict = {} property_dict = {}
getProperty = getattr(movement, 'getMappedProperty', movement.getProperty) getProperty = movement.getProperty
for prop in self.getTestedPropertyList(): for prop in self.getTestedPropertyList():
list_prop = prop + '_list' list_prop = prop + '_list'
property_dict[list_prop] = (list if prop == 'specialise' else property_dict[list_prop] = (list if prop == 'specialise' else
......
...@@ -98,9 +98,6 @@ class GeneratedDeliveryBuilder(BuilderMixin): ...@@ -98,9 +98,6 @@ class GeneratedDeliveryBuilder(BuilderMixin):
""" """
Initialize or update delivery movement properties. Initialize or update delivery movement properties.
""" """
if getattr(simulation_movement, 'getMappedProperty', None) is not None:
property_dict['quantity'] = simulation_movement.getMappedProperty('quantity')
else:
property_dict['quantity'] = simulation_movement.getQuantity() property_dict['quantity'] = simulation_movement.getQuantity()
property_dict['price'] = simulation_movement.getPrice() property_dict['price'] = simulation_movement.getPrice()
if update_existing_movement: if update_existing_movement:
......
...@@ -52,7 +52,7 @@ class PropertyGroupingMovementGroup(MovementGroup): ...@@ -52,7 +52,7 @@ class PropertyGroupingMovementGroup(MovementGroup):
tested_property_list = self.getTestedPropertyList() tested_property_list = self.getTestedPropertyList()
for movement in movement_list: for movement in movement_list:
key_value_list = [] key_value_list = []
getProperty = getattr(movement, 'getMappedProperty', movement.getProperty) getProperty = movement.getProperty
for prop in tested_property_list: for prop in tested_property_list:
key_value_list.append((prop, getProperty(prop))) key_value_list.append((prop, getProperty(prop)))
# key_value_list as a grouping key # key_value_list as a grouping key
......
...@@ -40,7 +40,7 @@ class PropertyMovementGroup(MovementGroup): ...@@ -40,7 +40,7 @@ class PropertyMovementGroup(MovementGroup):
def _getPropertyDict(self, movement, **kw): def _getPropertyDict(self, movement, **kw):
property_dict = {} property_dict = {}
getProperty = getattr(movement, 'getMappedProperty', movement.getProperty) getProperty = movement.getProperty
for prop in self.getTestedPropertyList(): for prop in self.getTestedPropertyList():
property_dict[prop] = getProperty(prop) property_dict[prop] = getProperty(prop)
return property_dict return property_dict
......
...@@ -314,12 +314,12 @@ class SimulatedDeliveryBuilder(BuilderMixin): ...@@ -314,12 +314,12 @@ class SimulatedDeliveryBuilder(BuilderMixin):
for s_m_list_per_movement in delivery_dict.values(): for s_m_list_per_movement in delivery_dict.values():
total_quantity = sum([quantity_dict.get(s_m, total_quantity = sum([quantity_dict.get(s_m,
s_m.getMappedProperty('quantity')) \ s_m.getProperty('quantity')) \
for s_m in s_m_list_per_movement]) for s_m in s_m_list_per_movement])
if total_quantity != 0.0: if total_quantity != 0.0:
for s_m in s_m_list_per_movement: for s_m in s_m_list_per_movement:
delivery_ratio = quantity_dict.get(s_m, delivery_ratio = quantity_dict.get(s_m,
s_m.getMappedProperty('quantity')) \ s_m.getProperty('quantity')) \
/ total_quantity / total_quantity
s_m.edit(delivery_ratio=delivery_ratio) s_m.edit(delivery_ratio=delivery_ratio)
else: else:
......
...@@ -759,34 +759,3 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): ...@@ -759,34 +759,3 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
movement -- not applicable movement -- not applicable
""" """
raise NotImplementedError raise NotImplementedError
security.declareProtected(Permissions.AccessContentsInformation,
'getMappedProperty')
def getMappedProperty(self, property):
mapping = self.getPropertyMappingValue()
if mapping is not None:
# Special case: corrected quantity is difficult to handle,
# because, if quantity is inverse in the mapping, other
# parameters, profit quantity (deprecated) and delivery error,
# must be inverse as well.
if property == 'corrected_quantity':
mapped_quantity_id = mapping.getMappedPropertyId('quantity')
quantity = mapping.getMappedProperty(self, 'quantity')
profit_quantity = self.getProfitQuantity() or 0
delivery_error = self.getDeliveryError() or 0
if mapped_quantity_id[:1] == '-':
# XXX what about if "quantity | -something_different" is
# specified?
return quantity + profit_quantity - delivery_error
else:
return quantity - profit_quantity + delivery_error
return mapping.getMappedProperty(self, property)
return self.getProperty(property)
security.declareProtected(Permissions.ModifyPortalContent,
'setMappedProperty')
def setMappedProperty(self, property, value):
mapping = self.getPropertyMappingValue()
if mapping is not None:
return mapping.setMappedProperty(self, property, value)
return self.setProperty(property, value)
...@@ -111,7 +111,7 @@ class TradeModelSolver(AcceptSolver): ...@@ -111,7 +111,7 @@ class TradeModelSolver(AcceptSolver):
for property_id, value in value_dict.iteritems(): for property_id, value in value_dict.iteritems():
if not simulation_movement.isPropertyRecorded(property_id): if not simulation_movement.isPropertyRecorded(property_id):
simulation_movement.recordProperty(property_id) simulation_movement.recordProperty(property_id)
simulation_movement.setMappedProperty(property_id, value) simulation_movement.setProperty(property_id, value)
simulation_movement.expand('immediate') simulation_movement.expand('immediate')
# Third, adopt changes on trade model related lines. # Third, adopt changes on trade model related lines.
......
...@@ -124,7 +124,7 @@ class UnifySolver(AcceptSolver): ...@@ -124,7 +124,7 @@ class UnifySolver(AcceptSolver):
simulation_movement.setDefaultActivateParameterDict(activate_kw) simulation_movement.setDefaultActivateParameterDict(activate_kw)
if not simulation_movement.isPropertyRecorded(solved_property): if not simulation_movement.isPropertyRecorded(solved_property):
simulation_movement.recordProperty(solved_property) simulation_movement.recordProperty(solved_property)
simulation_movement.setMappedProperty(solved_property, value) simulation_movement.setProperty(solved_property, value)
# XXX: would it be safe to expand by activity ? # XXX: would it be safe to expand by activity ?
simulation_movement.expand('immediate') simulation_movement.expand('immediate')
# Finish solving # Finish solving
......
...@@ -368,11 +368,11 @@ class FakeMovement: ...@@ -368,11 +368,11 @@ class FakeMovement:
""" """
total_quantity = 0 total_quantity = 0
for movement in self.__movement_list: for movement in self.__movement_list:
total_quantity += movement.getMappedProperty('quantity') total_quantity += movement.getProperty('quantity')
if total_quantity: if total_quantity:
for movement in self.__movement_list: for movement in self.__movement_list:
quantity = movement.getMappedProperty('quantity') quantity = movement.getProperty('quantity')
movement._setDeliveryRatio(quantity*float(delivery_ratio)/total_quantity) movement._setDeliveryRatio(quantity*float(delivery_ratio)/total_quantity)
else: else:
# Distribute equally ratio to all movements # Distribute equally ratio to all movements
...@@ -431,11 +431,7 @@ class FakeMovement: ...@@ -431,11 +431,7 @@ class FakeMovement:
""" """
total_quantity = 0 total_quantity = 0
for movement in self.getMovementList(): for movement in self.getMovementList():
getMappedProperty = getattr(movement, 'getMappedProperty', None)
if getMappedProperty is None:
quantity = movement.getQuantity() quantity = movement.getQuantity()
else:
quantity = getMappedProperty('quantity')
if quantity: if quantity:
total_quantity += quantity total_quantity += quantity
return total_quantity return total_quantity
...@@ -443,11 +439,7 @@ class FakeMovement: ...@@ -443,11 +439,7 @@ class FakeMovement:
def _getPriceDict(self): def _getPriceDict(self):
price_dict = {} price_dict = {}
for movement in self.getMovementList(): for movement in self.getMovementList():
getMappedProperty = getattr(movement, 'getMappedProperty', None)
if getMappedProperty is None:
quantity = movement.getQuantity() quantity = movement.getQuantity()
else:
quantity = getMappedProperty('quantity')
if quantity: if quantity:
price = movement.getPrice() or 0 price = movement.getPrice() or 0
quantity += price_dict.setdefault(price, 0) quantity += price_dict.setdefault(price, 0)
...@@ -507,12 +499,6 @@ class FakeMovement: ...@@ -507,12 +499,6 @@ class FakeMovement:
return self.__movement_list[0].getVariationCategoryList( return self.__movement_list[0].getVariationCategoryList(
omit_optional_variation=omit_optional_variation, **kw) omit_optional_variation=omit_optional_variation, **kw)
def getMappedProperty(self, property):
if property == 'quantity':
return self.getQuantity()
else:
raise NotImplementedError
def __repr__(self): def __repr__(self):
repr_str = '<%s object at 0x%x for %r' % (self.__class__.__name__, repr_str = '<%s object at 0x%x for %r' % (self.__class__.__name__,
id(self), id(self),
......
...@@ -711,9 +711,6 @@ class BuilderMixin(XMLObject, Amount, Predicate): ...@@ -711,9 +711,6 @@ class BuilderMixin(XMLObject, Amount, Predicate):
if not update_existing_movement or force_update: if not update_existing_movement or force_update:
# Now, only 1 movement is possible, so copy from this movement # Now, only 1 movement is possible, so copy from this movement
# XXX hardcoded value # XXX hardcoded value
if getattr(simulation_movement, 'getMappedProperty', None) is not None:
property_dict['quantity'] = simulation_movement.getMappedProperty('quantity')
else:
property_dict['quantity'] = simulation_movement.getQuantity() property_dict['quantity'] = simulation_movement.getQuantity()
property_dict['price'] = simulation_movement.getPrice() property_dict['price'] = simulation_movement.getPrice()
# Update properties on object (quantity, price...) # Update properties on object (quantity, price...)
......
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