From 37dab1bc07c81bc98a48e98e52d7ec718c9dbbb4 Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Mon, 30 Apr 2018 15:15:07 +0200 Subject: [PATCH] [FIX] sale_timesheet: access error during onchange `compute_sudo=True` execute the compute method as super user, to avoid access error. This also allow to trigger other computation in cascade without being stopped by access right error if the system has job to do. However, during a onchange, the method is not executed as super user, so access error can raise. An explicit `sudo()`in the compute method is required, in addition to the 'compute_sudo` on the field (usefull when storing value). This commit avoid the problem when a user (that is no timesheet user) try to add a SO line the delivered qty is based on its related timesheets (analytic lines). --- addons/sale_timesheet/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_timesheet/models/sale_order.py b/addons/sale_timesheet/models/sale_order.py index cbaab9e9fa7..ffe78b9dd41 100644 --- a/addons/sale_timesheet/models/sale_order.py +++ b/addons/sale_timesheet/models/sale_order.py @@ -151,7 +151,7 @@ class SaleOrderLine(models.Model): lines_by_timesheet = self.filtered(lambda sol: sol.qty_delivered_method == 'timesheet') domain = lines_by_timesheet._timesheet_compute_delivered_quantity_domain() - mapping = lines_by_timesheet._get_delivered_quantity_by_analytic(domain) + mapping = lines_by_timesheet.sudo()._get_delivered_quantity_by_analytic(domain) for line in lines_by_timesheet: line.qty_delivered = mapping.get(line.id, 0.0)