From 4a51fad2d58e60a4c4fe1a24ea71d3e7589049bf Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Wed, 10 Jul 2019 08:47:06 +0000 Subject: [PATCH] [FIX] hr: Load the public views on load_views if no access to employees Purpose ======= On a many2many targeting the hr.employee model, if the user has no access rights to the hr.employee model, clicking on a record of the many2many will lead to a traceback. Specification ============= It's because load_views, called by the web client, will try to load the form view on the hr.employee model. Overriding the method to load the public employee form view instead if the user has no read access is sufficient to solve the issue. We could have overriden the methods fields_view_get and fields_get, but it doesn't seem necessary yet. closes odoo/odoo#34724 Signed-off-by: Yannick Tivisse (yti) --- addons/hr/models/hr_employee.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/hr/models/hr_employee.py b/addons/hr/models/hr_employee.py index ccd48fe0611..c24075bf35f 100644 --- a/addons/hr/models/hr_employee.py +++ b/addons/hr/models/hr_employee.py @@ -147,6 +147,12 @@ class HrEmployeePrivate(models.Model): raise AccessError(_('The fields "%s" you try to read is not available on the public employee profile.') % (','.join(private_fields))) return self.env['hr.employee.public'].browse(self.ids).read(fields, load=load) + @api.model + def load_views(self, views, options=None): + if self.check_access_rights('read', raise_exception=False): + return super(HrEmployeePrivate, self).load_views(views, options=options) + return self.env['hr.employee.public'].load_views(views, options=options) + @api.model def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None): """