Browse Source

[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.
pull/34/head
Stéphane Bidoul (ACSONE) 9 years ago
committed by Pedro M. Baeza
parent
commit
cae70abe8d
  1. 2
      contract_show_invoice/README.rst
  2. 1
      contract_show_invoice/__init__.py
  3. 5
      contract_show_invoice/__openerp__.py
  4. 9
      contract_show_invoice/i18n/contract_invoices_button.pot
  5. 2
      contract_show_invoice/models/__init__.py
  6. 19
      contract_show_invoice/models/invoice.py
  7. 35
      contract_show_invoice/test/contract_show_invoice_test.yml
  8. 4
      contract_show_invoice/views/contract_view.xml

2
contract_show_invoice/README.rst

@ -40,7 +40,7 @@ Contributors
------------
* Ángel Moya <angel.moya@domatix.com>
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
Maintainer
----------

1
contract_show_invoice/__init__.py

@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import models

5
contract_show_invoice/__openerp__.py

@ -22,7 +22,7 @@
{
'name': 'Contract Show Invoice',
'summary': 'Button in contracts to show their invoices',
'version': '8.0.1.0.0',
'version': '8.0.2.0.0',
'author': 'Domatix,Odoo Community Association (OCA)',
'website': 'http://www.domatix.com',
'depends': ['account_analytic_analysis'],
@ -30,9 +30,6 @@
'data': [
'views/contract_view.xml',
],
'test': [
'test/contract_show_invoice_test.yml'
],
'installable': True,
'auto_install': False,
}

9
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"

2
contract_show_invoice/models/__init__.py

@ -1,2 +0,0 @@
# -*- coding: utf-8 -*-
from . import invoice

19
contract_show_invoice/models/invoice.py

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

35
contract_show_invoice/test/contract_show_invoice_test.yml

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

4
contract_show_invoice/views/contract_view.xml

@ -3,11 +3,9 @@
<data>
<record id="act_analytic_invoices" model="ir.actions.act_window">
<field name="context">{'search_default_analytic_account_ids':
[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">[('invoice_line.account_analytic_id','=',active_id)]</field>
<field name="view_id" ref="account.invoice_tree" />
<field name="search_view_id" ref="account.view_account_invoice_filter" />
</record>

Loading…
Cancel
Save