From f643d90857bc9ef6f26f47b5f25871a46f6cc61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Le=20Ninivin?= <cedric.leninivin@tiolive.com> Date: Thu, 6 Dec 2018 17:20:29 +0000 Subject: [PATCH] erp5_real_time_inventory_accounting: Update Inventory Rule * Use getSourceAssetPriceCurrency * Do not expand if no SourceAssetPrice --- ...erp5.InventoryAssetPriceAccountingSimulationRule.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bt5/erp5_real_time_inventory_accounting/DocumentTemplateItem/portal_components/document.erp5.InventoryAssetPriceAccountingSimulationRule.py b/bt5/erp5_real_time_inventory_accounting/DocumentTemplateItem/portal_components/document.erp5.InventoryAssetPriceAccountingSimulationRule.py index 85bfd246bd..6bbfbdc3ee 100644 --- a/bt5/erp5_real_time_inventory_accounting/DocumentTemplateItem/portal_components/document.erp5.InventoryAssetPriceAccountingSimulationRule.py +++ b/bt5/erp5_real_time_inventory_accounting/DocumentTemplateItem/portal_components/document.erp5.InventoryAssetPriceAccountingSimulationRule.py @@ -98,11 +98,10 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM def _getInputMovementList(self, movement_list=None, rounding=False): simulation_movement = self._applied_rule.getParentValue() - # No expand if price is not set (already checked in 'Test Method ID' on the Rule). - # Price is automatically acquired from Supply if not set directly on PL Movement. + # No expand if SourceAssetPrice is not defined (already checked in 'Test Method ID' on the Rule). base_price = simulation_movement.getSourceAssetPrice() - if not base_price: - base_price = simulation_movement.getPrice(0.0) + if base_price is None: + return [] quantity = simulation_movement.getCorrectedQuantity() * base_price if quantity is None: return [] @@ -117,6 +116,9 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM if input_movement.getRootAppliedRule().getCausalityValue().getPortalType().startswith('Purchase'): update_property_dict['source_section'] = input_movement.getDestinationSection() + resource = input_movement.getSourceAssetPriceCurrency() + if resource: + update_property_dict['resource'] = resource return update_property_dict class InventoryAssetPriceAccountingSimulationRule(InvoiceTransactionSimulationRule): -- 2.30.9