diff --git a/contract_recurring_plans/README.rst b/contract_recurring_plans/README.rst new file mode 100644 index 00000000..abb1ee5a --- /dev/null +++ b/contract_recurring_plans/README.rst @@ -0,0 +1,62 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================================== +Analytic plans for contract recurring invoices +============================================== + +This module allows to include an analytic plan on each recurring invoice line, +so if you set it, this will be taken to be transferred to the invoice instead +of the analytic account of the contract. + +Usage +===== + +On the contract view, select or create an analytic distribution for the +invoice recurring lines that you want. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/110/8.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here `_. + +Credits +======= + +Contributors +------------ + +* Pedro M. Baeza + +Icon +---- + +* https://openclipart.org/detail/125071/pie-graph +* Subicon made by `Freepik _ from + www.flaticon.com + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/contract_recurring_plans/__init__.py b/contract_recurring_plans/__init__.py new file mode 100644 index 00000000..721dbe49 --- /dev/null +++ b/contract_recurring_plans/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import models diff --git a/contract_recurring_plans/__openerp__.py b/contract_recurring_plans/__openerp__.py new file mode 100644 index 00000000..739bedc6 --- /dev/null +++ b/contract_recurring_plans/__openerp__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + 'name': 'Analytic plans on contracts recurring invoices', + 'version': '8.0.1.0.0', + 'category': 'Contract Management', + 'author': 'Serv. Tecnolog. Avanzados - Pedro M. Baeza, ' + 'Odoo Community Association (OCA)', + 'website': 'http://www.serviciosbaeza.com', + 'depends': [ + 'account_analytic_plans', + 'account_analytic_analysis', + ], + 'data': [ + 'views/account_analytic_invoice_line_view.xml', + ], + 'installable': True, +} diff --git a/contract_recurring_plans/i18n/es.po b/contract_recurring_plans/i18n/es.po new file mode 100644 index 00000000..240ddd74 --- /dev/null +++ b/contract_recurring_plans/i18n/es.po @@ -0,0 +1,36 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_analytic_analysis_recurring_plans +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-11-01 01:39+0000\n" +"PO-Revision-Date: 2014-11-01 01:39+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: account_analytic_analysis_recurring_plans +#: code:_description:0 +#: model:ir.model,name:account_analytic_analysis_recurring_plans.model_account_analytic_account +#, python-format +msgid "Analytic Account" +msgstr "Cuenta analítica" + +#. module: account_analytic_analysis_recurring_plans +#: field:account.analytic.invoice.line,analytics_id:0 +msgid "Analytic Distribution" +msgstr "Distribución analítica" + +#. module: account_analytic_analysis_recurring_plans +#: code:_description:0 +#: model:ir.model,name:account_analytic_analysis_recurring_plans.model_account_analytic_invoice_line +#, python-format +msgid "account.analytic.invoice.line" +msgstr "account.analytic.invoice.line" + diff --git a/contract_recurring_plans/models/__init__.py b/contract_recurring_plans/models/__init__.py new file mode 100644 index 00000000..5c3342b8 --- /dev/null +++ b/contract_recurring_plans/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import account_analytic_invoice_line diff --git a/contract_recurring_plans/models/account_analytic_invoice_line.py b/contract_recurring_plans/models/account_analytic_invoice_line.py new file mode 100644 index 00000000..3b0660a6 --- /dev/null +++ b/contract_recurring_plans/models/account_analytic_invoice_line.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import models, fields, api + + +class AccountAnalyticAccount(models.Model): + _inherit = "account.analytic.account" + + @api.model + def _prepare_invoice_line(self, line, invoice_id): + res = super(AccountAnalyticAccount, self)._prepare_invoice_line( + line, invoice_id) + if line.analytics_id: + res.update({'account_analytic_id': False, + 'analytics_id': line.analytics_id.id}) + return res + + +class AccountAnalyticInvoiceLine(models.Model): + _inherit = "account.analytic.invoice.line" + + analytics_id = fields.Many2one( + comodel_name='account.analytic.plan.instance', + string='Analytic Distribution') diff --git a/contract_recurring_plans/static/description/icon.png b/contract_recurring_plans/static/description/icon.png new file mode 100644 index 00000000..0fab733d Binary files /dev/null and b/contract_recurring_plans/static/description/icon.png differ diff --git a/contract_recurring_plans/static/description/icon.svg b/contract_recurring_plans/static/description/icon.svg new file mode 100644 index 00000000..b52aec86 --- /dev/null +++ b/contract_recurring_plans/static/description/icon.svg @@ -0,0 +1,463 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Openclipart + + + Pile of Golden Coins + 2010-04-09T03:27:45 + A pile of hypothetical golden coins, drawn in Inkscape. + https://openclipart.org/detail/43969/pile-of-golden-coins-by-j_alves + + + J_Alves + + + + + coin + currency + gold + money + thaler + + + + + + + + + + + diff --git a/contract_recurring_plans/tests/__init__.py b/contract_recurring_plans/tests/__init__.py new file mode 100644 index 00000000..d8b9e1ae --- /dev/null +++ b/contract_recurring_plans/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import test_contract_recurring_plans diff --git a/contract_recurring_plans/tests/test_contract_recurring_plans.py b/contract_recurring_plans/tests/test_contract_recurring_plans.py new file mode 100644 index 00000000..3f248053 --- /dev/null +++ b/contract_recurring_plans/tests/test_contract_recurring_plans.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +import openerp.tests.common as common + + +class TestContractRecurringPlans(common.TransactionCase): + + def setUp(self): + super(TestContractRecurringPlans, self).setUp() + self.partner = self.env['res.partner'].create({'name': 'Test'}) + self.product = self.env.ref('product.product_product_consultant') + self.uom = self.env.ref('product.product_uom_hour') + self.contract = self.env['account.analytic.account'].create({ + 'name': 'Test contract', + 'partner_id': self.partner.id, + 'type': 'contract', + 'recurring_invoices': 1, + 'recurring_interval': 1, + 'recurring_invoice_line_ids': [ + (0, 0, {'quantity': 2.0, + 'price_unit': 100.0, + 'name': 'Test', + 'product_id': self.product.id, + 'uom_id': self.uom.id})], + }) + plan = self.env['account.analytic.plan'].create({'name': 'Test'}) + self.analytics = self.env['account.analytic.plan.instance'].create( + {'plan_id': plan.id}) + + def test_invoice_without_plans(self): + self.contract.recurring_create_invoice() + invoice = self.env['account.invoice'].search( + [('partner_id', '=', self.partner.id)]) + self.assertEqual( + invoice.invoice_line[0].account_analytic_id, self.contract) + + def test_invoice_with_plans(self): + self.contract.recurring_invoice_line_ids.analytics_id = ( + self.analytics.id) + self.contract.recurring_create_invoice() + invoice = self.env['account.invoice'].search( + [('partner_id', '=', self.partner.id)]) + self.assertFalse(invoice.invoice_line[0].account_analytic_id) + self.assertEqual( + invoice.invoice_line[0].analytics_id, self.analytics) diff --git a/contract_recurring_plans/views/account_analytic_invoice_line_view.xml b/contract_recurring_plans/views/account_analytic_invoice_line_view.xml new file mode 100644 index 00000000..4d164ffd --- /dev/null +++ b/contract_recurring_plans/views/account_analytic_invoice_line_view.xml @@ -0,0 +1,17 @@ + + + + + + Contract form (with plans) + account.analytic.account + + + + + + + + + +