From 0af21dd42840f647fb53518183ee13280a5e9d08 Mon Sep 17 00:00:00 2001 From: Bhoomi Vaishnani Date: Wed, 22 Jul 2020 15:27:29 -0400 Subject: [PATCH 1/2] [FIX] stock_landed_costs_average: Resolve Float division by zero error. --- stock_landed_costs_average/models/stock_landed_cost.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_landed_costs_average/models/stock_landed_cost.py b/stock_landed_costs_average/models/stock_landed_cost.py index 16dd31ea..09fca953 100644 --- a/stock_landed_costs_average/models/stock_landed_cost.py +++ b/stock_landed_costs_average/models/stock_landed_cost.py @@ -88,7 +88,7 @@ class LandedCost(models.Model): ('id', 'in', quant_loc_ids)]) qty_available = line.product_id.with_context(location=locations.ids).qty_available total_cost = (qty_available * line.product_id.standard_price) + cost_to_add - line.product_id.write({'standard_price': total_cost / qty_available}) + line.product_id.write({'standard_price': total_cost / qty_available if qty_available != 0 else 0}) move = move.create(move_vals) cost.write({'state': 'done', 'account_move_id': move.id}) From 7dc890e0e7dd20aeec96c08f5afdb405f67d7844 Mon Sep 17 00:00:00 2001 From: Bhoomi Vaishnani Date: Fri, 24 Jul 2020 18:15:14 -0400 Subject: [PATCH 2/2] [FIX] stock_landed_costs_average: Resolve Float division by zero error. --- stock_landed_costs_average/models/stock_landed_cost.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stock_landed_costs_average/models/stock_landed_cost.py b/stock_landed_costs_average/models/stock_landed_cost.py index 09fca953..509ae58d 100644 --- a/stock_landed_costs_average/models/stock_landed_cost.py +++ b/stock_landed_costs_average/models/stock_landed_cost.py @@ -88,7 +88,8 @@ class LandedCost(models.Model): ('id', 'in', quant_loc_ids)]) qty_available = line.product_id.with_context(location=locations.ids).qty_available total_cost = (qty_available * line.product_id.standard_price) + cost_to_add - line.product_id.write({'standard_price': total_cost / qty_available if qty_available != 0 else 0}) + if qty_available > 0: + line.product_id.write({'standard_price': total_cost / qty_available}) move = move.create(move_vals) cost.write({'state': 'done', 'account_move_id': move.id})