Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
3722 Vistas

i have attrs in field view in odoo

attrs="{'invisible': [('owner_user_id', 'in', maintenance_team_id.invisible_fields)]}"

maintenance_team_id - Many2one, it have a char field "invisible_fields" i want check if string is in this field, but i receive an error, because ther is no field in origonal model. What can i do in this situation?

Avatar
Descartar
Autor Mejor respuesta

thank you guys, your advices help me, here my changes:

invisible_fields = fields.Char(related='maintenance_team_id.invisible_fields', readonly=False)  in models.py

attrs="{'invisible': [('invisible_fields', '=ilike', 'owner_user_id')]}"  in views.xml

p.s. i have not enough carma now for choosing answer.

Avatar
Descartar
Mejor respuesta

Hello Wald

it is now allowed to access field using '.' in right side of domain for form view. you can create new related field to apply attrs as follow

1) Create new related char field  

invisible_field = fields.Char(related='maintenance_team_id.invisible_fields', readonly=False)


2) Apply attrs in xml 

        attrs="{'invisible': [('owner_user_id', '=', invisible_fields)]}"


Thanks & Regards,



CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat

Avatar
Descartar
Mejor respuesta

In cases where a related record value is needed for a client-side domain the dot notation can't be used. A solution could be to add to the model a related field by using the related= attribute. This way the value is accessible as a directly accessible model field. E.g.:


invisible_fields= fields.Many2one(related='maintenance_team_id.invisible_fields')


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
nov 24
27508
2
may 18
4344
2
mar 15
12406
1
mar 24
5118
1
ene 24
15040