[FW][FIX] stock: adapt _onchange_location_in for New records
#190418
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Steps to reproduce:
Store to sublocation(location_out_idofstock.putaway.rule) > Close studio> Traceback
Cause of the issue:
Adding a line will trigger an onchange of the
stock.putaway.rulemodel in order to compute the default data of the new subrecord. However, the code will crash during the_search_countof the_onchange_location_inbecause of an invalid domain:odoo/addons/stock/models/product_strategy.py
Lines 80 to 88 in 29939aa
location_out_idwill 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