[FIX] sale_expense: expense count of SO should be compute in sudo

Without this commit, reading all fields of sales
order will raise an access error if user does not
have access to hr.expense documents. An since
the expense count is displayed on the form view, this
can be annoying.
This commit makes the computation of the expense
count done by 'sudo', as there is not critical
informations at stake.
This commit is contained in:
jem-odoo
2018-05-22 11:52:19 +02:00
parent b637b5aeb8
commit dafb9b2638
+1 -1
View File
@@ -8,7 +8,7 @@ class SaleOrder(models.Model):
_inherit = 'sale.order'
expense_ids = fields.One2many('hr.expense', 'sale_order_id', string='Expenses', domain=[('state', '=', 'done')], readonly=True, copy=False)
expense_count = fields.Integer("# of Expenses", compute='_compute_expense_count')
expense_count = fields.Integer("# of Expenses", compute='_compute_expense_count', compute_sudo=True)
@api.multi
@api.depends('expense_ids')