Reputation: 23
I have class:
class test(models.Models):
_name = "student"
.....
gender = fields.Selection([
('m', 'Male'),
('f', 'Female'),
('o', 'Other')
and I have class another one:
class get_Value(models.Models):
_name = "school"
student_id = fields.Many2one("module.test", string="Student")
gender = fields.Char(string="Gender", related="student_id.gender")
And odoo false.
Upvotes: 1
Views: 2166
Reputation: 523
your code should look like this:
Student:
class Student(models.Models):
_name = "modulename.student"
gender = fields.Selection([
('m', 'Male'),
('f', 'Female'),
('o', 'Other')
])
School:
class School(models.Models):
_name = "modulename.school"
student_id = fields.Many2one("modulename.student", string="Student")
gender = fields.Selection(string="Gender", related="student_id.gender")
modulename.modelname
)You can find more information here: https://www.odoo.com/documentation/14.0/developer/howtos/backend.html
Upvotes: 3
Reputation: 2825
You don't have to set another type of field for related fields, it should be the same, in this case selection
.
gender = fields.Selection(related="student_id.gender")
Upvotes: 0