[IMP] contract_show_invoice: ADD total invoiced in show invoices button (#181)

This commit is contained in:
Alberto Martín Cortada
2018-10-01 10:40:37 +02:00
committed by Pedro M. Baeza
parent f944b485c7
commit 8a5de59ada
5 changed files with 37 additions and 7 deletions

View File

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