summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Baptiste <kba@odoo.com>2020-06-29 06:47:57 +0000
committerKevin Baptiste <kba@odoo.com>2020-08-14 09:43:40 +0000
commitea1fa673c858c74a1e408ab09d6f3533171253b6 (patch)
treece2a6de9b16d82c00405594ec5b1ffe5f084911c
parent40146bff7f68c71ddca65b3d14497565750f2fa1 (diff)
[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>
-rw-r--r--addons/sale_timesheet/models/account.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py
index b933b65363f..c14767aacbf 100644
--- a/addons/sale_timesheet/models/account.py
+++ b/addons/sale_timesheet/models/account.py
@@ -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.'))