From 40f3658905c4488712619d2a8ad46f17123fd601 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Thu, 20 Jun 2024 10:08:54 +0200 Subject: [PATCH] [FIX] sale_margin_analysis: Avoid ZeroDivisionError --- sale_margin_delivered/models/sale_margin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sale_margin_delivered/models/sale_margin.py b/sale_margin_delivered/models/sale_margin.py index 5eb8ce58..29682716 100644 --- a/sale_margin_delivered/models/sale_margin.py +++ b/sale_margin_delivered/models/sale_margin.py @@ -74,7 +74,11 @@ def _compute_margin_delivered(self): for line in self.filtered("qty_delivered"): # we need to compute the price reduce to avoid rounding issues # the one stored in the line is rounded to the product price precision - price_reduce_taxexcl = line.price_subtotal / line.product_uom_qty + price_reduce_taxexcl = ( + line.price_subtotal / line.product_uom_qty + if line.product_uom_qty + else 0.0 + ) if line.product_id.type != "product": currency = line.order_id.pricelist_id.currency_id