I am a newbie to python and odoo. I am developing a custom module to implement student application for a school. My primary aim is to collect application data. I have 3 models for this.
class ApApplicationsModel(models.Model):
_name = 'ap.applications.model'
class ApPrevSchoolModel(models.Model):
_name = 'ap.prevschool.model'
class ApPersonModel(models.Model):
_name = 'ap.person.model'
_inherit = 'op.student'
ApPersonModel will be used to store the details of student, parent and guardian. To this effect i have an invisible selection attribute ap_persontype
3 many2one links have been defined in the
ap_father_id = fields.Many2one('ap.person.model','Father Details', readonly=False,related='ap_prevschool_model.ap_name', store=True)
ap_mother_id = fields.Many2one('ap.person.model','Mother Details', readonly=False)
ap_student_id = fields.Many2one('ap.person.model','Student Details')
I have a field
ap_persontype = fields.Selection(
[('student','Student'),('parent','Parent'),('grd','Guardian')], 'Person Type',default='student', track_visibility='onchange')
in ap.person.model
I want to set the type of person to 'student' or 'parent' or 'guardian' as the form view gets initiated to show and hide some fields.
How do i do this ?
It mayn't be a good oo practice to deal like this. How do i then achieve it ?