From b730de1978827bbeda7eef4c4e933e625f1ef02d Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Mon, 19 Feb 2018 13:19:44 +0100 Subject: [PATCH] [FIX] hr_expense: correctly set address_id for restricted user New rights were applied on hr.employee with this commit https://github.com/odoo/odoo/commit/2d777d5ade94f4a80862608e2807660f289d9923 Since, users with limited rights would see a read error when submitting an expense to manager. Indeed, when clicking on "SUBMIT TO MANAGER", it opens the view form for 'hr.expense.sheet' that trigger an onchange on employee_id to set the employee's private address to the expense. Since restricted users can't read that field, the rpc call to that onchange was throwing an error resulting in: 1. Showing an read error when entering form view that user could close to save anyway. 2. The hr.expense.sheet address would not be set as it should have Now, we give sudo rights to read that field during the onchange OPW-815786 --- addons/hr_expense/models/hr_expense.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 67a00f606b6..ee9740a969b 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -512,7 +512,7 @@ class HrExpenseSheet(models.Model): @api.onchange('employee_id') def _onchange_employee_id(self): - self.address_id = self.employee_id.address_home_id + self.address_id = self.employee_id.sudo().address_home_id self.department_id = self.employee_id.department_id @api.one