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

 I have created one field in my module and i dont want other user write ,create and edit .

How to acheive this

形象
丢弃
最佳答案

Try like this it may help you,
Add an extra field in the view, ie,

in Xml,

<field name="check_field" invisible="1" />
<field name="new_field" attrs="{'readonly': [('check_field', '!=', True)]}" />

in py,
check_field = fields.Boolean('Check', compute='get_user')


@api.multi  

@api.depends('new_field')   

def get_user(self):
        if SUPERUSER_ID == self._uid:
            self.check_user = True    

       else:
            self.check_user = False





形象
丢弃
最佳答案

Write two views for this model.One for the administrative user and other for the read only group.

形象
丢弃
最佳答案

Find administrative id from res_users model, after
<field name="name_field" attrs="{'readonly': [('<user_id>', '!=', <administrative id>)]}" />

形象
丢弃

<field name="name_field" attrs="{'readonly': [('<user_id>', '!=', 1)]}" />

it will help you..

相关帖文 回复 查看 活动
1
12月 24
6085
3
8月 24
6930
4
7月 24
41254
5
4月 23
99053
3
11月 22
4350