Commit c4ad4f0a authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Your Name

erp5_real_time_inventory_accounting: Update Inventory Rule

* Use getSourceAssetPriceCurrency
* Do not expand if no SourceAssetPrice
parent f2853f89
...@@ -98,11 +98,10 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM ...@@ -98,11 +98,10 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM
def _getInputMovementList(self, movement_list=None, rounding=False): def _getInputMovementList(self, movement_list=None, rounding=False):
simulation_movement = self._applied_rule.getParentValue() simulation_movement = self._applied_rule.getParentValue()
# No expand if price is not set (already checked in 'Test Method ID' on the Rule). # No expand if SourceAssetPrice is not defined (already checked in 'Test Method ID' on the Rule).
# Price is automatically acquired from Supply if not set directly on PL Movement.
base_price = simulation_movement.getSourceAssetPrice() base_price = simulation_movement.getSourceAssetPrice()
if not base_price: if base_price is None:
base_price = simulation_movement.getPrice(0.0) return []
quantity = simulation_movement.getCorrectedQuantity() * base_price quantity = simulation_movement.getCorrectedQuantity() * base_price
if quantity is None: if quantity is None:
return [] return []
...@@ -117,6 +116,9 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM ...@@ -117,6 +116,9 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM
if input_movement.getRootAppliedRule().getCausalityValue().getPortalType().startswith('Purchase'): if input_movement.getRootAppliedRule().getCausalityValue().getPortalType().startswith('Purchase'):
update_property_dict['source_section'] = input_movement.getDestinationSection() update_property_dict['source_section'] = input_movement.getDestinationSection()
resource = input_movement.getSourceAssetPriceCurrency()
if resource:
update_property_dict['resource'] = resource
return update_property_dict return update_property_dict
class InventoryAssetPriceAccountingSimulationRule(InvoiceTransactionSimulationRule): class InventoryAssetPriceAccountingSimulationRule(InvoiceTransactionSimulationRule):
......
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