[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
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user