[FIX]project_timesheet, sale: SO line not updated after timesheet is deleted

-Deleting some timesheets linked to a task created on a SO didn't update the delivred
quantity.

opw:697317
This commit is contained in:
Goffin Simon
2016-12-19 11:46:23 +01:00
parent 13063dd177
commit 4e60d28d00
+12
View File
@@ -18,6 +18,11 @@ class SaleOrderLine(models.Model):
domain,
['so_line', 'unit_amount', 'product_uom_id'], ['product_uom_id', 'so_line'], lazy=False
)
# If the unlinked analytic line was the last one on the SO line, the qty was not updated.
force_so_lines = self.env.context.get("force_so_lines")
if force_so_lines:
for line in force_so_lines:
lines.setdefault(line, 0.0)
for d in data:
if not d['product_uom_id']:
continue
@@ -124,3 +129,10 @@ class AccountAnalyticLine(models.Model):
line.with_context(create=True).write(res)
line.mapped('so_line').sudo()._compute_analytic()
return line
@api.multi
def unlink(self):
so_lines = self.mapped('so_line')
res = super(AccountAnalyticLine, self).unlink()
so_lines.with_context(force_so_lines=so_lines).sudo()._compute_analytic()
return res