[FIX] hr_holidays: Call onchange parent_id

Currently, parent_id is defined on hr.employee. This field
as an onchange defined.

But the inherit of hr.employee.base in the leave module
adds an onchange('parent_id'). The onchange method is never
called because the onchange in hr.employee does not call super
(which it's not supposed to do because the parent model
does not have the parent_id field).

To fix the issue, parent_id and all its onchange methods
are now defined on hr.employee.base
This commit is contained in:
Lucas Lefèvre
2019-09-20 09:23:27 +00:00
parent fa172f2e4d
commit 79228dd4d0
2 changed files with 9 additions and 9 deletions
-9
View File
@@ -97,9 +97,7 @@ class HrEmployeePrivate(models.Model):
image_1920 = fields.Image(default=_default_image)
phone = fields.Char(related='address_home_id.phone', related_sudo=False, string="Private Phone", groups="hr.group_hr_user")
# employee in company
parent_id = fields.Many2one('hr.employee', 'Manager', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
child_ids = fields.One2many('hr.employee', 'parent_id', string='Direct subordinates')
coach_id = fields.Many2one('hr.employee', 'Coach', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
category_ids = fields.Many2many(
'hr.employee.category', 'employee_category_rel',
'emp_id', 'category_id', groups="hr.group_hr_manager",
@@ -196,13 +194,6 @@ class HrEmployeePrivate(models.Model):
if employee.pin and not employee.pin.isdigit():
raise ValidationError(_("The PIN must be a sequence of digits."))
@api.onchange('parent_id')
def _onchange_parent_id(self):
manager = self.parent_id
previous_manager = self._origin.parent_id
if manager and (self.coach_id == previous_manager or not self.coach_id):
self.coach_id = manager
@api.onchange('job_id')
def _onchange_job_id(self):
if self.job_id:
+9
View File
@@ -26,6 +26,8 @@ class HrEmployeeBase(models.AbstractModel):
user_id = fields.Many2one('res.users')
resource_id = fields.Many2one('resource.resource')
resource_calendar_id = fields.Many2one('resource.calendar', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
parent_id = fields.Many2one('hr.employee', 'Manager', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
coach_id = fields.Many2one('hr.employee', 'Coach', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
tz = fields.Selection(
string='Timezone', related='resource_id.tz', readonly=False,
help="This field is used in order to define in which timezone the resources will work.")
@@ -72,3 +74,10 @@ class HrEmployeeBase(models.AbstractModel):
else:
employee.last_activity = False
employee.last_activity_time = False
@api.onchange('parent_id')
def _onchange_parent_id(self):
manager = self.parent_id
previous_manager = self._origin.parent_id
if manager and (self.coach_id == previous_manager or not self.coach_id):
self.coach_id = manager