From 3418c91f13b9c3f56b7a63e1e22a544a494dc072 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 7 Jul 2017 14:37:01 +0200 Subject: [PATCH] [FIX] product: fallback in category_all does not exists self.enf.ref returns None if the record is not found. Introduced at af11e74c opw-751602 --- addons/product/models/product_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index d38774a6a1a..d56aef35cfa 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -20,7 +20,7 @@ class ProductTemplate(models.Model): if self._context.get('categ_id') or self._context.get('default_categ_id'): return self._context.get('categ_id') or self._context.get('default_categ_id') category = self.env.ref('product.product_category_all', raise_if_not_found=False) - return category.id if category.type == 'normal' else False + return category and category.type == 'normal' and category.id or False def _get_default_uom_id(self): return self.env["product.uom"].search([], limit=1, order='id').id