Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6164 Lượt xem

Hi,

I want to have 2 different input fields, dependent if a user is in a group or not. The one if a user is in the group works but the on if the user is not not. I also tried <t groups="not myaddon.group_tag">


<t groups="myaddon.group_tag">
    <field name="category_id"
           widget="many2many_tags"
           placeholder="Tags..."/>
</t>
<t groups="! myaddon.group_tag">
    <field name="category_id"
           widget="many2many_tags"
           options="{'no_create': True}"
           placeholder="Tags not..."/>
</t>

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I did not find any syntax for this, so I solved it differently

For my dialog (TransientModel) I created a helper field:


def _get_has_mygroup(self):
return self.env.user.has_group('mygroup')

has_mygroup = fields.Boolean(default=_get_has_mygroup)


Afterwards I use it for readonly or invisible conditions.
Ảnh đại diện
Huỷ bỏ

Yes, This is the correct way

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 5 19
6292
1
thg 7 25
1771
1
thg 5 25
1842
1
thg 4 25
2330
1
thg 2 25
1610