diff --git a/mrp_bom_widget_section_and_note_one2many/models/mrp_bom_line.py b/mrp_bom_widget_section_and_note_one2many/models/mrp_bom_line.py index df851ed5b..a7eb58bbd 100644 --- a/mrp_bom_widget_section_and_note_one2many/models/mrp_bom_line.py +++ b/mrp_bom_widget_section_and_note_one2many/models/mrp_bom_line.py @@ -11,6 +11,7 @@ class MrpBomLine(models.Model): # Returns mandatory for classic line thanks to _sql_constraints and view product_id = fields.Many2one(required=False) + product_uom_id = fields.Many2one(required=False) # New fields to handle section & note name = fields.Text(string="Description") @@ -23,10 +24,15 @@ class MrpBomLine(models.Model): _sql_constraints = [ ( - "bom_required_fields", + "bom_required_fields_product_qty", "CHECK(display_type IS NOT NULL OR" "(product_id IS NOT NULL AND product_qty IS NOT NULL))", - "Missing required fields on bom line.", + "Missing required fields on bom line : product and quantity.", + ), + ( + "bom_required_field_uom", + "CHECK(display_type IS NOT NULL OR" "(product_uom_id IS NOT NULL))", + "Missing required field on bom line : uom.", ), ( "non_bom_null_fields", diff --git a/mrp_bom_widget_section_and_note_one2many/views/view_mrp_bom.xml b/mrp_bom_widget_section_and_note_one2many/views/view_mrp_bom.xml index 629a7e941..ad2691903 100644 --- a/mrp_bom_widget_section_and_note_one2many/views/view_mrp_bom.xml +++ b/mrp_bom_widget_section_and_note_one2many/views/view_mrp_bom.xml @@ -79,6 +79,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). options="{'no_open':True,'no_create':True}" groups="uom.group_uom" attrs="{ + 'required': [('display_type', '=', False)], 'invisible': [('display_type', '=', True)], }" />