[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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user