Browse Source

Merge branch '10.0_fix_total_invoiced' of git+ssh://github.com/efatto/contract into 10.0

pull/315/head
sergiocorato 5 years ago
parent
commit
3dad78f415
  1. 12
      contract_show_invoice/models/account_analytic_account.py
  2. 13
      contract_show_invoice/views/contract_view.xml

12
contract_show_invoice/models/account_analytic_account.py

@ -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')

13
contract_show_invoice/views/contract_view.xml

@ -6,7 +6,7 @@
[active_id], 'default_analytic_account_ids': [active_id]}</field>
<field name="name">Invoices</field>
<field name="res_model">account.invoice</field>
<field name="domain">[('analytic_account_ids','=',active_id)]</field>
<field name="domain">[('analytic_account_ids','=',active_id), ('type','in', ['out_invoice', 'out_refund']), ('state', 'not in', ['draft', 'cancel'])]</field>
<field name="search_view_id" ref="account.view_account_invoice_filter" />
</record>
@ -24,6 +24,17 @@
<field name="act_window_id" ref="act_analytic_invoices"/>
</record>
<record id="invoice_tree_show_total_untaxed" model="ir.ui.view">
<field name="name">account.invoice.tree.show.total.untaxed</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_tree"/>
<field name="arch" type="xml">
<field name="amount_total_signed" position="after">
<field name="amount_untaxed_signed" sum="Total Untaxed"/>
</field>
</field>
</record>
<record id="account_analytic_account_button_invoice" model="ir.ui.view">
<field name="name">account.analytic.account.button.invoice
</field>

Loading…
Cancel
Save