From 40e9b7563f1d243c42ba0106b9fa495a046bce90 Mon Sep 17 00:00:00 2001 From: Alex Comba Date: Tue, 11 Apr 2017 16:37:46 +0200 Subject: [PATCH] [FIX] product: prevent ValueError when computing quantity on a void recordset Invoice lines do not necessarily have a product and therefore an UoM set on them. You could then compute quantityes on a void recordset. In that case we just return the quantity untouched. This is actually the old behavior of compute_quantity that is set back. See https://github.com/odoo/odoo/blob/01279359b9e5340d5ecb15f0fee186f039356374/addons/product/product.py#L164 . Closes #16377 --- addons/product/models/product_uom.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/product/models/product_uom.py b/addons/product/models/product_uom.py index 23acd5a5294..d4a5cd422f0 100644 --- a/addons/product/models/product_uom.py +++ b/addons/product/models/product_uom.py @@ -90,6 +90,8 @@ class ProductUoM(models.Model): @api.multi def _compute_quantity(self, qty, to_unit, round=True, rounding_method='UP'): + if not self: + return qty self.ensure_one() if self.category_id.id != to_unit.category_id.id: if self._context.get('raise-exception', True):