diff --git a/product/ERP5/Document/Amount.py b/product/ERP5/Document/Amount.py index 17debe476a2de80bd3e9ecc7f5183ba0d4a30d3a..681214e5eeb7c9186774cf167bf3c9ff69fd6b98 100644 --- a/product/ERP5/Document/Amount.py +++ b/product/ERP5/Document/Amount.py @@ -67,6 +67,7 @@ class Amount(Base, Variated): , PropertySheet.SimpleItem , PropertySheet.Amount , PropertySheet.Price + , PropertySheet.Reference ) # A few more mix-in methods which should be relocated diff --git a/product/ERP5/Document/BusinessProcess.py b/product/ERP5/Document/BusinessProcess.py index fe491e6f26d6ff2bab93063862b2940d8360698d..edecf988146d0975cb6b60d5f32c2e50cde2b989 100644 --- a/product/ERP5/Document/BusinessProcess.py +++ b/product/ERP5/Document/BusinessProcess.py @@ -711,9 +711,11 @@ class BusinessProcess(Path, XMLObject): pass kw.update(update_property_dict) movement._edit(**kw) - business_link = self.getBusinessLinkValueList(trade_phase=trade_phase, context=movement) - business_link = map(lambda x: x.getRelativeUrl(), business_link) - movement._setCausalityList(business_link + movement.getCausalityList()) + business_link = self.getBusinessLinkValueList(trade_phase=trade_phase, + context=movement) + business_link = [x.getRelativeUrl() for x in business_link] + movement._setCausalityList(business_link + + movement.getCausalityList() + amount.getCausalityList()) result.append(movement) # result can not be empty diff --git a/product/ERP5/Document/Movement.py b/product/ERP5/Document/Movement.py index 523719e3fd3863b68ef7a2543d50983f0e0d10c4..7a19bf55955fa359465ac30111e77c1e5e36bbd4 100644 --- a/product/ERP5/Document/Movement.py +++ b/product/ERP5/Document/Movement.py @@ -196,6 +196,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin): , PropertySheet.SimpleItem , PropertySheet.CategoryCore , PropertySheet.Amount + , PropertySheet.Reference , PropertySheet.Task , PropertySheet.Arrow , PropertySheet.Movement diff --git a/product/ERP5/mixin/amount_generator.py b/product/ERP5/mixin/amount_generator.py index 9b0f6b5e3cc5fb723ebf03fa341f1564754544e7..76bfd82d6ab5dfcdea10badfc718c679241093b2 100644 --- a/product/ERP5/mixin/amount_generator.py +++ b/product/ERP5/mixin/amount_generator.py @@ -220,13 +220,8 @@ class AmountGeneratorMixin: property_dict.setdefault('base_application_set', set()).add(base_application) #property_dict['trade_phase_list'] = amount_generator_cell.getTradePhaseList() # Required moved to MappedValue - property_dict['reference'] = (amount_generator_cell.getReference() - or self.getReference()) # XXX - property_dict['id'] = amount_generator_cell.getRelativeUrl().replace('/', '_') - property_dict['title'] = self.getTitle() - property_dict['int_index'] = self.getIntIndex() - property_dict['description'] = self.getDescription() - + property_dict.setdefault('causality_value_list', + []).append(amount_generator_cell) # Case 2: the cell defines a temporary calculation line if base_contribution_list: # Define a key in order to aggregate amounts in cells @@ -254,6 +249,7 @@ class AmountGeneratorMixin: # base_contribution_list MUST be defined property_dict['base_contribution_list'] = base_contribution_list for property_dict in resource_amount_aggregate.itervalues(): + causality_value_list = property_dict.pop('causality_value_list') base_application_set = property_dict['base_application_set'] # property_dict should include # resource - VAT service or a Component in MRP @@ -283,9 +279,19 @@ class AmountGeneratorMixin: continue # Create an Amount object # XXX-JPS Could we use a movement for safety ? - amount = newTempAmount(portal, property_dict.pop('id')) + amount = newTempAmount(portal, + # we only want the id to be unique + causality_value_list[0].getRelativeUrl().replace('/', '_')) amount._setCategoryList(property_dict.pop('category_list', ())) - amount._edit(**property_dict) + amount._edit( + # XXX If they are several cells, we may have duplicate references. + reference=self.getReference(), + # XXX Are title, int_index and description useful ?? + title=self.getTitle(), + int_index=self.getIntIndex(), + description=self.getDescription(), + **property_dict) + amount._setValueList('causality', causality_value_list) if rounding: # We hope here that rounding is sufficient at line level amount = getRoundingProxy(amount, context=self) @@ -357,7 +363,7 @@ class AmountGeneratorMixin: result_list = [] for amount in generated_amount_list: key = (amount.getPrice(), amount.getEfficiency(), - amount.reference, amount.categories) + amount.getReference(), amount.categories) aggregated_amount = aggregated_amount_dict.get(key) if aggregated_amount is None: aggregated_amount_dict[key] = amount