From e1cfee911e3140c1f6c01985418fcb7bbb324863 Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Fri, 19 Apr 2019 11:19:35 +0200 Subject: [PATCH 1/2] [IMP] get account journal default by sequence --- contract/__manifest__.py | 2 +- contract/models/account_analytic_contract.py | 3 ++- contract_show_invoice/__manifest__.py | 2 +- .../models/account_analytic_account.py | 12 +++++++----- contract_show_invoice/views/contract_view.xml | 13 ++++++++++++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/contract/__manifest__.py b/contract/__manifest__.py index 70ff7890..ff9e4260 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -9,7 +9,7 @@ { 'name': 'Contracts Management - Recurring', - 'version': '10.0.4.3.0', + 'version': '10.0.4.3.2', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "OpenERP SA, " diff --git a/contract/models/account_analytic_contract.py b/contract/models/account_analytic_contract.py index 6f04a9e5..3a1f9060 100644 --- a/contract/models/account_analytic_contract.py +++ b/contract/models/account_analytic_contract.py @@ -80,4 +80,5 @@ class AccountAnalyticContract(models.Model): domain = [ ('type', '=', 'sale'), ('company_id', '=', company_id)] - return self.env['account.journal'].search(domain, limit=1) + return self.env['account.journal'].search( + domain, order='sequence asc', limit=1) diff --git a/contract_show_invoice/__manifest__.py b/contract_show_invoice/__manifest__.py index e83890a0..77322f00 100644 --- a/contract_show_invoice/__manifest__.py +++ b/contract_show_invoice/__manifest__.py @@ -6,7 +6,7 @@ { 'name': 'Contract Show Invoice', 'summary': 'Button in contracts to show their invoices', - 'version': '10.0.1.0.1', + 'version': '10.0.1.0.2', 'license': 'AGPL-3', 'author': 'Domatix,' 'Tecnativa,' diff --git a/contract_show_invoice/models/account_analytic_account.py b/contract_show_invoice/models/account_analytic_account.py index 2ec2bad6..699e61e0 100644 --- a/contract_show_invoice/models/account_analytic_account.py +++ b/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') diff --git a/contract_show_invoice/views/contract_view.xml b/contract_show_invoice/views/contract_view.xml index 590e068e..5f26972d 100644 --- a/contract_show_invoice/views/contract_view.xml +++ b/contract_show_invoice/views/contract_view.xml @@ -6,7 +6,7 @@ [active_id], 'default_analytic_account_ids': [active_id]} Invoices account.invoice - [('analytic_account_ids','=',active_id)] + [('analytic_account_ids','=',active_id), ('type','in', ['out_invoice', 'out_refund']), ('state', 'not in', ['draft', 'cancel'])] @@ -24,6 +24,17 @@ + + account.invoice.tree.show.total.untaxed + account.invoice + + + + + + + + account.analytic.account.button.invoice From 7006eb0b92919d27d5ad86c6c88d5533a9157f35 Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Tue, 13 Aug 2019 15:18:23 +0200 Subject: [PATCH 2/2] [FIX] remove bump version --- contract/__manifest__.py | 2 +- contract_show_invoice/__manifest__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contract/__manifest__.py b/contract/__manifest__.py index ff9e4260..70ff7890 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -9,7 +9,7 @@ { 'name': 'Contracts Management - Recurring', - 'version': '10.0.4.3.2', + 'version': '10.0.4.3.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "OpenERP SA, " diff --git a/contract_show_invoice/__manifest__.py b/contract_show_invoice/__manifest__.py index 77322f00..e83890a0 100644 --- a/contract_show_invoice/__manifest__.py +++ b/contract_show_invoice/__manifest__.py @@ -6,7 +6,7 @@ { 'name': 'Contract Show Invoice', 'summary': 'Button in contracts to show their invoices', - 'version': '10.0.1.0.2', + 'version': '10.0.1.0.1', 'license': 'AGPL-3', 'author': 'Domatix,' 'Tecnativa,'