[FIX] mrp: do not convert the quantity if there is no BoM

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) <whe@odoo.com>
This commit is contained in:
Touati Djamel (otd)
2022-12-08 13:38:11 +01:00
parent 76199fd956
commit 515fbccae3
+2 -2
View File
@@ -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,