Skip to Content
Menu
This question has been flagged
3 Replies
2404 Views

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
Discard
Author Best Answer

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
1
Nov 24
26277
2
May 18
3506
2
Mar 15
11500
1
Mar 24
3819
1
Jan 24
13852