From 7fee15258d90ffdd5cb49eb9aaad40b90dbf113c Mon Sep 17 00:00:00 2001 From: Barad Mahendra Date: Thu, 13 Aug 2020 05:40:39 +0000 Subject: [PATCH] [FIX] hr: Properly define the compute method to avoid access error Currently, Due to _compute_phones method when going to read the work_phone and mobile_phone from salary configurator then it will randomly failed on read access right for those two fields. So in this commit, Defined the _compute_phones method properly and remove the compute from mobile_phone as it's not computed anymore. TaskID: 2283753 Closes: #56205 --- addons/hr/models/hr_employee_base.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/hr/models/hr_employee_base.py b/addons/hr/models/hr_employee_base.py index 2c5b34db113..5c184aee5d1 100644 --- a/addons/hr/models/hr_employee_base.py +++ b/addons/hr/models/hr_employee_base.py @@ -25,7 +25,7 @@ class HrEmployeeBase(models.AbstractModel): address_id = fields.Many2one('res.partner', 'Work Address', compute="_compute_address_id", store=True, readonly=False, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]") work_phone = fields.Char('Work Phone', compute="_compute_phones", store=True, readonly=False) - mobile_phone = fields.Char('Work Mobile', compute="_compute_phones", store=True, readonly=False) + mobile_phone = fields.Char('Work Mobile') work_email = fields.Char('Work Email') work_location = fields.Char('Work Location') user_id = fields.Many2one('res.users') @@ -110,9 +110,11 @@ class HrEmployeeBase(models.AbstractModel): @api.depends('address_id') def _compute_phones(self): - for employee in self.filtered('address_id'): - if employee.address_id.phone: + for employee in self: + if employee.address_id and employee.address_id.phone: employee.work_phone = employee.address_id.phone + else: + employee.work_phone = False @api.depends('company_id') def _compute_address_id(self):