From 26b851e54139f1385d811d5cd7fef29af3cb5de7 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse <yti@odoo.com> Date: Fri, 5 May 2017 11:03:58 +0200 Subject: [PATCH] [IMP] sale_timesheet: Move timesheet_revenue computation in a separate method Will be used in migration scripts to saas~16 to compute this value for all the invoices that have been validated --- addons/sale_timesheet/models/account_invoice.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/sale_timesheet/models/account_invoice.py b/addons/sale_timesheet/models/account_invoice.py index 2aabf31ac63e..13de1c8c843f 100644 --- a/addons/sale_timesheet/models/account_invoice.py +++ b/addons/sale_timesheet/models/account_invoice.py @@ -48,7 +48,10 @@ class AccountInvoice(models.Model): @api.multi def invoice_validate(self): result = super(AccountInvoice, self).invoice_validate() + self._compute_timesheet_revenue() + return result + def _compute_timesheet_revenue(self): for invoice in self: for invoice_line in invoice.invoice_line_ids.filtered(lambda line: line.product_id.type == 'service'): uninvoiced_timesheet_lines = self.env['account.analytic.line'].sudo().search([ @@ -104,5 +107,3 @@ class AccountInvoice(models.Model): 'timesheet_invoice_id': invoice.id, 'timesheet_revenue': float_round(line_revenue, precision), }) - - return result -- GitLab