[FIX] hr_expense: use correct employee model according to user group

A traceback occurs when clicking on Search More in the employee field of
expense if the user has no rights on employee

Steps to reproduce:
1. Install Expenses
2. Go to Settings > General Settings > Users and click on Manage Users
3. Open user Mitchell Admin and remove all access rights on Employees
4. Go to Expenses and create a new expense
5. Click in the employee field, then on "Search More..." in the dropdown
6. An error occurs

Solution:
Depending on the group of the user, use 'hr.employee' or
'hr.employee.public' as done in https://github.com/odoo/odoo/commit/41eaff0f4c172a6018b0c8d9518d521c3832ef94

opw-3473418

closes odoo/odoo#138539

X-original-commit: 5d842587090b684786c3279d1ebe962ae57021b7
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
This commit is contained in:
MerlinGuillaume
2023-10-12 17:20:49 +00:00
parent f94c1ea65f
commit 36e98afb4f
+4 -3
View File
@@ -201,9 +201,10 @@
options="{'no_create': True}"/>
<field name="amount_tax"/>
</div>
<field name="employee_id" groups="hr_expense.group_hr_expense_team_approver"
context="{'default_company_id': company_id}" widget="many2one_avatar_user"
options="{'no_create': True}" readonly="not sheet_is_editable"/>
<t groups="hr_expense.group_hr_expense_team_approver">
<field name="employee_id" groups="!hr.group_hr_user" context="{'default_company_id': company_id}" widget="many2one_avatar_employee" options="{'relation': 'hr.employee.public', 'no_create': True}" readonly="not sheet_is_editable"/>
<field name="employee_id" groups="hr.group_hr_user" context="{'default_company_id': company_id}" widget="many2one_avatar_employee" options="{'relation': 'hr.employee', 'no_create': True}" readonly="not sheet_is_editable"/>
</t>
<label id="lo" for="payment_mode" invisible="product_has_cost"/>
<div id="payment_mode" invisible="product_has_cost">
<field name="payment_mode" widget="radio" readonly="sheet_id"/>