Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
7249 Vistas
@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
Descartar
Mejor respuesta

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
Descartar

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

Publicaciones relacionadas Respuestas Vistas Actividad
2
jul 23
5159
2
feb 23
3756
1
may 25
1464
1
abr 25
2689
1
abr 25
3467