Commit 56c9c687 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Cédric Le Ninivin

erp5_base: BuilderMixin Batch Order Quantity can't be redefined locally

* Also move the variable definition before they are used.
parent 2b1aeea3
......@@ -417,6 +417,12 @@ class BuilderMixin(XMLObject, Amount, Predicate):
next_start_date=date.earliestTime(),
factor=-1)).earliestTime()
# Consider min stock and min flow are always 0 on supplier supply
original_min_stock_value = 0 #supply.getMinOrderQuantity() / default_quantity_unit_flow_quantity_unit_conversion_ratio
original_factor = 0 #supply.getMinFlow()
original_order_quantity_unit_value = supply.getOrderQuantityUnitValue()
original_batch_order_quantity = supply.getBatchOrderQuantity()
# Function to define the minimal quantity to be ordered
def minimalQuantity(selected_supply,default_supply, quantity, date):
# Initiate variables to match original script from Yusei T.
......@@ -425,12 +431,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
local_min_delay_second, local_max_delay_second, local_min_order_delay_second, local_max_order_delay_second = getMinMaxDelayAndOrderDelay(selected_supply, default_supply)
local_order_quantity_unit_default_quantity_unit_conversion_ratio = getOrderQuantityUnitDefaultQuantityUnitConversionRatio(selected_supply, default_supply)
local_order_quantity_unit_value = getCorrectSupplyParameter(selected_supply, default_supply, 'getOrderQuantityUnitValue')
local_batch_order_quantity = getCorrectSupplyParameter(selected_supply, default_supply, 'getBatchOrderQuantity')
else:
local_min_delay_second, local_max_delay_second, local_min_order_delay_second, local_max_order_delay_second = min_delay_second, max_delay_second, min_order_delay_second, max_order_delay_second
local_order_quantity_unit_default_quantity_unit_conversion_ratio = order_quantity_unit_default_quantity_unit_conversion_ratio
local_order_quantity_unit_value = original_order_quantity_unit_value
local_batch_order_quantity = original_batch_order_quantity
delay_second = local_max_delay_second or local_min_delay_second or 0
limit_date = getPreviousValidDate(date)
start_date = getPreviousValidDate(
......@@ -441,7 +445,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
order_delay_second = local_max_order_delay_second or local_min_order_delay_second or 0
effective_date = addToDate(start_date, second=-order_delay_second)
order_quantity = ceil(quantity / local_order_quantity_unit_default_quantity_unit_conversion_ratio)
order_quantity = ceil(order_quantity / local_batch_order_quantity) * local_batch_order_quantity
order_quantity = ceil(order_quantity / original_batch_order_quantity) * original_batch_order_quantity
quantity = order_quantity * local_order_quantity_unit_default_quantity_unit_conversion_ratio
return order_quantity, local_order_quantity_unit_value, effective_date, start_date, stop_date, quantity
......@@ -565,11 +569,6 @@ class BuilderMixin(XMLObject, Amount, Predicate):
if len(stock_definition_supply_list):
return stock_definition_supply_list[0]
return default_supply
# Consider min stock and min flow are always 0 on supplier supply
original_min_stock_value = 0 #supply.getMinOrderQuantity() / default_quantity_unit_flow_quantity_unit_conversion_ratio
original_factor = 0 #supply.getMinFlow()
original_order_quantity_unit_value = supply.getOrderQuantityUnitValue()
original_batch_order_quantity = supply.getBatchOrderQuantity()
# Create a movement per period
next_next_period_start_date = None
for period_start_date in limit_date_list:
......
......@@ -50,13 +50,12 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:496, 0: Bad indentation. Found 9 spaces, expected 8 (bad-indentation)</string>
<string>W:447, 14: Unused variable \'inventory\' (unused-variable)</string>
<string>W:447, 35: Unused variable \'portal_type\' (unused-variable)</string>
<string>W:328, 4: Unused variable \'max_order_in_default_quantity_unit\' (unused-variable)</string>
<string>W:447, 8: Unused variable \'date\' (unused-variable)</string>
<string>W:327, 4: Unused variable \'min_order_in_default_quantity_unit\' (unused-variable)</string>
<string>W:506, 18: Unused variable \'total_inventory\' (unused-variable)</string>
<string>W:638, 0: Bad indentation. Found 9 spaces, expected 8 (bad-indentation)</string>
<string>W:421, 4: Unused variable \'original_min_stock_value\' (unused-variable)</string>
<string>W:422, 4: Unused variable \'original_factor\' (unused-variable)</string>
<string>W:520, 14: Unused variable \'inventory\' (unused-variable)</string>
<string>W:520, 35: Unused variable \'portal_type\' (unused-variable)</string>
<string>W:648, 18: Unused variable \'total_inventory\' (unused-variable)</string>
</tuple>
</value>
</item>
......
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