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