[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).
This commit is contained in:
jem-odoo
2018-05-04 13:22:11 +02:00
parent a3372ffa33
commit 37dab1bc07
+1 -1
View File
@@ -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)