odoo/odoo#191415

Created by fw-bot
Merged at f5cef4422548f7cf33595a74747e0c6c47a21e28

Statuses:

label
odoo-dev:master-17.0-sentry-6156032937-stock-value-error-mega-gx_H-fw
head
46dcf29c3d5ec09de169b3c2bea2472216a28ff9
merged
10 months ago by Bugfix, Meet Gandhi (mega)
odoo/odoo
17.0 #191005
saas-17.2 #191360
saas-17.4 #191381
18.0 #191400
saas-18.2
saas-18.3
saas-18.4
19.0
master #191415

[FW][FIX] stock: prevent error while validating stock move

Currently, an error occurs when validating stock moves without location.

Step to produce:

  • Install the mrp_subcontracting module (make a debugger on).
  • Create a product, add some quantities, and remove the value of 'Production Location' and 'Inventory Location' from it.
  • Click on the 'Bills of Materials' button which is in the breadcrumbs of the product form view to create a bom of this product, And set a 'BoM Type' as Subcontracting and add an Administrator as 'Subcontractors'.
  • Go to Inventory / Operations / Transfers / Receipts and create a new 'Receipts', add an Administrator as 'Receive From', and add product in 'Operations' which we created bom.
  • Open a form view of 'Receive From' (res.partner) and remove value from 'Subcontractor Location' filed which is in the 'Sales & Purchase' tab.
  • Again come to receipts form view and try to validate it.

ValueError: Expected singleton: stock.location()

This occurs because the system attempts to get 'location_id' from the stock move at [1], but it is not available.

Link [1]: https://github.com/odoo/odoo/blob/231952114ae730bb8d4671f4a61f738e8b6dd5b8/addons/stock/models/stock_move.py#L1566

To resolve this issue, add a condition to check if location_id is not available then use the company's subcontracting location as the default value.

Sentry-6156032937


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

Forward-Port-Of: #191005