Commit d56e89ac authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

copy properties and categories as they are instead of depending on expandable...

copy properties and categories as they are instead of depending on expandable property list specified in rule, so as to work for complicated rules.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35773 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d7267ffd
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
from CopyToTarget import CopyToTarget from CopyToTarget import CopyToTarget
from Acquisition import aq_base from Acquisition import aq_base
...@@ -51,34 +52,6 @@ class SplitAndDefer(CopyToTarget): ...@@ -51,34 +52,6 @@ class SplitAndDefer(CopyToTarget):
new_movement_quantity = delivery_quantity * simulation_movement.getDeliveryRatio() new_movement_quantity = delivery_quantity * simulation_movement.getDeliveryRatio()
applied_rule = simulation_movement.getParentValue() applied_rule = simulation_movement.getParentValue()
rule = applied_rule.getSpecialiseValue() rule = applied_rule.getSpecialiseValue()
expandable_property_list = []
if getattr(rule, 'getExpandablePropertyList', None) is not None:
expandable_property_list = rule.getExpandablePropertyList()
if len(expandable_property_list) == 0:
# hardcoded default for compatibility
expandable_property_list = (
'base_application_list',
'base_contribution_list',
'description',
'destination',
'destination_account',
'destination_function',
'destination_section',
'efficiency',
'price',
'price_currency',
'quantity_unit',
'resource',
'source',
'source_account',
'source_function',
'source_section',
'start_date',
'stop_date',
'variation_category_list',
'variation_property_dict',
)
if movement_quantity > new_movement_quantity: if movement_quantity > new_movement_quantity:
split_index = 0 split_index = 0
...@@ -87,22 +60,16 @@ class SplitAndDefer(CopyToTarget): ...@@ -87,22 +60,16 @@ class SplitAndDefer(CopyToTarget):
split_index += 1 split_index += 1
new_id = "%s_split_%s" % (simulation_movement.getId(), split_index) new_id = "%s_split_%s" % (simulation_movement.getId(), split_index)
# Adopt different dates for deferred movements # Adopt different dates for deferred movements
movement_dict = {} movement_dict = _getPropertyAndCategoryList(simulation_movement)
# new properties # new properties
movement_dict.update( movement_dict.update(
portal_type="Simulation Movement", portal_type="Simulation Movement",
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. delivery=None,
order=simulation_movement.getOrder(),
**self.additional_parameters **self.additional_parameters
) )
for prop in expandable_property_list:
if prop not in movement_dict: # XXX: better way to filter out
movement_dict.update(**{
prop: simulation_movement.getProperty(prop)})
new_movement = applied_rule.newContent(**movement_dict) new_movement = applied_rule.newContent(**movement_dict)
start_date = getattr(self, 'start_date', None) start_date = getattr(self, 'start_date', None)
if start_date is not None: if start_date is not None:
......
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