Hi I need to restrict the write access of a field in res.partner form. Only admin should have the access to write the field. The field should be readonly for all other users. How can I make it possible.
Thanks in Advance.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi I need to restrict the write access of a field in res.partner form. Only admin should have the access to write the field. The field should be readonly for all other users. How can I make it possible.
Thanks in Advance.
Hi! The following code is an example how to use fields_view_get:
@api.model
def fields_view_get(self, view_id=None, view_type=False, toolbar=False, submenu=False):
context = self._context or {}
res = super(Partner, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=False)
if not self.env.user.has_group('base.user_root'):
doc = etree.XML(res['arch'])
# The field you want to modify the attribute
node = doc.xpath("//field[@name='email']")[0]
node.set('readonly', '1')
setup_modifiers(node, res['fields']['email'])
res['arch'] = etree.tostring(doc)
return res
return res
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 11 19
|
3803 | ||
|
2
thg 8 23
|
2120 | ||
|
0
thg 2 21
|
3107 | ||
|
0
thg 11 20
|
2080 | ||
|
1
thg 7 20
|
3621 |