From a7985a5abb49326991a97c707611bb3670dbfdd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Thu, 10 Aug 2017 14:52:49 +0200 Subject: [PATCH] [FIX] sale_timesheet: revenue computation with sudo() Since the revenue computation is an automatic system action, it should be done in sudo(). This avoid access error. Indeed, if a company creates and confirms a SO, a task can be created in another company project. Logging timesheet from the project company is thus impossible since the user can not access SO line of the origin company. Adding sudo() seems better than givin read access to 'all' so line for timesheet user. --- addons/sale_timesheet/models/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py index 155246b1c0c..81697e4607b 100644 --- a/addons/sale_timesheet/models/account.py +++ b/addons/sale_timesheet/models/account.py @@ -103,7 +103,7 @@ class AccountAnalyticLine(models.Model): # set the revenue and billable type according to the product and the SO line so_line_id = values.get('so_line') or self.so_line.id - so_line = self.env['sale.order.line'].browse(so_line_id) if so_line_id else self.env['sale.order.line'].browse() + so_line = self.env['sale.order.line'].browse(so_line_id).sudo() if so_line_id else self.env['sale.order.line'].browse().sudo() if so_line.product_id.type == 'service': # find the analytic account to convert revenue into its currency account_id = values.get('account_id') or self.account_id.id