[FIX] account_analytic_default_hr_expense: access rights

Before this commit, when user has no extra access rights, clicking on
create in Expense raises an Access Right Error.

This fix solves the issue by sudoing the access on
account.analytic.default in the onchange method causing the error.

Task-2069060

closes odoo/odoo#36572

Signed-off-by: Jérome Maes (jem) <jem@openerp.com>
This commit is contained in:
Geoffroy Larue
2019-09-09 14:19:37 +00:00
parent 9087332336
commit d43ede7882
@@ -10,7 +10,7 @@ class HrExpense(models.Model):
@api.onchange('product_id', 'date', 'account_id')
def _onchange_product_id(self):
res = super(HrExpense, self)._onchange_product_id()
rec = self.env['account.analytic.default'].account_get(product_id=self.product_id.id, account_id=self.account_id.id, company_id=self.company_id.id, date=self.date)
rec = self.env['account.analytic.default'].sudo().account_get(product_id=self.product_id.id, account_id=self.account_id.id, company_id=self.company_id.id, date=self.date)
self.analytic_account_id = rec.analytic_id.id
self.analytic_tag_ids = rec.analytic_tag_ids.ids
return res