跳至内容
菜单
此问题已终结
3 回复
4001 查看

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?

形象
丢弃
编写者 最佳答案

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.

形象
丢弃
最佳答案

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

形象
丢弃
最佳答案

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')


形象
丢弃
相关帖文 回复 查看 活动
1
11月 24
27715
2
5月 18
4484
2
3月 15
12546
1
3月 24
5843
1
1月 24
15192