Friday, September 25, 2026
1 change · 18.0
Resolved issues and error corrections
Fixed an issue where confirming or processing rental orders could fail when one product variant had a kit setup but another variant did not. This keeps rental workflows moving correctly for businesses using variant-specific kits.
Original PR description
Steps to reproduce: ------------------- - Install `sale_mrp_renting` module. - Enable **Rental Transfers** from setting - Create a storable rental product with two variants: - Green - color - Grey -…
Steps to reproduce:
-------------------
- Install `sale_mrp_renting` module.
- Enable **Rental Transfers** from setting
- Create a storable rental product with two variants:
- Green - color
- Grey - color
- Create a Kit BoM for the Green variant only and add a component
- Create a rental order for one Grey unit
- Confirm the rental order
Issue:
------
Confirming the rental order raises a `ZeroDivisionError`
```txt
File "/data/build/enterprise/sale_mrp_renting/models/sale_order_line.py", line 21, in _get_qty_procurement
qty_to_compute = outgoing_moves._compute_kit_quantities(self.product_id, order_qty, bom, filters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/build/odoo/addons/mrp/models/stock_move.py", line 785, in _compute_kit_quantities
kit_qty = kit_qty / kit_bom.product_qty
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: float division by zero
```
Cause:
-------
When the user confirms the order, `action_confirm()` calls `_action_confirm()`, which launches stock rules through `_action_launch_stock_rule()`. This calls `_get_qty_procurement()` to determine the quantity already procured.
The rental override then checks whether the product has a Kit BoM using:
```python
'phantom' in self.product_id.bom_ids.mapped('type')
```
https://github.com/odoo/enterprise/blob/1913d8b8c411086914278600f80ef8dd45e1fc3b/sale_mrp_renting/models/sale_order_line.py#L10-L23
However, `bom_ids` is defined on `product.template` through `product_tmpl_id`.
Therefore, Grey also sees the Kit BoM belonging to Green, since both variants share the same template.
See the [BoM field definition](https://github.com/odoo/odoo/blob/c270965ec11c95e5e2866b30f8fa2c90287c6e8a/addons/mrp/models/product.py#L21-L25).
The condition evaluates to `True`, and the code enters the kit calculation. It then calls:
```python
bom = self.env['mrp.bom']._bom_find(self.product_id, bom_type='phantom')[self.product_id]
```
Unlike the template-level check, `_bom_find()` looks for a BoM applicable to the actual variant.
Since the only Kit BoM is restricted to Green, the lookup correctly returns an empty recordset for Grey.
See the [BoM lookup](https://github.com/odoo/odoo/blob/c270965ec11c95e5e2866b30f8fa2c90287c6e8a/addons/mrp/models/mrp_bom.py#L351-L388).
For an order of one Grey unit, the values are:
```text
product.bom_ids.mapped('type') = ['phantom']
bom = mrp.bom()
order_qty = 1.0
bom.product_qty = 0.0
```
The quantity conversion leaves `order_qty` unchanged because the empty BoM has no destination UoM.
See the [UoM conversion](https://github.com/odoo/odoo/blob/c270965ec11c95e5e2866b30f8fa2c90287c6e8a/addons/uom/models/uom_uom.py#L211-L220)
The code then passes this empty BoM to `_compute_kit_quantities()`. Its first division becomes `1.0 / 0.0`, raising `ZeroDivisionError`. The zero comes from the empty recordset, not from Green's BoM quantity.
[See failing division](https://github.com/odoo/odoo/blob/c270965ec11c95e5e2866b30f8fa2c90287c6e8a/addons/mrp/models/stock_move.py#L774-L786)
Fixing confirmation alone leaves the same issue in later operations. Delivered-quantity computation also passes an empty BoM to the kit helper when completed outgoing moves exist.
https://github.com/odoo/enterprise/blob/1913d8b8c411086914278600f80ef8dd45e1fc3b/sale_mrp_renting/models/sale_order_line.py#L25-L49
After confirmation and pickup succeed, validating the return triggers `stock.move._action_done()`. Its kit check also accepts Grey based on Green's BoM, then passes an empty BoM to `_compute_kit_quantities()`, causing the same division-by-zero error.
https://github.com/odoo/enterprise/blob/1913d8b8c411086914278600f80ef8dd45e1fc3b/sale_mrp_renting/models/stock_move.py#L10-L30
Fix
---
Only perform kit calculations when `_bom_find()` returns a matching BoM.
- For procurement, return the quantity computed by the parent method when no matching BoM exists.
- For delivered quantities, delegate lines without a matching kit BoM to the parent computation through `todo_ids`.
- For returns, skip kit-specific calculations when no matching BoM exists, preserving the normal rental return handling.
---------
opw-6588790