You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
807 B

  1. # -*- coding: utf-8 -*-
  2. # © 2018 Alberto Martín Cortada - Guadaltech <alberto.martin@guadaltech.es>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from odoo import api, fields, models
  5. class AccountAnalyticAccount(models.Model):
  6. _inherit = 'account.analytic.account'
  7. @api.multi
  8. def _compute_total_invoiced(self):
  9. invoice_model = self.env['account.invoice']
  10. for analytic in self:
  11. fetch_data = invoice_model.read_group(
  12. [('invoice_line_ids.account_analytic_id', '=', analytic.id)],
  13. ['amount_total'], [],
  14. )
  15. analytic.total_invoiced = fetch_data[0]['amount_total']
  16. total_invoiced = fields.Float(string="Total Invoiced",
  17. compute='_compute_total_invoiced')