Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
7268 Weergaven
@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
Annuleer
Beste antwoord

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
Annuleer

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

Gerelateerde posts Antwoorden Weergaven Activiteit
2
jul. 23
5177
2
feb. 23
3770
1
mei 25
1574
1
apr. 25
2740
1
apr. 25
3502