diff --git a/addons/hr/i18n/hr.pot b/addons/hr/i18n/hr.pot index 09fb0c7b354..f485defd585 100644 --- a/addons/hr/i18n/hr.pot +++ b/addons/hr/i18n/hr.pot @@ -2568,6 +2568,12 @@ msgstr "" msgid "You cannot create recursive departments." msgstr "" +#. module: hr +#: code:addons/hr/models/hr_employee.py:0 +#, python-format +msgid "You do not have access to this document." +msgstr "" + #. module: hr #: code:addons/hr/models/res_config_settings.py:0 #, python-format diff --git a/addons/hr/models/hr_employee.py b/addons/hr/models/hr_employee.py index 5978a2ac7de..2f7166f3c93 100644 --- a/addons/hr/models/hr_employee.py +++ b/addons/hr/models/hr_employee.py @@ -238,7 +238,10 @@ class HrEmployeePrivate(models.Model): """ if self.check_access_rights('read', raise_exception=False): return super(HrEmployeePrivate, self)._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid) - ids = self.env['hr.employee.public']._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid) + try: + ids = self.env['hr.employee.public']._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid) + except ValueError: + raise AccessError(_('You do not have access to this document.')) if not count and isinstance(ids, Query): # the result is expected from this table, so we should link tables ids = super(HrEmployeePrivate, self.sudo())._search([('id', 'in', ids)])