|
|
@ -10,13 +10,15 @@ class AccountAnalyticAccount(models.Model): |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def _compute_total_invoiced(self): |
|
|
|
invoice_model = self.env['account.invoice'] |
|
|
|
invoice_line_model = self.env['account.invoice.line'] |
|
|
|
for analytic in self: |
|
|
|
fetch_data = invoice_model.read_group( |
|
|
|
[('invoice_line_ids.account_analytic_id', '=', analytic.id)], |
|
|
|
['amount_total'], [], |
|
|
|
fetch_data = invoice_line_model.read_group( |
|
|
|
[('account_analytic_id', '=', analytic.id), |
|
|
|
('invoice_id.state', 'in', ['open', 'paid']), |
|
|
|
('invoice_id.type', 'in', ['out_invoice', 'out_refund'])], |
|
|
|
['price_subtotal_signed'], [], |
|
|
|
) |
|
|
|
analytic.total_invoiced = fetch_data[0]['amount_total'] |
|
|
|
analytic.total_invoiced = fetch_data[0]['price_subtotal_signed'] |
|
|
|
|
|
|
|
total_invoiced = fields.Float(string="Total Invoiced", |
|
|
|
compute='_compute_total_invoiced') |