In order to prevent users who are not members of the Library Managers group from modifying the value of manager_remarks, you need to perform the following steps:
- Extend the create() method, like this:
@api.model def create(self, values): if not self.user_has_groups( 'library.group_library_manager'): if 'manager_remarks' in values: raise exceptions.UserError( 'You are not allowed to modify ' 'manager_remarks' ) return super(LibraryBook, self).create(values)
- Extend the write() method, as follows:
@api.multi def write(self, values): if not self.user_has_groups( 'library.group_library_manager'): if 'manager_remarks' in values: raise exceptions.UserError( 'You are not allowed to modify ' 'manager_remarks' ) return super(LibraryBook, self).write(values)
- Extend the fields_get() method, as follows:
@api.model def fields_get(self, allfields=None, attributes=None): fields = super(LibraryBook, self).fields_get( allfields=allfields, attributes=attributes ) if not self.user_has_groups( 'library.group_library_manager'): if 'manager_remarks' in fields: fields['manager_remarks']['readonly'] = True