Reputation: 3057
Is this possible is odoo that we grant edit access to a model in one view but not in over all system. Because as per my knowledge if you grant any of CRUD access to a particular group or user. It will be applied on all views in your system. I want user to be able to edit a record of model only if he is in a specific view.
Upvotes: 2
Views: 835
Reputation: 14746
You can add groups to the view directly that will be only for visibility purpose. That will directly invisible that view for that user.
Or you can override fields_view_get method in which you can set view readonly to user.
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
view = self.env.ref('view_external_id').id
if view == view_id and view_type=='form':
view_info['arch'] = view_info['arch'].replace("<form","<form edit="\"false\"")
return super(class_name, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
Upvotes: 1