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

erp5_real_time_inventory_accounting: Use source asset Price to get Price

parent 9c34fc19
...@@ -81,13 +81,7 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM ...@@ -81,13 +81,7 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM
'stock/transit/entree'): 'stock/transit/entree'):
update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStartDate() update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStartDate()
if input_movement.getRootAppliedRule().getCausalityValue().getPortalType().startswith('Sale'): movement._edit(**update_dict)
sign = lambda x: (1, -1)[x < 0]
update_dict['quantity'] = input_movement.getResourceValue().Resource_getPriceCalculationOperandDict(
movement=input_movement,
use_internal_supply=True,
)['price'] * sign(movement.getQuantity())
movement._edit(**update_dict)
input_movement.log("%r (input_movement=%r): ledger=%r, start_date=%r, stop_date=%r" % input_movement.log("%r (input_movement=%r): ledger=%r, start_date=%r, stop_date=%r" %
(movement, (movement,
...@@ -106,7 +100,10 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM ...@@ -106,7 +100,10 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM
# No expand if price is not set (already checked in 'Test Method ID' on the Rule). # 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. # Price is automatically acquired from Supply if not set directly on PL Movement.
quantity = simulation_movement.getPrice() base_price = simulation_movement.getSourceAssetPrice()
if not base_price:
base_price = simulation_movement.getPrice(0.0)
quantity = simulation_movement.getCorrectedQuantity() * base_price
if quantity is None: if quantity is None:
return [] return []
......
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