The operation cannot be completed: another model requires the record
being deleted. If possible, archive it instead. Model: Employee
(hr.employee), Constraint: hr_employee_iwave_category_id_fkey
class HrEmployeeTag(models.Model):
_inherit = "hr.employee"
iwave_category_id = fields.Many2one("hr.employee.category", compute="compute_iwave_category_id", store=True,
ondelete="cascade")
category_ids = fields.Many2many(default="_get_category_ids_value")
@api.depends('iwave_Experience')
def compute_iwave_category_id(self):
for rec in self:
if rec.iwave_Experience >= 1:
self.iwave_category_id = 1
if rec.iwave_Experience >= 2:
self.iwave_category_id = 2
if rec.iwave_Experience >= 3:
self.iwave_category_id = 3
@api.onchange('iwave_Experience')
def _get_category_ids_value(self):
for rec in self:
if rec.iwave_Experience < 1:
rec.write({'category_ids': [6, 0, 'category_ids']})
rec.category_ids = rec.iwave_category_id
if rec.iwave_Experience >= 1:
rec.write({'category_ids': [6, 0, 'category_ids']})
rec.category_ids = rec.iwave_category_id
if rec.iwave_Experience >= 2:
rec.write({'category_ids': [6, 0, 'category_ids']})
rec.category_ids = rec.iwave_category_id
if rec.iwave_Experience >= 3:
rec.write({'category_ids': [6, 0, 'category_ids']})
rec.category_ids = rec.iwave_category_id
else:
rec.category_ids = False
how to solve this error.