mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] contract_show_invoice: Migrate to v9.0
* [MIG] contract_show_invoice: Migrate to v9.0
This commit is contained in:
committed by
Pedro M. Baeza
parent
34d4b9fa49
commit
7b167f5e0b
@@ -40,6 +40,7 @@ Contributors
|
|||||||
------------
|
------------
|
||||||
|
|
||||||
* Ángel Moya <angel.moya@domatix.com>
|
* Ángel Moya <angel.moya@domatix.com>
|
||||||
|
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
|
|||||||
@@ -1,38 +1,20 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2015 Angel Moya <angel.moya@domatix.com>
|
||||||
|
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2015 Domatix (<www.domatix.com>).
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
{
|
{
|
||||||
'name': 'Contract Show Invoice',
|
'name': 'Contract Show Invoice',
|
||||||
'summary': 'Button in contracts to show their invoices',
|
'summary': 'Button in contracts to show their invoices',
|
||||||
'version': '8.0.1.0.0',
|
'version': '9.0.1.0.0',
|
||||||
'author': 'Domatix, Odoo Community Association (OCA)',
|
'author': 'Domatix,'
|
||||||
|
'Tecnativa,'
|
||||||
|
'Odoo Community Association (OCA)',
|
||||||
'website': 'http://www.domatix.com',
|
'website': 'http://www.domatix.com',
|
||||||
'depends': ['account_analytic_analysis'],
|
'depends': ['account', 'analytic'],
|
||||||
'category': 'Sales Management',
|
'category': 'Sales Management',
|
||||||
'data': [
|
'data': [
|
||||||
'views/contract_view.xml',
|
'views/contract_view.xml',
|
||||||
],
|
],
|
||||||
'test': [
|
'installable': True,
|
||||||
'test/contract_show_invoice_test.yml'
|
|
||||||
],
|
|
||||||
'installable': False,
|
|
||||||
'auto_install': False,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
# Translation of Odoo Server.
|
|
||||||
# This file contains the translation of the following modules:
|
|
||||||
# * contract_show_invoice
|
|
||||||
#
|
|
||||||
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"
|
|
||||||
"Last-Translator: <>\n"
|
|
||||||
"Language-Team: \n"
|
|
||||||
"MIME-Version: 1.0\n"
|
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
|
||||||
"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"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: contract_show_invoice
|
|
||||||
#: view:account.analytic.account:contract_show_invoice.account_analytic_account_button_invoice
|
|
||||||
#: model:ir.actions.act_window,name:contract_show_invoice.act_analytic_invoices
|
|
||||||
msgid "Invoices"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: contract_show_invoice
|
|
||||||
#: view:account.analytic.account:contract_show_invoice.account_analytic_account_button_invoice
|
|
||||||
msgid "Invoices related with this contract"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
@@ -1,19 +1,24 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2015 Angel Moya <angel.moya@domatix.com>
|
||||||
|
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from openerp import models, fields, api
|
from openerp import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class AccountInvoice(models.Model):
|
class AccountInvoice(models.Model):
|
||||||
_inherit = 'account.invoice'
|
_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(
|
analytic_account_ids = fields.Many2many(
|
||||||
comodel_name='account.analytic.account',
|
comodel_name='account.analytic.account',
|
||||||
compute='_analytic_account_ids',
|
compute='_compute_analytic_account_ids',
|
||||||
store=True,
|
store=True,
|
||||||
string='Contracts')
|
string='Contracts')
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('invoice_line_ids.account_analytic_id')
|
||||||
|
def _compute_analytic_account_ids(self):
|
||||||
|
for invoice in self:
|
||||||
|
invoice.analytic_account_ids = invoice.mapped(
|
||||||
|
'invoice_line_ids.account_analytic_id'
|
||||||
|
)
|
||||||
|
|||||||
5
contract_show_invoice/test/__init__.py
Normal file
5
contract_show_invoice/test/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
|
|
||||||
|
from . import test_contract_show_invoice
|
||||||
@@ -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,)
|
|
||||||
28
contract_show_invoice/test/test_contract_show_invoice.py
Normal file
28
contract_show_invoice/test/test_contract_show_invoice.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
|
|
||||||
|
from openerp.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestContractShowInvoice(TransactionCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestContractShowInvoice, self).setUp()
|
||||||
|
self.analytic_account = self.env['account.analytic.account'].create({
|
||||||
|
'name': 'Test contract show invoice',
|
||||||
|
})
|
||||||
|
self.invoice = self.env['account.invoice'].create(
|
||||||
|
{'partner_id': self.env.ref('base.res_partner_2').id,
|
||||||
|
'type': 'out_invoice',
|
||||||
|
})
|
||||||
|
self.invoice._onchange_partner_id()
|
||||||
|
self.invoice_line = self.env['account.invoice.line'].create(
|
||||||
|
{'product_id': self.env.ref('product.product_product_2').id,
|
||||||
|
'quantity': 1.0,
|
||||||
|
'invoice_id': self.invoice.id,
|
||||||
|
'account_analytic_id': self.analytic_account.id,
|
||||||
|
})
|
||||||
|
self.invoice_line._onchange_product_id()
|
||||||
|
|
||||||
|
def test_contract_show_invoice(self):
|
||||||
|
self.assertEqual(len(self.analytic_account.analytic_account_ids), 1)
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<field name="model">account.analytic.account</field>
|
<field name="model">account.analytic.account</field>
|
||||||
<field name="inherit_id" ref="analytic.view_account_analytic_account_form" />
|
<field name="inherit_id" ref="analytic.view_account_analytic_account_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr='//div[@name="buttons"]' position='inside'>
|
<xpath expr='//div[@name="button_box"]' position='inside'>
|
||||||
<button class="oe_stat_button" type="action" icon="fa-edit"
|
<button class="oe_stat_button" type="action" icon="fa-edit"
|
||||||
name="%(contract_show_invoice.act_analytic_invoices)d"
|
name="%(contract_show_invoice.act_analytic_invoices)d"
|
||||||
string="Invoices" help="Invoices related with this contract">
|
string="Invoices" help="Invoices related with this contract">
|
||||||
|
|||||||
Reference in New Issue
Block a user