From e71f954da3a3b29f2b89e02b56419de43e13952c Mon Sep 17 00:00:00 2001 From: Priyanka Kakadiya Date: Tue, 28 May 2019 07:47:43 +0000 Subject: [PATCH] [REF] purchase,mrp,repairs,stock: enforce uom domain Enforce the domain of the UOM not by an onchange but by a domain. Exemple of issue if the domain is enforce by an onchange: - create a picking - add a move - select the product - select an uom > the uom presented are the one from the product category. -Save - edit - select an uom > all UOM are presented even the ones of other categories This commit enforce this new logic at most places. task: 1886272 closes odoo/odoo#33083 Signed-off-by: Simon Lejeune (sle) --- addons/mrp/models/mrp_bom.py | 6 ++++-- addons/mrp/views/mrp_bom_views.xml | 3 +++ addons/purchase/models/purchase.py | 9 +++------ addons/purchase/views/purchase_views.xml | 2 ++ .../purchase_requisition/models/purchase_requisition.py | 3 ++- .../views/purchase_requisition_views.xml | 2 ++ addons/repair/models/repair.py | 9 ++++++--- addons/repair/views/repair_views.xml | 5 +++++ addons/stock/models/stock_move.py | 4 ++-- addons/stock/models/stock_scrap.py | 3 ++- addons/stock/views/stock_move_views.xml | 4 ++++ addons/stock/views/stock_picking_views.xml | 1 + addons/stock/views/stock_scrap_views.xml | 2 ++ 13 files changed, 38 insertions(+), 15 deletions(-) diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py index 26456acc724..a6d2ab4f297 100644 --- a/addons/mrp/models/mrp_bom.py +++ b/addons/mrp/models/mrp_bom.py @@ -43,7 +43,8 @@ class MrpBom(models.Model): product_uom_id = fields.Many2one( 'uom.uom', 'Product Unit of Measure', default=_get_default_product_uom_id, oldname='product_uom', required=True, - help="Unit of Measure (Unit of Measure) is the unit of measurement for the inventory control") + help="Unit of Measure (Unit of Measure) is the unit of measurement for the inventory control", domain="[('category_id', '=', product_uom_category_id)]") + product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id') sequence = fields.Integer('Sequence', help="Gives the sequence order when displaying a list of bills of material.") routing_id = fields.Many2one( 'mrp.routing', 'Routing', @@ -233,7 +234,8 @@ class MrpBomLine(models.Model): 'uom.uom', 'Product Unit of Measure', default=_get_default_product_uom_id, oldname='product_uom', required=True, - help="Unit of Measure (Unit of Measure) is the unit of measurement for the inventory control") + help="Unit of Measure (Unit of Measure) is the unit of measurement for the inventory control", domain="[('category_id', '=', product_uom_category_id)]") + product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id') sequence = fields.Integer( 'Sequence', default=1, help="Gives the sequence order when displaying.") diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml index 26d8b27dde7..0d68a231435 100644 --- a/addons/mrp/views/mrp_bom_views.xml +++ b/addons/mrp/views/mrp_bom_views.xml @@ -26,6 +26,7 @@ +