Skip to content

[18.0] (Bug with the fix) Impossible to confirm a SO - Sale Order : error of "rounding in the UoM" --> TypeError: unsupported operand type(s) for *: 'NoneType' and 'float' #3890

@thsdrouot

Description

@thsdrouot

Module

sale_procurement_group_by_line in 18.0.1.0.0

Describe the bug

When confirming a quotation in Odoo 18 with the OCA module sale_procurement_group_by_line, the system raises a TypeError:

TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

The error occurs because _action_launch_stock_rule calls float_compare with a quantity (qty) that can be None, particularly for products of type 'kit'.
Additionally, the module does not handle cases where product UoM rounding is missing. This leads to crashes when confirming sales orders containing kits or lines with None quantities.

To Reproduce

Affected versions:

Steps to reproduce the behavior:

  1. Use a kit in a SO
  2. Try to confirm into a sale
  3. You get the error

Expected behavior
Sale confirmed and delivery ready

Here is the solution :

File to change : sale_procurement_group_by_line/model/sale.py

from odoo.tools.float_utils import float_compare

for line in self:
previous_product_uom_qty = line.product_uom_qty # ou la valeur calculée précédemment

# Utilise le champ Boolean du modèle
qty = line._get_qty_procurement(
    previous_product_uom_qty if line.has_previous_product_uom_qty else False
)

# Sécurisation UoM
rounding = line.product_uom.rounding or 1.0

# Sécurisation qty
qty_to_compare = qty or 0.0
product_uom_qty_to_compare = line.product_uom_qty or 0.0

# Gestion des kits : ne pas lancer de stock sur la ligne kit
if line.product_id.type == 'kit':
    qty_to_compare = 0.0

# Comparaison sécurisée
float_compare(
    qty_to_compare,
    product_uom_qty_to_compare,
    precision_rounding=rounding
)

[FIX] sale_procurement_group_by_line: handle kits and None quantities in _action_launch_stock_rule

  • Added a boolean field has_previous_product_uom_qty on sale.order.line to indicate if a previous UoM quantity exists.
  • Modified _action_launch_stock_rule to safely handle:
    • products of type 'kit'
    • None quantities returned by _get_qty_procurement
    • missing product UoM rounding values
  • Ensures float_compare always receives numeric values and a valid rounding, preventing TypeError on confirming quotations.
Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions