Skip to content
Snippets Groups Projects
Commit 1bc3d37e authored by Adrien Widart (awt)'s avatar Adrien Widart (awt)
Browse files

[FIX] purchase_{mrp,stock}: run procurement with buy route

In multi-steps receipt, when running a procurement, using "Buy" as
preferred route does not always work because the route is not
correctly configured

To reproduce the issue:
1. In Settings, enable "Multi-Step Routes"
2. Edit the warehouse:
   - Incoming: 2 steps
3. Create a product P:
    - Type: Storable
    - Vendors: a vendor V
    - Routes:
        - Manufacture
        - Buy
4. Update on hand quantity:
   - -1 at WH/Stock
5. Open the Replenishment page
   - There should be a line with 1 x P
6. Set the Preferred route to "Buy"
7. Order Once

Error: a user error is displayed "There is no Bill of Material of
type manufacture [...] Please define a Bill [...]". This is
incorrect, it should generate a PO

The problem is simple: the Buy route is composed of one rule:
- Action: Buy
- Source Location: /
- Destination Location: WH/Input

But, when running the procurement, we first look for a rule to
fulfill the need at WH/Stock. We prioritize the rules of the
preferred route, but as explained above, the route does not contain
such a rule. Therefore, we use the other routes of the product:
https://github.com/odoo/odoo/blob/ba3bb9b701a382c4052ddb57392baeee32625937/addons/stock/models/stock_rule.py#L461-L466


And, because of step 3, it then finds the manufacture rule. This is
the reason why it tries to create a MO and why an error is raised
because of the missing BoM

OPW-3006960

closes odoo/odoo#108550

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 52593400
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment