How to do it...

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:

  1. 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)
  1. 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) 
  1. 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 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.111.33