Skip to Content
Menu
This question has been flagged
1 Reply
5876 Views
@api.onchange("name_teacher")
def _onchange_name_teacher(self):
for rec in self:
return{
'domain': {'name_subject': [('name_teacher', 'in', rec.name_teacher.name_subject.ids)]}
}


error:

WARNING odoo16 odoo.models: onchange method TeacherSubject._onchange_name_teacher 

returned a domain, this is deprecated


No data is showing on table

Avatar
Discard
Best Answer

Hi,

Returning a domain using onchange method has been deprecated in Odoo 14.


The standard way is to use a computed field as below:

https://github.com/odoo/odoo/pull/41918#issuecomment-824946980


Avatar
Discard

Thank you Waleed for this information and the link to the OCA module.

If the capability of returning a domain from an onchange method has been deprecated, is this OCA module the "standard" way to do this type of thing?

My use case is that I have a dropdown list of values (pricelists) and I want to filter the list to those that meet certain qualifications based on the partner that has been selected. I need to be able to change the domain on that field based on the partner selected.

Odoo didn't mention what should we use, but the standard solution is to use fields domain parameter:
For more details, You can check the below link for this case:
https://github.com/odoo/odoo/pull/41918

Related Posts Replies Views Activity
2
Jul 23
3693
2
Feb 23
2581
3
Nov 24
2955
5
Nov 24
7482
2
Oct 24
2890