diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-02-02 15:01:47 +0100 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2018-02-02 16:08:00 +0100 |
| commit | 63c39c74605a9458de4e7a8a2a2f3821e55843ba (patch) | |
| tree | 1dd22217f078653321286f83b20f3fbf28730819 | |
| parent | 3e91cbf47d62be945583d79ec9b7fd23e424a28f (diff) | |
[FIX] hr: soft-prevent read of employees forbidden field
Before this commit, when having a simple employee (group employee) accessing the form view
of hr.employee, there was traceback because the field is_address_home_a_company was not in the view
This is because of commit 2d777d5
which restricted this field to the group_hr_user (Officer) in Python
When the view itself is not group-restricted
The JS loads everything from the view but puts invisible=1 on sections that have a group
The field, in our case, is forbidden before that and is not loaded, whereas the domain in which it is used is loaded
After this commit, the view loads correctly, while avoiding leaks as intended
OPW 813721
| -rw-r--r-- | addons/hr/models/hr.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/addons/hr/models/hr.py b/addons/hr/models/hr.py index 2bcfddd39d1..b34fcc99502 100644 --- a/addons/hr/models/hr.py +++ b/addons/hr/models/hr.py @@ -5,7 +5,7 @@ import logging from odoo import api, fields, models from odoo import tools, _ -from odoo.exceptions import ValidationError +from odoo.exceptions import ValidationError, AccessError from odoo.modules.module import get_module_resource _logger = logging.getLogger(__name__) @@ -116,7 +116,6 @@ class Employee(models.Model): is_address_home_a_company = fields.Boolean( 'The employee adress has a company linked', compute='_compute_is_address_home_a_company', - groups="hr.group_hr_user", ) country_id = fields.Many2one( 'res.country', 'Nationality (Country)', groups="hr.group_hr_user") @@ -271,7 +270,11 @@ class Employee(models.Model): """Checks that choosen address (res.partner) is not linked to a company. """ for employee in self: - employee.is_address_home_a_company = employee.address_home_id.parent_id.id is not False + try: + employee.is_address_home_a_company = employee.address_home_id.parent_id.id is not False + except AccessError: + employee.is_address_home_a_company = False + class Department(models.Model): _name = "hr.department" |
