@ -166,10 +166,11 @@ def _create(self, data_list):
[ ( ' model ' , ' = ' , self . _name ) ] ) . id
access_right_rec = self . env [ ' access.right ' ] . sudo ( ) . search_read (
[ ( ' model_id ' , ' = ' , current_model_id ) ] ,
[ ' model_id ' , ' is_create_or_update ' ,
[ ' model_id ' , ' is_create_or_update ' , ' restriction_type ' , ' user_id ' ,
' groups_id ' ] )
if access_right_rec and not self . env . is_admin ( ) :
for rec in access_right_rec :
if rec [ ' restriction_type ' ] == ' group ' :
group_name = self . env [ ' ir.model.data ' ] . sudo ( ) . search ( [
( ' model ' , ' = ' , ' res.groups ' ) ,
( ' res_id ' , ' = ' , rec [ ' groups_id ' ] [ 0 ] )
@ -181,7 +182,15 @@ def _create(self, data_list):
group = module_name + " . " + group_name
if self . env . user . has_group ( group ) :
if rec [ ' is_create_or_update ' ] :
raise UserError ( ' You are restricted from performing this '
raise UserError (
' You are restricted from performing this '
' operation. Please contact the '
' administrator. ' )
if rec [ ' restriction_type ' ] == ' user ' :
if self . env . user . id == rec [ ' user_id ' ] [ 0 ] :
if rec [ ' is_create_or_update ' ] :
raise UserError (
' You are restricted from performing this '
' operation. Please contact the '
' administrator. ' )
return records
@ -291,9 +300,11 @@ def unlink(self):
[ ( ' model ' , ' = ' , self . _name ) ] ) . id
access_right_rec = self . env [ ' access.right ' ] . sudo ( ) . search_read (
[ ( ' model_id ' , ' = ' , current_model_id ) ] , [ ' model_id ' , ' is_delete ' ,
' restriction_type ' , ' user_id ' ,
' groups_id ' ] )
if access_right_rec and not self . env . is_admin ( ) :
for rec in access_right_rec :
if rec [ ' restriction_type ' ] == ' group ' :
group_name = self . env [ ' ir.model.data ' ] . sudo ( ) . search ( [
( ' model ' , ' = ' , ' res.groups ' ) ,
( ' res_id ' , ' = ' , rec [ ' groups_id ' ] [ 0 ] )
@ -305,9 +316,17 @@ def unlink(self):
group = module_name + " . " + group_name
if self . env . user . has_group ( group ) :
if rec [ ' is_delete ' ] :
raise UserError ( _ ( ' You are restricted from performing this '
raise UserError (
_ ( ' You are restricted from performing this '
' operation. Please contact the '
' administrator. ' ) )
if rec [ ' restriction_type ' ] == ' user ' :
if self . env . user . id == rec [ ' user_id ' ] [ 0 ] :
if rec [ ' is_delete ' ] :
raise UserError (
' You are restricted from performing this '
' operation. Please contact the '
' administrator. ' )
return True