我想在 odoo 10 中创建一个条形图(图表视图),可以显示每门课程学习的学生人数。有了这个 python 数据库,我该如何实现它?Internet 上没有关于此类视图的示例代码。
class Student(models.Model):
_name = "studentmanagement.student"
id= fields.Char(required=True, index=True)
full_name= fields.Char(required=True, index=True)
gender = fields.Char()
birthday = fields.Char(required=True)
address = fields.Char(required=True)
course_inscription = fields.Many2many('studentmanagement.course',string = 'inscription')
_sql_constraints = [('id_unique', 'UNIQUE(id)', 'Two students can not have the same ID!')]
class course(models.Model):
_name = "studentmanagement.course"
code = fields.Char(required=True, index=True)
course_name = fields.Char(required=True, index=True)
credits = fields.Integer(required=True)
nstudent= fields.Integer(compute='_compute_percentage_students_course', store=True)
_sql_constraints = [('code_unique', 'UNIQUE(code)', 'Two courses can not have the same ID!')]
@api.depends('percentage','course_inscription')
def _compute_percentage_students_course(self):
for record in self:
record.nstudent = len(record.course_inscription)
非常感谢你的帮助 !