From 92c4a3e89a149b41dc79f8e7bf01e82295df4882 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 10 Sep 2015 12:01:22 +0200 Subject: [PATCH] [FIX] stock_landed_costs: Former Cost The former cost of a stock.valuation.adjustment.lines line is the sum of cost * qty of each quant linked to the stock.move record linked to this line (with the field 'move_id'). opw:648922 --- addons/stock_landed_costs/stock_landed_costs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/stock_landed_costs/stock_landed_costs.py b/addons/stock_landed_costs/stock_landed_costs.py index e6ccde996b2..1dad39ef1e9 100644 --- a/addons/stock_landed_costs/stock_landed_costs.py +++ b/addons/stock_landed_costs/stock_landed_costs.py @@ -65,12 +65,11 @@ class stock_landed_cost(osv.osv): if move.product_id.valuation != 'real_time' or move.product_id.cost_method != 'real': continue total_cost = 0.0 - total_qty = move.product_qty weight = move.product_id and move.product_id.weight * move.product_qty volume = move.product_id and move.product_id.volume * move.product_qty for quant in move.quant_ids: - total_cost += quant.cost - vals = dict(product_id=move.product_id.id, move_id=move.id, quantity=move.product_uom_qty, former_cost=total_cost * total_qty, weight=weight, volume=volume) + total_cost += quant.cost * quant.qty + vals = dict(product_id=move.product_id.id, move_id=move.id, quantity=move.product_uom_qty, former_cost=total_cost, weight=weight, volume=volume) lines.append(vals) if not lines: raise osv.except_osv(_('Error!'), _('The selected picking does not contain any move that would be impacted by landed costs. Landed costs are only possible for products configured in real time valuation with real price costing method. Please make sure it is the case, or you selected the correct picking'))