From 875bcb1d665238142d8360852ec443587ac0b35b Mon Sep 17 00:00:00 2001 From: "Nathan Marotte (nama)" Date: Tue, 24 Aug 2021 12:51:43 +0000 Subject: [PATCH] [FIX] stock_landed_cost : traceback division by 0 when no quantity Issue: When computing the landed cost for a transfer with quantity 0, the validation of the LC wasn't working since there was a quantity 0 Steps to reproduce : 1) Create a PO for some items 2) Confirm, validate the delivery 3) Edit and unlock the delivery, set one quantity to 0, save 4) Create a landed cost for that transfer 5) Compute it 6) Validate -> Traceback Why is that a bug: There should not be a traceback, this is caused by trying to validate a landed cost for a product where there is no quantity, if there is no quantity, it should be part of the landed cost computation opw-2599799 closes odoo/odoo#75565 X-original-commit: 800433bde03a36ead40a78bc6d53cbb95c24f97b Signed-off-by: Arnold Moyaux Signed-off-by: Nathan Marotte --- addons/stock_landed_costs/models/stock_landed_cost.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_landed_costs/models/stock_landed_cost.py b/addons/stock_landed_costs/models/stock_landed_cost.py index 06e1437253a..563b8cf0239 100644 --- a/addons/stock_landed_costs/models/stock_landed_cost.py +++ b/addons/stock_landed_costs/models/stock_landed_cost.py @@ -184,7 +184,7 @@ class StockLandedCost(models.Model): for move in self._get_targeted_move_ids(): # it doesn't make sense to make a landed cost for a product that isn't set as being valuated in real time at real cost - if move.product_id.valuation != 'real_time' or move.product_id.cost_method not in ('fifo', 'average') or move.state == 'cancel': + if move.product_id.valuation != 'real_time' or move.product_id.cost_method not in ('fifo', 'average') or move.state == 'cancel' or not move.product_qty: continue vals = { 'product_id': move.product_id.id,