[FIX] stock_landed_costs_average: Resolve Float division by zero error.

This commit is contained in:
Bhoomi Vaishnani
2020-07-24 18:15:14 -04:00
parent 0af21dd428
commit 7dc890e0e7

View File

@@ -88,7 +88,8 @@ class LandedCost(models.Model):
('id', 'in', quant_loc_ids)]) ('id', 'in', quant_loc_ids)])
qty_available = line.product_id.with_context(location=locations.ids).qty_available qty_available = line.product_id.with_context(location=locations.ids).qty_available
total_cost = (qty_available * line.product_id.standard_price) + cost_to_add 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) move = move.create(move_vals)
cost.write({'state': 'done', 'account_move_id': move.id}) cost.write({'state': 'done', 'account_move_id': move.id})