I'm building a class model for my students model. Here is the code:
class Student(models.Model):
_name = 'res.student'
name = fields.Char(string="Nama Siswa", required=True)
address = fields.Char(string="Alamat Siswa", required=True)
phone = fields.Char(string="Nomor Telepon", required=True)
fathers_name = fields.Char(string="Nama Ayah")
mothers_name = fields.Char(string="Nama Ibu")
entry_year = fields.Char(string="Tahun Masuk", required=True)
expected_year = fields.Char(string="Tahun Keluar", required=True)
class_id = fields.Many2one("res.class", ondelete="set null", required=True)
major = fields.Selection([('default', 'Belum Ada'), ('science','IPA'), ('social','IPS'),], string="Jurusan", default="default")
entry_fee_ids = fields.One2many("entry.installment", "student_id")
yearly_fee_ids = fields.One2many("yearly.installment", "student_id")
class StudentClass(models.Model):
_name = 'res.class'
class_name = fields.Char(string="Class", required=True)
class_major = fields.Selection([('science', 'IPA'), ('social', 'IPS'), ('unset','Tidak Ada')], default='unset', required=True, string="Class Major")
student_ids = fields.One2many("res.student", "class_id")
class_total_student = fields.Integer(string="Total Students", readonly=True, default=0, compute="count_total_student", store=True)
When I install the Student Management App (which includes student model but not class model) odoo told me I got key error on class_id (FK for class model)
Can someone help shed a light?
Thanks in advance!
U need this in future: https://github.com/sehrishnaz/learnopenerp/wiki