Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
7750 Widoki
@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

Awatar
Odrzuć
Najlepsza odpowiedź

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


Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
2
lip 23
5641
2
lut 23
4175
1
maj 25
2398
1
kwi 25
3425
1
kwi 25
4239