From 11c73cd0aa2ff9cbfde8e5eebf3f22dfa1c805f1 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Mon, 8 Jan 2018 18:18:59 -0800 Subject: [PATCH] [FIX] stock_landed_cost: round former_cost of valuations for total_cost When computing the total_cost of a landed cost make sure to round the individual costs of the valuation lines the same way as done by the ORM (i.e. with the 'Product price' precision). Otherwise the sum of the additional costs on the valuation lines will not equal the price of the cost lines. This is wrong and leads to errors during validation. opw-804396 --- addons/stock_landed_costs/stock_landed_costs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/stock_landed_costs/stock_landed_costs.py b/addons/stock_landed_costs/stock_landed_costs.py index 6c0423d7e38..3c0dfbc06e7 100644 --- a/addons/stock_landed_costs/stock_landed_costs.py +++ b/addons/stock_landed_costs/stock_landed_costs.py @@ -288,9 +288,13 @@ class stock_landed_cost(osv.osv): v.update({'cost_id': cost.id, 'cost_line_id': line.id}) self.pool.get('stock.valuation.adjustment.lines').create(cr, uid, v, context=context) total_qty += v.get('quantity', 0.0) - total_cost += v.get('former_cost', 0.0) total_weight += v.get('weight', 0.0) total_volume += v.get('volume', 0.0) + + former_cost = v.get('former_cost', 0.0) + # round this because former_cost on the valuation lines is also rounded + total_cost += float_round(former_cost, precision_digits=digits[1]) if digits else former_cost + total_line += 1 for line in cost.cost_lines: