From bd025cda6a114de1293b583ef0a9fac88ff145b9 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 20 Apr 2016 10:54:08 +0200 Subject: [PATCH] [FIX] stock_landed_costs: former_cost_per_unit precision The precision of `former_cost_per_unit` should not be set. Indeed, a stock move can contain several quants with different unit prices. Therefore, we should not round the field when stored, otherwise the difference per unit will not be calculated correctly. This is a workaround since we cannot change the DB structure in stable. opw-675222 --- addons/stock_landed_costs/stock_landed_costs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock_landed_costs/stock_landed_costs.py b/addons/stock_landed_costs/stock_landed_costs.py index 85aff2b21ac..0401cbcb83f 100644 --- a/addons/stock_landed_costs/stock_landed_costs.py +++ b/addons/stock_landed_costs/stock_landed_costs.py @@ -230,7 +230,8 @@ class stock_landed_cost(osv.osv): if not line.move_id: continue per_unit = line.final_cost / line.quantity - diff = per_unit - line.former_cost_per_unit + # FORWARDPORT UP TO SAAS-10 + diff = per_unit - (line.former_cost / line.quantity if line.quantity else 1.0) quants = [quant for quant in line.move_id.quant_ids] quant_dict = {} for quant in quants: