选择日期(参考时间表)时,如何在出勤模块中获取学生班级名称(例如,-2018-Math-1BE)?

时间:2019-05-12 05:48:38

标签: python odoo erp

class EducationStudentsAttendance(models.Model):
    _name = 'education.attendances'

name = fields.Char(compute='get_name', string='Attendance Sheet Name', default='New')
    # class_id = fields.Many2one('education.class', string='Class')
    class_division = fields.Many2one('education.class.division', string='Class', required=True)
    date = fields.Date(string='Date', default=fields.Date.today, required=True)
    attendance_line = fields.One2many('education.attendances.line', 'attendance_id', string='Attendance Line')
    attendance_created = fields.Boolean(string='Attendance Created')
    state = fields.Selection([('draft', 'Draft'), ('done', 'Done')], default='draft')
    academic_year = fields.Many2one('education.academic.year', string='Academic Year',
                                    related='class_division.academic_year_id', store=True)

    # add fields to relate timetable
    week_day = fields.Char('Week Day')
    subject = fields.Many2one('education.subject', string='Subject', required=True)

“”“这里在时间表中创建时如何获得class_division?”“”

1 个答案:

答案 0 :(得分:1)

您可以使用Onchange API来做到这一点 看到这个例子

    @api.onchange('date')
    def set_name(self):
        self.name = ('Your Text %s - %s') % (self.date, self.subject )