[IMP] sale_timesheet: return timesheets to merge

Add a method for timesheets that can be merged.

closes odoo/odoo#53779

Taskid: 2275778
Related: odoo/enterprise#11365
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Kevin Baptiste
2020-08-14 09:43:40 +00:00
parent 40146bff7f
commit ea1fa673c8
+4
View File
@@ -121,6 +121,10 @@ class AccountAnalyticLine(models.Model):
domain = super(AccountAnalyticLine, self)._timesheet_get_portal_domain()
return expression.AND([domain, [('timesheet_invoice_type', 'in', ['billable_time', 'non_billable'])]])
def _get_timesheets_to_merge(self):
res = super(AccountAnalyticLine, self)._get_timesheets_to_merge()
return res.filtered(lambda l: not l.timesheet_invoice_id or l.timesheet_invoice_id.state != 'posted')
def unlink(self):
if any(line.timesheet_invoice_id and line.timesheet_invoice_id.state == 'posted' for line in self):
raise UserError(_('You cannot remove a timesheet that has already been invoiced.'))