Commit c07ab3f8 authored by Julien Muchembled's avatar Julien Muchembled Committed by Klaus Wölfel

Do not hardcode computation of start/stop dates

Let's use reference_date_method_id on Trade Model Paths.
parent b087bb4c
...@@ -37,63 +37,6 @@ class InventoryAssetPriceAccountingRuleMovementGenerator( ...@@ -37,63 +37,6 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(
meta_type = 'ERP5 Inventory Asset Price Accounting Simulation Rule' meta_type = 'ERP5 Inventory Asset Price Accounting Simulation Rule'
portal_type = 'Inventory Asset Price Accounting Simulation Rule' portal_type = 'Inventory Asset Price Accounting Simulation Rule'
# XXX: Copy/paste from erp5.component.mixin.RuleMixin to support Transit use case
def getGeneratedMovementList(self, movement_list=None, rounding=False):
"""
Returns a list of movements generated by that rule.
movement_list - optional IMovementList which can be passed explicitely
rounding - boolean argument, which controls if rounding shall be applied on
generated movements or not
NOTE:
- implement rounding appropriately (True or False seems
simplistic)
"""
# Default implementation below can be overriden by subclasses
# however it should be generic enough not to be overriden
# by most classes
# Results will be appended to result
result = []
# Build a list of movement and business path
input_movement_list = self._getInputMovementList(
movement_list=movement_list, rounding=rounding)
for input_movement in input_movement_list:
# Merge movement and business path properties (core implementation)
# Lookup Business Process through composition (NOT UNION)
business_process = input_movement.asComposedDocument()
explanation = self._applied_rule # We use applied rule as local explanation
trade_phase = self._getTradePhaseList(input_movement, business_process) # XXX-JPS not convenient to handle
update_property_dict = self._getUpdatePropertyDict(input_movement)
for movement in business_process.getTradePhaseMovementList(explanation, input_movement,
trade_phase=trade_phase, delay_mode=None,
update_property_dict=update_property_dict):
# PATCH-BEGIN
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()))
# PATCH-END
result.append(movement)
# And return list of generated movements
return result
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()
...@@ -102,8 +45,6 @@ class InventoryAssetPriceAccountingRuleMovementGenerator( ...@@ -102,8 +45,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)]
...@@ -112,10 +53,9 @@ class InventoryAssetPriceAccountingRuleMovementGenerator( ...@@ -112,10 +53,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