[FIX] hr_maintenance: fix singleton error in _compute_owner
avoid singleton error when accessing on multiple records
Iontroduced at 9a20c6556f
Closes #25379
This commit is contained in:
@@ -9,7 +9,7 @@ class MaintenanceEquipment(models.Model):
|
||||
employee_id = fields.Many2one('hr.employee', string='Assigned to Employee', track_visibility='onchange')
|
||||
department_id = fields.Many2one('hr.department', string='Assigned to Department', track_visibility='onchange')
|
||||
equipment_assign_to = fields.Selection(
|
||||
[('department', 'Department'), ('employee', 'Employee') ,('other', 'Other')],
|
||||
[('department', 'Department'), ('employee', 'Employee'), ('other', 'Other')],
|
||||
string='Used By',
|
||||
required=True,
|
||||
default='employee')
|
||||
@@ -82,10 +82,11 @@ class MaintenanceRequest(models.Model):
|
||||
|
||||
@api.depends('employee_id', 'department_id')
|
||||
def _compute_owner(self):
|
||||
if self.equipment_id.equipment_assign_to == 'employee':
|
||||
self.owner_user_id = self.employee_id.user_id.id
|
||||
elif self.equipment_id.equipment_assign_to == 'department':
|
||||
self.owner_user_id = self.department_id.manager_id.user_id.id
|
||||
for r in self:
|
||||
if r.equipment_id.equipment_assign_to == 'employee':
|
||||
r.owner_user_id = r.employee_id.user_id.id
|
||||
elif r.equipment_id.equipment_assign_to == 'department':
|
||||
r.owner_user_id = r.department_id.manager_id.user_id.id
|
||||
|
||||
@api.onchange('employee_id', 'department_id')
|
||||
def onchange_department_or_employee_id(self):
|
||||
|
||||
Reference in New Issue
Block a user