From 515fbccae3ea83c8f511e1b22266b9b29c88d2dd Mon Sep 17 00:00:00 2001 From: "Touati Djamel (otd)" Date: Thu, 1 Dec 2022 08:14:36 +0000 Subject: [PATCH] [FIX] mrp: do not convert the quantity if there is no BoM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: - install “mrp_mps” - Create a storable product “P1” - routes: Manufacture + MTO - make sure there is no BoM set - Go to “Master Production Schedule”: - Add the product “P1” - Add a quantity and click on “Replenish” Problem: A User Error is triggered with the following message: `The unit of measure Units defined on the order line doesn't belong to the same category as the unit of measure False defined on the product. Please correct the unit of measure defined on the order line or on the product, they should belong to the same category.` The `compute_qauntity` function is called to convert the qty into the UoM of the BoM, but since there is no bom, an empty record is given as a parameter: https://github.com/odoo/odoo/blob/8c5fb8b71538462422c8f166b772b5e316ecd6b5/addons/mrp/models/stock_rule.py#L122 https://github.com/odoo/odoo/blob/0f91970020af640faa3a06369fa888315f83f98f/addons/uom/models/uom_uom.py#L215 opw-3085227 closes odoo/odoo#107476 X-original-commit: 7d0df9035cf603ed25ef88a3cf99ed89aef6771e Signed-off-by: William Henrotin (whe) --- addons/mrp/models/stock_rule.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/stock_rule.py b/addons/mrp/models/stock_rule.py index df9dae68342..ae8faf098ef 100644 --- a/addons/mrp/models/stock_rule.py +++ b/addons/mrp/models/stock_rule.py @@ -119,8 +119,8 @@ class StockRule(models.Model): 'origin': origin, 'product_id': product_id.id, 'product_description_variants': values.get('product_description_variants'), - 'product_qty': product_uom._compute_quantity(product_qty, bom.product_uom_id), - 'product_uom_id': bom.product_uom_id.id, + 'product_qty': product_uom._compute_quantity(product_qty, bom.product_uom_id) if bom else product_qty, + 'product_uom_id': bom.product_uom_id.id if bom else product_uom.id, 'location_src_id': self.location_src_id.id or self.picking_type_id.default_location_src_id.id or location_dest_id.id, 'location_dest_id': location_dest_id.id, 'bom_id': bom.id,