Commit 4843f36e authored by Julien Muchembled's avatar Julien Muchembled Committed by Cédric Le Ninivin

Do not hardcode computation of start/stop dates

Let's use reference_date_method_id on Trade Model Paths.
parent 73cde008
...@@ -34,36 +34,6 @@ class InventoryAssetPriceAccountingRuleMovementGenerator( ...@@ -34,36 +34,6 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(
""" """
""" """
def _updateGeneratedMovementList(self, input_movement, generated_movement_list):
"""Support Transit use case
"""
generated_movement_list = super(
InventoryAssetPriceAccountingRuleMovementGenerator,
self,
)._updateGeneratedMovementList(
input_movement,
generated_movement_list,
)
for movement in generated_movement_list:
update_dict = {}
if movement.getLedger() in ('stock/stock/entree',
'stock/transit/sortie',
'stock/customs/entree'):
update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStopDate()
elif movement.getLedger() in ('stock/preparation/sortie',
'stock/transit/entree'):
update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStartDate()
movement._edit(**update_dict)
input_movement.log("%r (input_movement=%r): ledger=%r, start_date=%r, stop_date=%r" %
(movement,
input_movement,
movement.getLedger(),
movement.getStartDate(),
movement.getStopDate()))
return generated_movement_list
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()
...@@ -72,8 +42,6 @@ class InventoryAssetPriceAccountingRuleMovementGenerator( ...@@ -72,8 +42,6 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(
if base_price is None: if base_price is None:
return [] return []
quantity = simulation_movement.getCorrectedQuantity() * base_price quantity = simulation_movement.getCorrectedQuantity() * base_price
if quantity is None:
return []
return [simulation_movement.asContext(quantity=quantity)] return [simulation_movement.asContext(quantity=quantity)]
...@@ -82,10 +50,9 @@ class InventoryAssetPriceAccountingRuleMovementGenerator( ...@@ -82,10 +50,9 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(
self, self,
input_movement) input_movement)
if input_movement.getRootAppliedRule().getCausalityValue().getPortalType().startswith('Purchase'): order = input_movement.getRootAppliedRule().getCausalityValue()
update_property_dict['source_section'] = input_movement.getDestinationSection() if (order.getPortalType().startswith('Purchase')
or not input_movement.getSourceSection()):
if not input_movement.getSourceSection():
update_property_dict['source_section'] = input_movement.getDestinationSection() update_property_dict['source_section'] = input_movement.getDestinationSection()
resource = input_movement.getSourceAssetPriceCurrency() resource = input_movement.getSourceAssetPriceCurrency()
......
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