Skip to content
Snippets Groups Projects
user avatar
Victor Piryns (pivi) authored
Current behaviour:
In mobile view, if an user that doesn't have any rights over
"Employees", clicking on any of the Many2One `employee_id` (for ex:
when adding a timesheet on a task and clicking on the employee field),
for either the dropdown, or to the form view with the `external` button,
we get a stacktrace.

Expected behaviour:
We shouldn't be met with a stacktrace, if we don't have rights, we
should be redirected to the corresponding view for the `hr.employee.
public` model.

Steps to reproduce:
- Install Timesheets
- Set Marc Demo's Employee's right to `none/empty`, login as Marc
- In mobile view, go to Project > a task > open the timesheet sheet
- Click on Add or any of the present timesheets
- Click on employee field, either on it (redirect to the mobile
  kanban view of all employees) or to the right edge of it (redirect
  to the form view for the currently selected employee).
- Instead of being redirected, you are met with a stacktrace.

Reason for the problem:
Since the migration to Owl, there is an implicit consistency
expected between what is the requested model for said view, and the
model we get back from the server for said view. In general (for
example when in desktop view), usually we pass by an override of
`get_formview_action` which changes the model we are loading
front-end side depending on the access to the employee model. If
access, we load `hr.employee`, if no access, `hr.employee.public`.
But for mobile, we don't pass by an action, we just load a dialog,
and the `resModel` used for the dialog is based on the `relation` of
the `Many2OneField`, which is `hr.employee`. In that case when
`get_views` is being called, we receive a view with the model key
being `hr.employee.public`, which is inconsistent with what the
front-end requested (which is `hr.employee`) and we have a
stacktrace in owl.

Fix:
Override the `relation` property to the correct model in the
corresponding widget set on the template of the field, based on
available group. This relation is used to set the `resModel` when
opening the dialog.

Affected versions:
- 16.0
- saas-16.1
- saas-16.2
- saas-16.3
- master

opw-3269817

closes odoo/odoo#123217

Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
41eaff0f
History
Name Last commit Last update