Adrien Widart 3e8a45fce0 [FIX] stock,sale_mrp: avoid post-process scheduler if no procurement
When the post-production location is a child of the stock location,
running the scheduler may lead to a recursion error.

To reproduce the issue:
(Enable debug mode. Use demo data)
1. In Settings, enable "Multi-Step Routes"
2. Edit the warehouse:
    - Manufacture: 3 steps
3. In the locations, edit WH/Post-Production:
    - Parent Location: WH/Stock
4. Create two products P_finished, P_compo:
    - P_finished:
        - Storable
        - Route Manufacture
5. Create a reordering rule RR for P_finished:
    - Location: WH/Stock
    - Min: 0
    - Max: 0
6. Create a BoM:
    - Product: P_finished
    - Type: Manufacture
    - Components: 1 x P_compo
7. Create a sale order SO with 1 x P_finished
8. Confirm SO

Error: an Odoo Server Error is displayed: "RecursionError"

When confirming the SO, it leads to the creation and the confirmation of
the delivery. When confirming the delivery, we trigger the scheduler:
because of the delivery, there is a need in WH/Stock. Moreover, there is
an reordering rule RR for that product and that location. Therefore, we
create and process a procurement and this will create the manufacturing
order for P_finished. Then, the post-process of the scheduler is called:
1. We find the draft MO related to the RR and confirm it:
https://github.com/odoo/odoo/blob/eabf5cc14b4c731f112e6c78b579ef8e98edcaad/addons/mrp/models/stock_orderpoint.py#L121-L125
2. When confirming the MO, we first try to confirm the associated
pickings (from Pre-Prod to Stock and from Post-Prod to Stock). Note that
we will update the state of the MO after the pickings confirmation:
https://github.com/odoo/odoo/blob/14431b2497dcf4aaf778ef1b06e023101b00a4e2/addons/mrp/models/mrp_production.py#L1204-L1208
3. When confirming a picking, we trigger the scheduler:
https://github.com/odoo/odoo/blob/fcc74186330c8df37cfac08455bd7bba44d4656b/addons/stock/models/stock_picking.py#L790-L791
4. We have two pickings, each one with one stock move: the first one
with 1 x P_compo from Pre-Prod to Stock, and a second one with 1 x
P_finished from Post-Prod to Stock. When triggering the scheduler, we
try to find a RR that fulfill the need of each SM:
https://github.com/odoo/odoo/blob/0183298293192538a801f52262c047ea34a1b76a/addons/stock/models/stock_move.py#L1949-L1954
The location of the created reordering rule is WH/Stock. The source
location of the second stock move is WH/Stock/Post-Production, i.e. a
child of WH/Stock. Therefore, we find the reordering rule we created and
we try to process an associated procurement:
https://github.com/odoo/odoo/blob/0183298293192538a801f52262c047ea34a1b76a/addons/stock/models/stock_move.py#L1961-L1962
5. Because there isn't any quantity to order, we don't create and
process any procurement:
https://github.com/odoo/odoo/blob/029da238a2baaf59bdf9ae828a4739ee4a9f3ede/addons/stock/models/stock_orderpoint.py#L519-L525
However, we still call the post-process of the scheduler:
https://github.com/odoo/odoo/blob/029da238a2baaf59bdf9ae828a4739ee4a9f3ede/addons/stock/models/stock_orderpoint.py#L548-L549
This brings us back to the step 1 => Recursion !

OPW-2926657

closes odoo/odoo#97646

X-original-commit: c06e1ec755206e8dd8aff6b341151848e6d173c7
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-08-08 23:45:39 +02:00
2022-08-08 22:16:21 +02:00
2022-08-08 12:33:02 +02:00
…
…
2021-10-07 17:59:53 +00:00
2022-01-14 15:44:52 +00:00

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%