From d4b83fa716b82c796f92d19533252be01dba8b74 Mon Sep 17 00:00:00 2001 From: Rafael Monnerat <rafael@nexedi.com> Date: Tue, 19 Sep 2006 11:41:45 +0000 Subject: [PATCH] The invoicing rule expand was over-wrinting with old values the properties in the simulation movements. This fix one part of testInvoice, but still they fail because the floating Problem. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10150 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/InvoicingRule.py | 45 ++++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/product/ERP5/Document/InvoicingRule.py b/product/ERP5/Document/InvoicingRule.py index 33b1629849..a0cad003bf 100644 --- a/product/ERP5/Document/InvoicingRule.py +++ b/product/ERP5/Document/InvoicingRule.py @@ -138,28 +138,31 @@ class InvoicingRule(Rule): modify, remove) - add/modify/remove child movements to match prevision """ - add_list, modify_dict, \ - delete_list = self._getCompensatedMovementList(applied_rule, **kw) - - for movement_id in delete_list: - applied_rule._delObject(movement_id) + parent_movement = applied_rule.getParentValue() + if parent_movement is not None: + if not parent_movement.isFrozen(): + add_list, modify_dict, \ + delete_list = self._getCompensatedMovementList(applied_rule, **kw) + + for movement_id in delete_list: + applied_rule._delObject(movement_id) - for movement, prop_dict in modify_dict.items(): - #XXX ignore start_date and stop_date if the difference is smaller than a - # rule defined value - for prop in ('start_date', 'stop_date'): - if prop in prop_dict.keys(): - prop_dict.pop(prop) - applied_rule[movement].edit(**prop_dict) - - for movement_dict in add_list: - if 'id' in movement_dict.keys(): - mvmt_id = applied_rule._get_id(movement_dict.pop('id')) - new_mvmt = applied_rule.newContent(id=mvmt_id, - portal_type=self.movement_type) - else: - new_mvmt = applied_rule.newContent(portal_type=self.movement_type) - new_mvmt.edit(**movement_dict) + for movement, prop_dict in modify_dict.items(): + #XXX ignore start_date and stop_date if the difference is smaller than a + # rule defined value + for prop in ('start_date', 'stop_date'): + if prop in prop_dict.keys(): + prop_dict.pop(prop) + applied_rule[movement].edit(**prop_dict) + + for movement_dict in add_list: + if 'id' in movement_dict.keys(): + mvmt_id = applied_rule._get_id(movement_dict.pop('id')) + new_mvmt = applied_rule.newContent(id=mvmt_id, + portal_type=self.movement_type) + else: + new_mvmt = applied_rule.newContent(portal_type=self.movement_type) + new_mvmt.edit(**movement_dict) # Pass to base class Rule.expand(self, applied_rule, force=force, **kw) -- 2.30.9