Adrien Widart 5a2edc50ea [FIX] stock: receive products with detailed operations
A recursion error may appear when a user receives a product.

To reproduce the issue:
1. Create a tracked-by-usn product P
2. Create an immediate receipt for P
3. In the Detailed Operations wizard, add a line and Confirm

Error: An Odoo Server Error is raised (`RecursionError`)

[1] When confirming the wizard, a new SML is created. In the creation
method, we define the `product_uom_qty` of the associated SM:
https://github.com/odoo/odoo/blob/1b1b320c4b8a0c08d156e569216cbea1100fb1bb/addons/stock/models/stock_move_line.py#L294
[2] In the writing method of the SM, because we are defining
`product_uom_qty`, we unreserve and assign again the SM:
https://github.com/odoo/odoo/blob/1b1b320c4b8a0c08d156e569216cbea1100fb1bb/addons/stock/models/stock_move.py#L606-L607
[3] In the assigning method, because there isn't any need, it quickly
lead to
https://github.com/odoo/odoo/blob/1b1b320c4b8a0c08d156e569216cbea1100fb1bb/addons/stock/models/stock_move.py#L1487-L1488
i.e., the SM is considered as assigned and flagged to be redirected
[4] In the redirection method (`_apply_putaway_strategy`), we define the
new destination location of the SML.
https://github.com/odoo/odoo/blob/1b1b320c4b8a0c08d156e569216cbea1100fb1bb/addons/stock/models/stock_move_line.py#L230
[5] Because of this, in the writing method of the SML, we define again
the `product_uom_qty` of the SM:
https://github.com/odoo/odoo/blob/1b1b320c4b8a0c08d156e569216cbea1100fb1bb/addons/stock/models/stock_move_line.py#L461-L462
This brings us back to step 2 => Recursion

In the writing method of the SM (step 2), we can prevent the "unreserve
& reserve again" step thanks to a key-context: `do_not_unreserve`.

OPW-2833951

closes odoo/odoo#90171

X-original-commit: fbc5cf7813c2e9d8a02fe8a73a74bfa32a8f9b96
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-04-29 18:22:06 +02:00
2022-04-23 07:37:55 +02:00
…
2015-09-08 17:58:38 +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%