diff --git a/addons/uom/models/uom_uom.py b/addons/uom/models/uom_uom.py index f98b0dc67bb..04368b3624c 100644 --- a/addons/uom/models/uom_uom.py +++ b/addons/uom/models/uom_uom.py @@ -83,9 +83,8 @@ class UoM(models.Model): self._cr.execute(""" SELECT C.id AS category_id, count(U.id) AS uom_count FROM uom_category C - LEFT JOIN uom_uom U ON C.id = U.category_id AND uom_type = 'reference' + LEFT JOIN uom_uom U ON C.id = U.category_id AND uom_type = 'reference' AND U.active = 't' WHERE C.id IN %s - AND U.active = 't' GROUP BY C.id """, (tuple(category_ids),)) for uom_data in self._cr.dictfetchall(): diff --git a/addons/uom/tests/test_uom.py b/addons/uom/tests/test_uom.py index 66207639f77..c6fe98dd81e 100644 --- a/addons/uom/tests/test_uom.py +++ b/addons/uom/tests/test_uom.py @@ -68,6 +68,16 @@ class TestUom(TransactionCase): 'name': 'Custom UoM category', }) + # at first we can not create a non reference in custom category + with self.assertRaises(ValidationError): + self.env['uom.uom'].create({ + 'name': 'Bigger UoM of my category', + 'factor_inv': 42, + 'uom_type': 'bigger', + 'rounding': 0.5, + 'category_id': category.id + }) + # create the reference self.env['uom.uom'].create({ 'name': 'Reference UoM of my category',