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

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 e6d0b451
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
# #
############################################################################## ##############################################################################
from erp5.component.document.InvoiceTransactionSimulationRule import (InvoiceTransactionSimulationRule, from Products.ERP5.Document.InvoiceTransactionSimulationRule import \
InvoiceTransactionRuleMovementGenerator) InvoiceTransactionSimulationRule, InvoiceTransactionRuleMovementGenerator
class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleMovementGenerator): class InventoryAssetPriceAccountingRuleMovementGenerator(
InvoiceTransactionRuleMovementGenerator):
""" """
""" """
# CMF Type Definition # CMF Type Definition
...@@ -72,12 +73,10 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM ...@@ -72,12 +73,10 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM
# PATCH-BEGIN # PATCH-BEGIN
update_dict = {} update_dict = {}
if movement.getLedger() in ('stock/stock/entree', if movement.getLedger() in ('stock/stock/entree',
'stock/preparation/entree',
'stock/transit/sortie', 'stock/transit/sortie',
'stock/customs/entree'): 'stock/customs/entree'):
update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStopDate() update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStopDate()
elif movement.getLedger() in ('stock/stock/sortie', elif movement.getLedger() in ('stock/preparation/sortie',
'stock/preparation/sortie',
'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()
...@@ -116,6 +115,9 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM ...@@ -116,6 +115,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()
if not input_movement.getSourceSection():
update_property_dict['source_section'] = input_movement.getDestinationSection()
resource = input_movement.getSourceAssetPriceCurrency() resource = input_movement.getSourceAssetPriceCurrency()
if resource: if resource:
update_property_dict['resource'] = 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