Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
8287 Lượt xem

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")
Ảnh đại diện
Huỷ bỏ

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

Tác giả

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.

Câu trả lời hay nhất

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)

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 24
1659
1
thg 7 22
2453
0
thg 2 22
2482
3
thg 9 25
3209
0
thg 8 25
765