Skip to Content
Menu
This question has been flagged
2 Replies
2651 Views

My View .xml is
        <record id="student_menu_action" model="ir.actions.act_window">
            <field name="name">Students</field>
            <field name="res_model">student.student</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[]</field>
            <field name="help" type="html">
                <p class="oe_view_nocontent_create">Create The First Student
                </p>
            </field>
</record>
        <record id="teacher_menu_action" model="ir.actions.act_window">
            <field name="name">Teachers</field>
            <field name="res_model">student.teacher</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[]</field>
            <field name="help" type="html">
                <p class="oe_view_nocontent_create">Create The First Teacher
                </p>
            </field>

and Menu item is:-

<menuitem id="school_menu"
    name="School"/>

<menuitem id="student_menu"
    name="Student Details"
    parent="school_menu"/>
       
<menuitem id="school_student_menu"
                  parent="student_menu"
                  name="Student"
                  action="student_menu_action"/>
<menuitem id="teacher_menu"
    name="Teacher Details"
    parent="school_menu"/>

<menuitem id="school_teacher_menu"
                  parent="teacher_menu"
                  name="Teacher"
                  action="teacher_menu_action"/>


And my model is :-

class StudentStudent(models.Model):
    _name = 'student.student'

    name = fields.Char(string='Name', required=True)
    age = fields.Integer(string='Age')
    photo = fields.Binary(string='Image')
    gender = fields.Selection([('male', 'Male'), ('female', 'Female'), ('others', 'Others')], string='Gender')
    student_dob = fields.Date(string="Date of Birth")
    student_blood_group = fields.Selection(
        [('A+', 'A+ve'), ('B+', 'B+ve'), ('O+', 'O+ve'), ('AB+', 'AB+ve'),
         ('A-', 'A-ve'), ('B-', 'B-ve'), ('O-', 'O-ve'), ('AB-', 'AB-ve')],
        string='Blood Group')
    nationality = fields.Many2one('res.country', string='Nationality')

class TeacherTeacher(models.Model):
    _name = 'student.teacher'

    nametr = fields.Char(string='Name', required=True)
    agetr = fields.Integer(string='Age')
    phototr = fields.Binary(string='Image')
    gendertr = fields.Selection([('male', 'Male'), ('female', 'Female'), ('others', 'Others')], string='Gender')
    teacher_dob = fields.Date(string="Date of Birth")
    teacher_blood_group = fields.Selection(
        [('A+', 'A+ve'), ('B+', 'B+ve'), ('O+', 'O+ve'), ('AB+', 'AB+ve'),
         ('A-', 'A-ve'), ('B-', 'B-ve'), ('O-', 'O-ve'), ('AB-', 'AB-ve')],
        string='Blood Group')
    nationalitytr = fields.Many2one('res.country', string='Nationality')

when selecting a menu from Teacher under parent menu Teacher Details the Heading contails

Name/student.teacher,1 instead of name of student


Avatar
Discard
Best Answer

You need to define the _rec_name on your model teacher.

By default is use the 'name' field... but in your case there are no field name

https://www.odoo.com/documentation/8.0/reference/orm.html?#openerp.models.Model._name



btw your model seems the same... 

why not just have the same field for all, and a selection "Teacher/Student" ;) but it is not the debate here

Avatar
Discard
Best Answer

hello,

there are many ways to achieve, you can use any one from below options.

1. use _rec_name = 'your_fieldname' for getting the name instead of student.teacher(1)

2. you have the column 'name'.

3. you can also achive your goal using override the name_get().

Avatar
Discard
Author

Thank you:)