Skip to content

Conversation

@fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Dec 11, 2024

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:

@api.onchange('location_in_id')
def _onchange_location_in(self):
child_location_count = 0
if self.location_out_id:
child_location_count = self.env['stock.location'].search_count([
('id', '=', self.location_out_id.id),
('id', 'child_of', self.location_in_id.id),
('id', '!=', self.location_in_id.id),
])
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

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 the`stock.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

X-original-commit: 74882d0
@robodoo
Copy link
Contributor

robodoo commented Dec 11, 2024

Pull request status dashboard

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Dec 11, 2024
@fw-bot
Copy link
Contributor Author

fw-bot commented Dec 11, 2024

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Dec 11, 2024
@fw-bot
Copy link
Contributor Author

fw-bot commented Dec 12, 2024

@lase-odoo @Whenrow this forward port of #188053 is awaiting action (not merged or closed).

@lase-odoo
Copy link
Contributor

robodoo r+

robodoo pushed a commit that referenced this pull request Dec 12, 2024
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 the`stock.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

closes #190418

X-original-commit: 74882d0
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Lancelot Semal (lase) <lase@odoo.com>
@robodoo robodoo added the 18.1 label Dec 12, 2024
@robodoo robodoo closed this Dec 12, 2024
@fw-bot fw-bot deleted the master-16.0-opw-4126731-onchange_one2many_studio-lase-iN6k-fw branch December 26, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

18.1 forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants