Commit 73cde008 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Cédric Le Ninivin

erp5_real_time_inventory_accounting: Update Rule

* Code clean up
* Remove hardcoded ledger to pick date
* Add code to defined source section when none is defined
parent 87b77222
......@@ -26,10 +26,11 @@
#
##############################################################################
from erp5.component.document.InvoiceTransactionSimulationRule import (InvoiceTransactionSimulationRule,
InvoiceTransactionRuleMovementGenerator)
from Products.ERP5.Document.InvoiceTransactionSimulationRule import \
InvoiceTransactionSimulationRule, InvoiceTransactionRuleMovementGenerator
class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleMovementGenerator):
class InventoryAssetPriceAccountingRuleMovementGenerator(
InvoiceTransactionRuleMovementGenerator):
"""
"""
......@@ -46,12 +47,10 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM
for movement in generated_movement_list:
update_dict = {}
if movement.getLedger() in ('stock/stock/entree',
'stock/preparation/entree',
'stock/transit/sortie',
'stock/customs/entree'):
update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStopDate()
elif movement.getLedger() in ('stock/stock/sortie',
'stock/preparation/sortie',
elif movement.getLedger() in ('stock/preparation/sortie',
'stock/transit/entree'):
update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStartDate()
......@@ -86,6 +85,9 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM
if input_movement.getRootAppliedRule().getCausalityValue().getPortalType().startswith('Purchase'):
update_property_dict['source_section'] = input_movement.getDestinationSection()
if not input_movement.getSourceSection():
update_property_dict['source_section'] = input_movement.getDestinationSection()
resource = input_movement.getSourceAssetPriceCurrency()
if resource:
update_property_dict['resource'] = resource
......
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