跳至内容
菜单
此问题已终结
1 回复
7875 查看

I have my class hrms.employee having a char field 'field_of_study' i need to relate it to co-model hrms.employee.education


class HrmsEmployee(models.Model):

    _name = "hrms.employee"

    _description = "Employee model for hrms module"

    field_of_study = fields.Char(string="Field of Study")

class HrmsEmployeeEducation(models.Model):
    _name = "hrms.employee.education"
    _description = "Employee Education Model for hrms Module"
    emp_id = fields.Many2one('hrms.employee')
    field = fields.Char(string="Field of Study",
                related="emp_id.field_of_study")
形象
丢弃

Code you have written seems to be correct. What problem you're facing?

编写者

image0image1

Field 'Field Of Study' from employee has the value but 'Field Of Study' from education model doesnt show anything.

Same happens to me. Idk what to do. I got the code exactly like you and i've been wondering the same for the past 8 hours at work.

最佳答案

Try deleting the quotation marks on the 'related' atribute, just like this:

field = fields.Char(string="Field of Study",
                related=emp_id.field_of_study)

形象
丢弃
相关帖文 回复 查看 活动
0
3月 24
1113
1
7月 22
2163
0
2月 22
1890
2
7月 25
2970
2
6月 25
1788