odoo/odoo#190418

Created by fw-bot
Merged at eb7161ff96b7f6eaaf9647f4a4f00b15d1995868

Statuses:

label
odoo-dev:master-16.0-opw-4126731-onchange_one2many_studio-lase-iN6k-fw
head
b7d07732a8a0a99e315e517b8059c9d921e69f62
merged
1 year ago by Bugfix, Lancelot Semal (lase)
odoo/odoo
16.0 #188053
17.0 #189469
saas-17.2 #189878
saas-17.4 #190409
18.0 #190415
saas-18.2
saas-18.3
saas-18.4
19.0
master #190418

[FW][FIX] stock: adapt `_onchange_location_in` for New records

Steps to reproduce:

  • Enable Multi-Steps Routes in the settings
  • Inventory > Configuration > Warehouse Management > Locations
  • Pick any location
  • With studio add the one2Many field Store to sublocation (location_out_id of stock.putaway.rule) > Close studio
  • Try to add a line on the associated list

> Traceback

Cause of the issue:

Adding a line will trigger an onchange of thestock.putaway.rule model in order to compute the default data of the new subrecord. However, the code will crash during the _search_count of the _onchange_location_in because of an invalid domain: https://github.com/odoo/odoo/blob/29939aa5fb1455af89a37293d2f76541ff1645ef/addons/stock/models/product_strategy.py#L80-L88 THis crashed since in our case the location_out_id will be a new record created during the onchange to represent the 'stock.location' and from which we are looking at the form. As such, a NewId will be given and treated as an integer in the domain leading to a traceback when the db is served.

Fix:

Onchange method should be robust with respect to the usage of New records and hence the records used here should be replace by their origin if it even exists.

opw-4126731

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

Forward-Port-Of: #189878
Forward-Port-Of: #188053