Touati Djamel (otd) 2a5e079ef7 [FIX] mrp: unbuild a manufacturing order with a tracked product
Steps to reproduce the bug:
- Create a storable product “P1”:
    - Tracked by SN
    - BoM:
        - Component:  1 unit of “C1”

- Create a Mo to produce one unit of “P1”:
    - Confirm the MO
    - Set a new serial number “SN1” and qty done for “C1”
    - Mark as done
    - Click on “unbuild” button

Problem:
An user error is triggered: “This lot ‘SN1’ is incompatible with this
product ‘C1’

When you click on the "Unbuild" button, the `lot_id` of the finished
product is added in the context with the key `'default_lot_id'`:
https://github.com/odoo/odoo/blob/dd60647ce41547ecd00bbde45ddf564a7ada91c7/addons/mrp/models/mrp_production.py#L1977
Therefore, when creating the `stock.move.line` for the component,
even if the “lot_id” is not in the vals, we will get the “lot_id” from the context:

https://github.com/odoo/odoo/blob/d04a5b5c8c7dc13e4e911a29d1944e90587e2883/odoo/models.py#L4136

https://github.com/odoo/odoo/blob/d04a5b5c8c7dc13e4e911a29d1944e90587e2883/odoo/models.py#L1961

Then, we do a field validation via a constraint, but as the product "C1"
is not compatible with the product in lot "P1", an error is triggered:

https://github.com/odoo/odoo/blob/b9334c53b84228c00ab100ffd28620b3c923c4e6/addons/stock/models/stock_move_line.py#L94-L95

opw-3284525

closes odoo/odoo#120981

X-original-commit: 2ee59a523e12b79c1338467bcf7577a1c9b63d11
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-05-10 21:18:08 +02: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%