From 2aa5c812483296e00de21e343c8fbdb9857a9a6e Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 7 Sep 2018 17:42:39 +0200 Subject: [PATCH] [FIX] stock_landed_costs: do not prorate - Set the product A in FIFO, real-time valuation - Receive 5 units @ 2000 each - Create a landed cost of 1000, apply on the picking => the cost of A is 2200 - Sell one unit - Create another landed cost of 1000, apply on the same picking The cost of A is 2360, while one expects 2400. The value of the move after the second landed cost is computed as: value = previous value + prorata of landed cost 2 = 11000 + (1000 * 4/5) = 11800 This is not correct. The whole value of the second landed cost should be taken into account for the `value` field. The prorata is only useful for the field `remaining_value`. opw-1878229 --- addons/stock_landed_costs/models/stock_landed_cost.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock_landed_costs/models/stock_landed_cost.py b/addons/stock_landed_costs/models/stock_landed_cost.py index 6dfeb180684..c921dcdd3f3 100644 --- a/addons/stock_landed_costs/models/stock_landed_cost.py +++ b/addons/stock_landed_costs/models/stock_landed_cost.py @@ -107,9 +107,9 @@ class LandedCost(models.Model): new_landed_cost_value = line.move_id.landed_cost_value + line.additional_landed_cost line.move_id.write({ 'landed_cost_value': new_landed_cost_value, - 'value': line.move_id.value + cost_to_add, + 'value': line.move_id.value + line.additional_landed_cost, 'remaining_value': line.move_id.remaining_value + cost_to_add, - 'price_unit': (line.move_id.value + cost_to_add) / line.move_id.product_qty, + 'price_unit': (line.move_id.value + line.additional_landed_cost) / line.move_id.product_qty, }) # `remaining_qty` is negative if the move is out and delivered proudcts that were not # in stock.