class DepartmentInfo(models.Model):
_name = "department.info"
_description = "Department Details"
_rec_name = "department_name"
_inherit = ["mail.thread", "mail.activity.mixin"]
department_name = fields.Char(string="Department Name")
department_code = fields.Integer(string="Department Code")
department_hod_name = fields.Char(string="Head Of Department")
employee_ids = fields.One2many(
comodel_name="employee.info", inverse_name="department_id", string="Employees"
)
def sc_create(self):
print(self)
self.create(
{
"employee_ids": [(0,0,"first_name":f"TEMP{self.id}","department_id":self,},)]
})
the department_id of the newly created record is empty