From cae70abe8d9990bed49a70399774de8f82cdabde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Wed, 27 Apr 2016 21:10:54 +0200 Subject: [PATCH] [IMP] contract_show_invoice: more lightweight solution (#31) [IMP] contract_show_invoice: more lightweight solution In order to implement the button, it's not necessary to have a heavy stored computed field. So I propose to remove it. --- contract_show_invoice/README.rst | 2 +- contract_show_invoice/__init__.py | 1 - contract_show_invoice/__openerp__.py | 7 ++-- .../i18n/contract_invoices_button.pot | 9 ++--- contract_show_invoice/models/__init__.py | 2 -- contract_show_invoice/models/invoice.py | 19 ---------- .../test/contract_show_invoice_test.yml | 35 ------------------- contract_show_invoice/views/contract_view.xml | 6 ++-- 8 files changed, 7 insertions(+), 74 deletions(-) delete mode 100644 contract_show_invoice/models/__init__.py delete mode 100644 contract_show_invoice/models/invoice.py delete mode 100644 contract_show_invoice/test/contract_show_invoice_test.yml diff --git a/contract_show_invoice/README.rst b/contract_show_invoice/README.rst index 9f1fc92e..b143ce0d 100644 --- a/contract_show_invoice/README.rst +++ b/contract_show_invoice/README.rst @@ -40,7 +40,7 @@ Contributors ------------ * Ángel Moya - +* Stéphane Bidoul Maintainer ---------- diff --git a/contract_show_invoice/__init__.py b/contract_show_invoice/__init__.py index a0fdc10f..40a96afc 100644 --- a/contract_show_invoice/__init__.py +++ b/contract_show_invoice/__init__.py @@ -1,2 +1 @@ # -*- coding: utf-8 -*- -from . import models diff --git a/contract_show_invoice/__openerp__.py b/contract_show_invoice/__openerp__.py index f7f773c4..2efb2611 100644 --- a/contract_show_invoice/__openerp__.py +++ b/contract_show_invoice/__openerp__.py @@ -22,17 +22,14 @@ { 'name': 'Contract Show Invoice', 'summary': 'Button in contracts to show their invoices', - 'version': '8.0.1.0.0', - 'author': 'Domatix, Odoo Community Association (OCA)', + 'version': '8.0.2.0.0', + 'author': 'Domatix,Odoo Community Association (OCA)', 'website': 'http://www.domatix.com', 'depends': ['account_analytic_analysis'], 'category': 'Sales Management', 'data': [ 'views/contract_view.xml', ], - 'test': [ - 'test/contract_show_invoice_test.yml' - ], 'installable': True, 'auto_install': False, } diff --git a/contract_show_invoice/i18n/contract_invoices_button.pot b/contract_show_invoice/i18n/contract_invoices_button.pot index 6341c066..a6ef757b 100644 --- a/contract_show_invoice/i18n/contract_invoices_button.pot +++ b/contract_show_invoice/i18n/contract_invoices_button.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-10-01 07:58+0000\n" -"PO-Revision-Date: 2015-10-01 07:58+0000\n" +"POT-Creation-Date: 2016-04-13 12:35+0000\n" +"PO-Revision-Date: 2016-04-13 12:35+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,11 +15,6 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" -#. module: contract_show_invoice -#: field:account.invoice,analytic_account_ids:0 -msgid "Contracts" -msgstr "" - #. module: contract_show_invoice #: model:ir.model,name:contract_show_invoice.model_account_invoice msgid "Invoice" diff --git a/contract_show_invoice/models/__init__.py b/contract_show_invoice/models/__init__.py deleted file mode 100644 index 78d96a03..00000000 --- a/contract_show_invoice/models/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from . import invoice diff --git a/contract_show_invoice/models/invoice.py b/contract_show_invoice/models/invoice.py deleted file mode 100644 index e3d3efb0..00000000 --- a/contract_show_invoice/models/invoice.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -from openerp import models, fields, api - - -class AccountInvoice(models.Model): - _inherit = 'account.invoice' - - @api.one - @api.depends('invoice_line.account_analytic_id') - def _analytic_account_ids(self): - self.analytic_account_ids = \ - self.mapped('invoice_line.account_analytic_id') - - analytic_account_ids = fields.Many2many( - comodel_name='account.analytic.account', - compute='_analytic_account_ids', - store=True, - string='Contracts') diff --git a/contract_show_invoice/test/contract_show_invoice_test.yml b/contract_show_invoice/test/contract_show_invoice_test.yml deleted file mode 100644 index b0174271..00000000 --- a/contract_show_invoice/test/contract_show_invoice_test.yml +++ /dev/null @@ -1,35 +0,0 @@ -- - In order to test Contract Invoices Button I create a new Contract -- - !record {model: account.analytic.account, id: contract_main}: - name: Maintenance of Servers - company_id: base.main_company - partner_id: base.main_partner - type: contract - recurring_invoices : 1 - recurring_interval : 1 - recurring_invoice_line_ids: - - quantity: 2.0 - price_unit: 100.0 - name: Database Administration 25 - product_id: product.product_product_consultant - uom_id: product.product_uom_hour -- - I test the invoices button -- - !python {model: account.invoice}: | - contract_id = ref('contract_show_invoice.contract_main') - invoices = self.search(cr, uid,[('analytic_account_ids','=',contract_id)],context=context) - assert len(invoices) == 0, "No invoices related this contract, but get (%s)"%(invoices,) -- - I generate all invoices from contracts having recurring invoicing -- - !python {model: account.analytic.account}: | - self.recurring_create_invoice(cr, uid, []) -- - I test the invoices button -- - !python {model: account.invoice}: | - contract_id = ref('contract_show_invoice.contract_main') - invoices = self.search(cr, uid,[('analytic_account_ids','=',contract_id)],context=context) - assert len(invoices) == 1, "Must have one invoice related this contract, but get (%s)"%(invoices,) \ No newline at end of file diff --git a/contract_show_invoice/views/contract_view.xml b/contract_show_invoice/views/contract_view.xml index e89fa445..ae29e9c6 100644 --- a/contract_show_invoice/views/contract_view.xml +++ b/contract_show_invoice/views/contract_view.xml @@ -3,11 +3,9 @@ - {'search_default_analytic_account_ids': - [active_id], 'default_analytic_account_ids': active_id} Invoices account.invoice - [('analytic_account_ids','=',active_id)] + [('invoice_line.account_analytic_id','=',active_id)] @@ -28,4 +26,4 @@ - \ No newline at end of file +