تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
3891 أدوات العرض

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
نوفمبر 24
27644
2
مايو 18
4454
2
مارس 15
12524
1
مارس 24
5613
1
يناير 24
15136