diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py index a58ad781b38..76dbe43bb20 100644 --- a/addons/mrp/models/mrp_bom.py +++ b/addons/mrp/models/mrp_bom.py @@ -436,7 +436,9 @@ class MrpByProduct(models.Model): product_qty = fields.Float( 'Quantity', default=1.0, digits='Product Unit of Measure', required=True) - product_uom_id = fields.Many2one('uom.uom', 'Unit of Measure', required=True) + product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id') + product_uom_id = fields.Many2one('uom.uom', 'Unit of Measure', required=True, + domain="[('category_id', '=', product_uom_category_id)]") bom_id = fields.Many2one('mrp.bom', 'BoM', ondelete='cascade', index=True) allowed_operation_ids = fields.One2many('mrp.routing.workcenter', related='bom_id.operation_ids') operation_id = fields.Many2one( @@ -448,14 +450,3 @@ class MrpByProduct(models.Model): """ Changes UoM if product_id changes. """ if self.product_id: self.product_uom_id = self.product_id.uom_id.id - - @api.onchange('product_uom_id') - def onchange_uom(self): - res = {} - if self.product_uom_id and self.product_id and self.product_uom_id.category_id != self.product_id.uom_id.category_id: - res['warning'] = { - 'title': _('Warning'), - 'message': _('The unit of measure you choose is in a different category than the product unit of measure.') - } - self.product_uom_id = self.product_id.uom_id.id - return res diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml index ba283f00b57..03554e5977a 100644 --- a/addons/mrp/views/mrp_bom_views.xml +++ b/addons/mrp/views/mrp_bom_views.xml @@ -17,6 +17,7 @@ +