odoo/odoo#200538

Created by fw-bot
Merged at b9508277278b623aef7b592c6d3f7cdde6e65380

Statuses:

Linked pull requests
label
odoo-dev:saas-18.2-17.0-opw-4452747-create_new_finished_lot_mo-lase-415847-fw
head
e47ff71cdbdc68559551f10fefba8171365f2eac
merged
8 months ago by Bugfix, Lancelot Semal (lase)
odoo/odoo odoo/enterprise
17.0 #193965 #77265
saas-17.2 #196663 #78632
saas-17.4 #197155 #197112 #78966 #78940
18.0 #197372 #79109
saas-18.1 #197516 #79189
saas-18.2 #200538 #80861
master #200771 #80973

[FW][FIX] mrp: allow finished lot production via quality checks

Steps to reproduce:

  • Create a storable product FP tracked by SN with a BOM:
    • 1 Operation: - instruction: Register Production type (per product)
    • 1 x Comp (storable product in stock)
  • Create and confirm an MO for one unit of FP.
  • Go to the shopfoor app > open the instruction of your operation
  • Type a non-existing serial number in the search bar > Create "new_sn"
    > This opens a form view of the stock.lot model
  • Save and close the new stock.lot
    > Invalid operation: You are not allowed to create or edit a lot or serial number for the components with the operation type
    > "Manufacturing". To change this, go on the operation type and tick the box "Create New Lots/Serial Numbers for
    > Components"

Expected behavior:

The invalid operation should not be raised as the "required" option concerns only componenets and not final products.

Cause of the issue:

Creating a stock lot will first launch a call of the _check_create: https://github.com/odoo/odoo/blob/c25d71f14fa168807f07cd88bed805d15db8add5/addons/stock/models/stock_lot.py#L150-L153 However, since this check does not verifies that the product for which we create the lot is indeed related to a component of the MO it will raise the invalid operation even for final products: https://github.com/odoo/odoo/blob/c25d71f14fa168807f07cd88bed805d15db8add5/addons/mrp/models/stock_lot.py#L11-L17

Issue 2:

Currently, the quickCreate ("Create sn_name") option of the lot field of te "register production" dialog calls a name_create that will set an error message in the logs as the product_id required field can not be provided neither in the vals or the context of the name_create. You then fall back on the same form dialog than the "Create and edit". The quickCreate option should therefore just be disabled.

Enterprise: odoo/enterprise#77265

opw-4452747

I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #197516
Forward-Port-Of: #193965