콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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
아바타
취소
관련 게시물 답글 화면 활동
1
11월 19
3810
2
8월 23
2125
0
2월 21
3109
0
11월 20
2082
1
7월 20
3644