diff options
| -rw-r--r-- | addons/uom/models/uom_uom.py | 1 | ||||
| -rw-r--r-- | addons/uom/tests/test_uom.py | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/addons/uom/models/uom_uom.py b/addons/uom/models/uom_uom.py index beee90fbf43..5d18143b4f3 100644 --- a/addons/uom/models/uom_uom.py +++ b/addons/uom/models/uom_uom.py @@ -79,6 +79,7 @@ class UoM(models.Model): not possible to do it in SQL directly. """ category_ids = self.mapped('category_id').ids + self.env['uom.uom'].flush(['category_id', 'uom_type', 'active']) self._cr.execute(""" SELECT C.id AS category_id, count(U.id) AS uom_count FROM uom_category C diff --git a/addons/uom/tests/test_uom.py b/addons/uom/tests/test_uom.py index 1b7dd2b1e1a..935bb6a12cb 100644 --- a/addons/uom/tests/test_uom.py +++ b/addons/uom/tests/test_uom.py @@ -62,6 +62,12 @@ class TestUom(TransactionCase): 'category_id': time_category.id }) + def test_31_reference_uniqueness(self): + """ Check the uniqueness of the reference UoM in a category """ + time_category = self.env['uom.category'].search([('measure_type', '=', 'working_time')], limit=1) + with self.assertRaises(ValidationError): + self.env['uom.uom'].search([('measure_type', '=', 'unit'), ('uom_type', '=', 'reference')]).category_id = time_category + def test_40_custom_uom(self): """ A custom UoM is an UoM in a category without measurement type. It should behave like a normal UoM """ category = self.env['uom.category'].create({ |
