From b1e328d369ce553bb14d0add127ff146cfce5e39 Mon Sep 17 00:00:00 2001 From: Vishal Thacker Date: Thu, 21 Oct 2021 08:48:46 +0000 Subject: [PATCH] [IMP] uom: set one unit as a Reference Unit Before this commit, the user was able to change the UoM type from "Reference Unit" to "Bigger" or "Smaller" and let an UoM category with no reference. So, to force UoM category to have at least one Reference Unit, the user can't change the reference unit if there is no other unit set as reference. task-2581265 Part-of: odoo/odoo#74695 --- addons/uom/models/uom_uom.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/addons/uom/models/uom_uom.py b/addons/uom/models/uom_uom.py index 627a84aa724..0855cdcf61a 100644 --- a/addons/uom/models/uom_uom.py +++ b/addons/uom/models/uom_uom.py @@ -24,12 +24,7 @@ class UoMCategory(models.Model): else: reference_count = sum(uom.uom_type == 'reference' for uom in self.uom_ids) if reference_count == 0 and self._origin.id: - return { - 'warning': { - 'title': _('Warning!'), - 'message': _("UoM category %s should have a reference unit of measure.") % self.name - } - } + raise UserError(_('UoM category %s must have at least one reference unit of measure.', self.name)) if self.reference_uom_id: new_reference = self.uom_ids.filtered(lambda o: o.uom_type == 'reference' and o._origin.id != self.reference_uom_id.id) else: