Commit a0cd984f authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Klaus Wölfel

erp5_real_time_inventory_accounting: Update Inventory Rule

* Use getSourceAssetPriceCurrency
* Do not expand if no SourceAssetPrice
parent 8445ee04
......@@ -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):
......
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