I want to add a computed field to refer to the number of courses owned by each responsible
how can add this field and where ?
this is the code of Course class:
from odoo import api, fields, models,_
class AcademyCourse(models.Model):
_name="academy.course"
_description="Academy Course"
name=fields.Char(string="Course Name",required=True)
description=fields.Text(string="Course Description",required=True)
responsible_id=fields.Many2one('res.users',string="Responsible",ondelete="set null")
session_ids=fields.One2many('academy.session','course_id',string="Sessions")
_sql_constraints = {
('name_description_check',
'CHECK(name != description)',
'The title of the course should not be the description'),
('name_unique',
'UNIQUE(name)',
'The course title must be unique')
}
i don't have res.users class
how can i add this field inside it???
Solution 2:
Add One2many field with academy.course and relation field with responsible_id res.users after inherit in your code