Skip to content

Conversation

@eduezerouali-tecnativa
Copy link

cc @Tecnativa TT59293
ping @sergio-teruel @victoralmau

This module verifies all available BoMs for a given product and automatically selects the first BoM for which all required components are currently in stock. If no BoM meets the availability criteria, the module gracefully falls back to Odoo’s default BoM selection logic.

@pedrobaeza pedrobaeza added this to the 15.0 milestone Nov 19, 2025
@pedrobaeza
Copy link
Member

Check CI

for line in bom.bom_line_ids:
required = line.product_qty
component = line.product_id
available = quant._get_available_quantity(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to load the availability of all products at once to obtain better performance.
See how this is done in the production order:
https://github.com/odoo/odoo/blob/fb4c85e007ee70e95e95197d358f1cde19b82338/addons/stock/models/stock_move.py#L440

Then decide (either you or add an option for the user to do so) whether to take into account free_qty, virtual_available, or another option.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, virtual_available is hard-coded, but it might be useful to make this a configurable setting for the user. What do you think?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is better to add an option for the user to decide.
The default option should be free_qty.

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 15.0-add-mrp_bom_assign_auto branch 2 times, most recently from 406d769 to d5e2c31 Compare November 19, 2025 15:09
rec["id"]: rec["virtual_available"] for rec in product_available
}
for bom in boms:
if not bom:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this condition occur within the for?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will never occur, that was code left behind.

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 15.0-add-mrp_bom_assign_auto branch 2 times, most recently from b6197b8 to 49c4790 Compare November 21, 2025 11:19
@eduezerouali-tecnativa
Copy link
Author

ping @sergio-teruel @carlosdauden

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 15.0-add-mrp_bom_assign_auto branch from 6294525 to e1758d5 Compare December 1, 2025 13:38
@eduezerouali-tecnativa
Copy link
Author

@carlosdauden @sergio-teruel please could you review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants