[FIX] sale: set timesheet line to zero

- Create a SO with a product that is a service and will be invoiced
  based in delivery quantities and will be tracked on timesheets and
  contract.
- Confirm
- Use a simple user that only has for rights: "Employee"
- Create a timesheet as the employee for the contract created by the sale
- Log some time
- Save it
- Check the SO: ok the number of hours should be "to be invoiced"
- Edit the timesheet and set one day to 0 hours => Access Error

In case of a zero value, the timesheet widget sends an unlink command
for the corresponding entry. In this case, the `sudo` is not set at the
appropropriate moment since the context key `force_so_lines` will resue
lines which are not defined in the `sudo` environment.

opw-728453
This commit is contained in:
Nicolas Martinelli
2017-04-18 11:55:16 +02:00
parent 2c75ad396f
commit b4193cd35b
+2 -2
View File
@@ -150,7 +150,7 @@ class AccountAnalyticLine(models.Model):
@api.multi
def unlink(self):
so_lines = self.mapped('so_line')
so_lines = self.sudo().mapped('so_line')
res = super(AccountAnalyticLine, self).unlink()
so_lines.with_context(force_so_lines=so_lines).sudo()._compute_analytic()
so_lines.with_context(force_so_lines=so_lines)._compute_analytic()
return res