Skip to content

Commit

Permalink
[FIX] stock_landed_cost: round former_cost of valuations for total_cost
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jorenvo committed Jan 12, 2018
1 parent 26d3b77 commit 11c73cd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion addons/stock_landed_costs/stock_landed_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,13 @@ def compute_landed_cost(self, cr, uid, ids, context=None):
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:
Expand Down

0 comments on commit 11c73cd

Please sign in to comment.