mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[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.
This commit is contained in:
committed by
Pedro M. Baeza
parent
560d199091
commit
653a891a3f
@@ -40,7 +40,7 @@ Contributors
|
||||
------------
|
||||
|
||||
* Ángel Moya <angel.moya@domatix.com>
|
||||
|
||||
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import models
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import invoice
|
||||
@@ -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')
|
||||
@@ -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,)
|
||||
@@ -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>
|
||||
@@ -28,4 +26,4 @@
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user