i created a custom module and now i want to give a security rule that any users who logged in can can edit their own records
Thanks in advance
my code
from odoo import fields, models, api
from odoo.exceptions import UserError
class Subject(models.Model):
_name = 'std.subject'
_description = 'Subject'
name = fields.Char(string='Subject')
student_id = fields.Many2many('std.record', string='students')
class StudentDetails(models.Model):
_name = 'std.record'
_description = 'Student'
name = fields.Char(string='Name')
middle_name = fields.Char(string='Middle Name')
last_name = fields.Char(string='Last Name')
roll_no = fields.Integer(string='Roll Number')
std_dob = fields.Date(string='Date of Birth')
image = fields.Binary(string='Image')
introduction = fields.Text(string="Introduction")
std_class = fields.Many2one(comodel_name='std.class', string='Student Class')
subj = fields.Many2many(comodel_name='std.subject', string='Subject')
user_id = fields.Many2one(comodel_name='res.users',string='User')
_sql_constraints = [
('unique_roll_number', 'unique(roll_no)', 'This roll number is already used on another student.'), ]
@api.constrains('std_dob')
def check_student_dob(self):
if self.std_dob and self.std_dob >= fields.Date.today():
raise UserError(('DOB should be less than Today\'s Date.'))
class Class(models.Model):
_name = 'std.class'
_description = 'Class'
name = fields.Char(string='Class')
stdnt_class = fields.One2many(
comodel_name='std.record',
inverse_name='std_class',
string='class',
required=False)