mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] contract_show_invoice: ADD total invoiced in show invoices button (#181)
This commit is contained in:
committed by
Pedro M. Baeza
parent
f944b485c7
commit
8a5de59ada
@@ -20,11 +20,6 @@ For further information, please visit:
|
|||||||
|
|
||||||
* https://www.odoo.com/forum/help-1
|
* https://www.odoo.com/forum/help-1
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
* Add field with the total amount invoiced to the invoices button.
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
@@ -42,6 +37,7 @@ Contributors
|
|||||||
* Ángel Moya <angel.moya@domatix.com>
|
* Ángel Moya <angel.moya@domatix.com>
|
||||||
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
* Dave Burkholder <dave@thinkwelldesigns.com>
|
* Dave Burkholder <dave@thinkwelldesigns.com>
|
||||||
|
* Alberto Martín - Guadaltech <alberto.martin@guadaltech.es>
|
||||||
|
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from . import invoice
|
from . import invoice
|
||||||
|
from . import account_analytic_account
|
||||||
|
|||||||
22
contract_show_invoice/models/account_analytic_account.py
Normal file
22
contract_show_invoice/models/account_analytic_account.py
Normal 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')
|
||||||
@@ -26,3 +26,7 @@ class TestContractShowInvoice(TransactionCase):
|
|||||||
|
|
||||||
def test_contract_show_invoice(self):
|
def test_contract_show_invoice(self):
|
||||||
self.assertEqual(len(self.analytic_account.analytic_account_ids), 1)
|
self.assertEqual(len(self.analytic_account.analytic_account_ids), 1)
|
||||||
|
|
||||||
|
def test_contract_total_invoiced(self):
|
||||||
|
self.assertEqual(self.invoice.amount_total,
|
||||||
|
self.analytic_account.total_invoiced)
|
||||||
|
|||||||
@@ -33,7 +33,14 @@
|
|||||||
<xpath expr='//div[@name="button_box"]' position='inside'>
|
<xpath expr='//div[@name="button_box"]' position='inside'>
|
||||||
<button class="oe_stat_button" type="action" icon="fa-edit"
|
<button class="oe_stat_button" type="action" icon="fa-edit"
|
||||||
name="%(contract_show_invoice.act_analytic_invoices)d"
|
name="%(contract_show_invoice.act_analytic_invoices)d"
|
||||||
string="Invoices" help="Invoices related with this contract">
|
help="Invoices related with this contract">
|
||||||
|
<div class="o_form_field o_stat_info">
|
||||||
|
<span class="o_stat_value">
|
||||||
|
<field name="total_invoiced" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
|
</span>
|
||||||
|
<span class="o_stat_text">Invoiced</span>
|
||||||
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user