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
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Nov 19
|
2732 | ||
|
2
Aug 23
|
1176 | ||
|
0
Feb 21
|
2338 | ||
|
0
Nov 20
|
1333 | ||
|
1
Jul 20
|
2551 |