Skip to Content
Menu
This question has been flagged
1 Reply
2897 Views
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.


Avatar
Discard
Best Answer

Try this:

iwave_category_id = fields.Many2one("hr.employee.category", compute="compute_iwave_category_id", store=True)

if you don't really need the delete.
Or you can tell us why you need that.


Avatar
Discard
Related Posts Replies Views Activity
2
Dec 24
3136
1
Dec 24
359
4
Nov 24
1368
1
Sep 24
1138
1
Sep 24
1206