How to use related field to set an attribute of a many2one object?
<p>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.</p>

<pre><code>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'
</code></pre>

<p>ApPersonModel will be used to store the details of student, parent and guardian. To this effect i have an invisible selection attribute ap_persontype</p>

<p>3 many2one links have been defined in the </p>

<pre><code>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')
</code></pre>

<p>I have a field </p>

<pre><code>ap_persontype = fields.Selection(
        [('student','Student'),('parent','Parent'),('grd','Guardian')],  'Person Type',default='student', track_visibility='onchange') 
</code></pre>

<p>in ap.person.model</p>

<p>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. </p>

<p>How do i do this ?</p>

<p>It mayn't be a good oo practice to deal like this. How do i then achieve it ?</p>