Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
4005 Widoki

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?

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lis 24
27716
2
maj 18
4487
2
mar 15
12548
1
mar 24
5849
1
sty 24
15192