From 803635dbca5b720c392ed77caebd4349226e6de3 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 22 Feb 2016 18:36:40 +0100 Subject: [PATCH 1/7] [ADD] contract_recurring_invoicing_markers ======================================= Markers for contract recurring invoices ======================================= This module allows to include some markers on the lines of your recurring invoices definition inside the contract so that the generated invoice lines will contain a dynamic text depending on these markers. These markers are the supported ones: * #START#: Start date of the invoiced period. * #END# End date of the invoiced period. Usage ===== On a contract (*Sales > Sales > Contracts*), mark "Generate recurring invoices automatically" for enabling the creation of recurring invoices. In the "Invoice Lines" section, you can add lines with products. In the *Description* field, you can now add any of the markers mentioned before between the rest of the text. When you invoice this contract (automatically or manually), your invoice will contain the corresponding text that replaces the marker. Known issues / Roadmap ====================== * Add more markers, like #START_MONTH# or #END_MONTH#. --- .../README.rst | 79 +++++ .../__init__.py | 5 + .../__openerp__.py | 19 ++ .../models/__init__.py | 5 + .../models/account_analytic_account.py | 41 +++ .../static/description/icon.png | Bin 0 -> 6327 bytes .../static/description/icon.svg | 320 ++++++++++++++++++ .../tests/__init__.py | 5 + ...est_contract_recurring_invoicing_marker.py | 39 +++ .../views/account_analytic_account_view.xml | 20 ++ 10 files changed, 533 insertions(+) create mode 100644 contract_recurring_invoicing_marker/README.rst create mode 100644 contract_recurring_invoicing_marker/__init__.py create mode 100644 contract_recurring_invoicing_marker/__openerp__.py create mode 100644 contract_recurring_invoicing_marker/models/__init__.py create mode 100644 contract_recurring_invoicing_marker/models/account_analytic_account.py create mode 100644 contract_recurring_invoicing_marker/static/description/icon.png create mode 100644 contract_recurring_invoicing_marker/static/description/icon.svg create mode 100644 contract_recurring_invoicing_marker/tests/__init__.py create mode 100644 contract_recurring_invoicing_marker/tests/test_contract_recurring_invoicing_marker.py create mode 100644 contract_recurring_invoicing_marker/views/account_analytic_account_view.xml diff --git a/contract_recurring_invoicing_marker/README.rst b/contract_recurring_invoicing_marker/README.rst new file mode 100644 index 000000000..a26d69360 --- /dev/null +++ b/contract_recurring_invoicing_marker/README.rst @@ -0,0 +1,79 @@ +.. 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 + +======================================= +Markers for contract recurring invoices +======================================= + +This module allows to include some markers on the lines of your recurring +invoices definition inside the contract so that the generated invoice lines +will contain a dynamic text depending on these markers. + +These markers are the supported ones: + +* #START#: Start date of the invoiced period. +* #END# End date of the invoiced period. + +Usage +===== + +On a contract (*Sales > Sales > Contracts*), mark "Generate recurring invoices +automatically" for enabling the creation of recurring invoices. + +In the "Invoice Lines" section, you can add lines with products. In the +*Description* field, you can now add any of the markers mentioned before +between the rest of the text. + +When you invoice this contract (automatically or manually), your invoice +will contain the corresponding text that replaces the marker. + +.. 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 + +Known issues / Roadmap +====================== + +* Add more markers, like #START_MONTH# or #END_MONTH#. + +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_invoicing_marker/__init__.py b/contract_recurring_invoicing_marker/__init__.py new file mode 100644 index 000000000..406086aa9 --- /dev/null +++ b/contract_recurring_invoicing_marker/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# (c) 2016 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_invoicing_marker/__openerp__.py b/contract_recurring_invoicing_marker/__openerp__.py new file mode 100644 index 000000000..f2efc5549 --- /dev/null +++ b/contract_recurring_invoicing_marker/__openerp__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# (c) 2016 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + 'name': 'Markers for contract recurring invoices', + 'version': '8.0.1.0.0', + 'category': 'Contract Management', + 'author': 'Serv. Tecnol. Avanzados - Pedro M. Baeza, ' + 'Odoo Community Association (OCA)', + 'website': 'http://www.serviciosbaeza.com', + 'depends': [ + 'account_analytic_analysis', + ], + 'data': [ + 'views/account_analytic_account_view.xml', + ], + 'installable': True, +} diff --git a/contract_recurring_invoicing_marker/models/__init__.py b/contract_recurring_invoicing_marker/models/__init__.py new file mode 100644 index 000000000..9bde9c9bc --- /dev/null +++ b/contract_recurring_invoicing_marker/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# (c) 2016 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import account_analytic_account diff --git a/contract_recurring_invoicing_marker/models/account_analytic_account.py b/contract_recurring_invoicing_marker/models/account_analytic_account.py new file mode 100644 index 000000000..c29866551 --- /dev/null +++ b/contract_recurring_invoicing_marker/models/account_analytic_account.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# (c) 2016 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import api, fields, models +from dateutil.relativedelta import relativedelta + + +class AccountAnalyticAccount(models.Model): + _inherit = "account.analytic.account" + + @api.model + def _prepare_invoice(self, contract): + next_date = fields.Date.from_string( + contract.recurring_next_date or fields.Date.today()) + interval = contract.recurring_interval + old_date = next_date + if contract.recurring_rule_type == 'daily': + new_date = next_date + relativedelta(days=interval - 1) + elif contract.recurring_rule_type == 'weekly': + new_date = next_date + relativedelta(weeks=interval, days=-1) + else: + new_date = next_date + relativedelta(months=interval, days=-1) + obj = self.with_context(old_date=old_date, next_date=new_date) + return super(AccountAnalyticAccount, obj)._prepare_invoice(contract) + + @api.model + def _prepare_invoice_line(self, line, invoice_id): + res = super(AccountAnalyticAccount, self)._prepare_invoice_line( + line, invoice_id) + if 'old_date' in self.env.context and 'next_date' in self.env.context: + lang_obj = self.env['res.lang'] + contract = line.analytic_account_id + lang = lang_obj.search( + [('code', '=', contract.partner_id.lang)]) + date_format = lang.date_format + res['name'] = res['name'].replace( + '#START#', self.env.context['old_date'].strftime(date_format)) + res['name'] = res['name'].replace( + '#END#', self.env.context['next_date'].strftime(date_format)) + return res diff --git a/contract_recurring_invoicing_marker/static/description/icon.png b/contract_recurring_invoicing_marker/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d4d85b463492004db72160d3ecb6a3eaeac718eb GIT binary patch literal 6327 zcmaJ_c{r5syMM;MWDA)P6S8FA#*#IIY%wW&md4l_%gD~4By0Ji>>7#45<-NLLfKLY zNyxtMWIwO(@0{y8=btmzyz^e~Joj^N&*#2B_w_zBxvtAV$4LhOV9>jUx&hq@rxy(s z^xLN9&;{Kn{I2TVq=7!6G>);*Gp+YEOFu|{@brRR70wET{ydM@w!oX>obUk-zE}_t z5Fp{|;Cz9;ouvrzhvf0SZQm5L!8eH{Y45UySbz5ns3?~KOBO;=AWkdcy>5|@$_ zmr}YZC95o>pe!f09By4ahY>M;u#bAL89`Eg^EGdce#(H5qT)iE9@uyKrI%4q- zt{#$dvPwuL$y3k7aZcj@aYp=KXT4v2Gnju}yo<%)JUwwj?f5eQ=eqS! znl}Tpmvch!Y}(BoEd#2N_f!(}XaqXXUZT%LrDUu;nsNzbSc(%%7W;r@k6uYBU8HMR z;JIW&zCwo%7+@dW_8knN9FyouTfE%a_J}~IJSr<4NT3jy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3&7WFu7+QquCFGXwEKI=X3>)wWnB>!g) zS$@ac`oAYA`NIp}bsQtk1i@m7^;9HI2y~Uo?=ppG-kVvbE09_I?3(Ibnd@=#dm?Er z)!w|SR{4jH<%pJaRN1$&%$hW*V~`@pr9sx=Q^(wY!zQ!nZxw=u8m5smx|N{(cJdbA zexY#OYDUk@34(YKnA@Vp&p(NZn0_lWMLAAd@BY=_|Jr<1ob?_umz59-y(|ZM+SgI#SM8(z3mv1V!T + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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_invoicing_marker/tests/__init__.py b/contract_recurring_invoicing_marker/tests/__init__.py new file mode 100644 index 000000000..6e03ad9f9 --- /dev/null +++ b/contract_recurring_invoicing_marker/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# (c) 2016 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import test_contract_recurring_invoicing_marker diff --git a/contract_recurring_invoicing_marker/tests/test_contract_recurring_invoicing_marker.py b/contract_recurring_invoicing_marker/tests/test_contract_recurring_invoicing_marker.py new file mode 100644 index 000000000..607bb7db4 --- /dev/null +++ b/contract_recurring_invoicing_marker/tests/test_contract_recurring_invoicing_marker.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# (c) 2016 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 TestContractRecurringInvoicingMarker(common.TransactionCase): + + def setUp(self): + super(TestContractRecurringInvoicingMarker, self).setUp() + self.partner = self.env['res.partner'].create({ + 'name': 'Test', + 'lang': 'en_US', + }) + 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_next_date': '2016-01-01', + 'recurring_rule_type': 'monthly', + 'recurring_interval': 1, + 'recurring_invoice_line_ids': [ + (0, 0, {'quantity': 2.0, + 'price_unit': 100.0, + 'name': '#START# - #END#', + 'product_id': self.product.id, + 'uom_id': self.uom.id})], + }) + + def test_invoice_with_marker(self): + self.contract.recurring_create_invoice() + invoice = self.env['account.invoice'].search( + [('partner_id', '=', self.partner.id)]) + self.assertEqual( + invoice.invoice_line[0].name, u'01/01/2016 - 01/31/2016') diff --git a/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml b/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml new file mode 100644 index 000000000..5bc873584 --- /dev/null +++ b/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml @@ -0,0 +1,20 @@ + + + + + + Contract form (with markers) + account.analytic.account + + + + +

#START#: Start date of the invoiced period

+

#END#: End date of the invoiced period

+
+
+
+
+ +
+
From 95feed8357ccda8e9c8acf26aa538059607a47e7 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 22 Feb 2016 18:49:00 +0100 Subject: [PATCH 2/7] [IMP] contract_recurring_invoicing_marker: Spanish translation --- .../i18n/es.po | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 contract_recurring_invoicing_marker/i18n/es.po diff --git a/contract_recurring_invoicing_marker/i18n/es.po b/contract_recurring_invoicing_marker/i18n/es.po new file mode 100644 index 000000000..00d9bb0ef --- /dev/null +++ b/contract_recurring_invoicing_marker/i18n/es.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * contract_recurring_invoicing_marker +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-02-22 17:47+0000\n" +"PO-Revision-Date: 2016-02-22 17:47+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_recurring_invoicing_marker +#: view:account.analytic.account:contract_recurring_invoicing_marker.account_analytic_account_form_form +msgid "#END#" +msgstr "#END#" + +#. module: contract_recurring_invoicing_marker +#: view:account.analytic.account:contract_recurring_invoicing_marker.account_analytic_account_form_form +msgid "#START#" +msgstr "#START#" + +#. module: contract_recurring_invoicing_marker +#: view:account.analytic.account:contract_recurring_invoicing_marker.account_analytic_account_form_form +msgid ": End date of the invoiced period" +msgstr ": Fecha final del periodo facturado" + +#. module: contract_recurring_invoicing_marker +#: view:account.analytic.account:contract_recurring_invoicing_marker.account_analytic_account_form_form +msgid ": Start date of the invoiced period" +msgstr ": Fecha inicial del periodo facturado" + +#. module: contract_recurring_invoicing_marker +#: model:ir.model,name:contract_recurring_invoicing_marker.model_account_analytic_account +msgid "Analytic Account" +msgstr "Cuenta analítica" + +#. module: contract_recurring_invoicing_marker +#: view:account.analytic.account:contract_recurring_invoicing_marker.account_analytic_account_form_form +msgid "Legend (for the markers inside invoice lines description)" +msgstr "Leyenda (para los marcadores dentro de la descripción de las líneas de factura)" + From 5d4e639086831b3ad1de1d8169baeb9a04f59afc Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 22 Feb 2016 19:26:41 +0100 Subject: [PATCH 3/7] [FIX] contract_recurring_invoicing_marker: Avoid empty date format --- .../models/account_analytic_account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contract_recurring_invoicing_marker/models/account_analytic_account.py b/contract_recurring_invoicing_marker/models/account_analytic_account.py index c29866551..a134d75eb 100644 --- a/contract_recurring_invoicing_marker/models/account_analytic_account.py +++ b/contract_recurring_invoicing_marker/models/account_analytic_account.py @@ -33,7 +33,7 @@ class AccountAnalyticAccount(models.Model): contract = line.analytic_account_id lang = lang_obj.search( [('code', '=', contract.partner_id.lang)]) - date_format = lang.date_format + date_format = lang.date_format or '%d/%M/%Y' res['name'] = res['name'].replace( '#START#', self.env.context['old_date'].strftime(date_format)) res['name'] = res['name'].replace( From 7ba0d29e0208cb3ff1980caa3da63dfdb52771e7 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 22 Feb 2016 19:50:58 +0100 Subject: [PATCH 4/7] [IMP] contract_recurring_invoicing_marker: Add more tests --- ...test_contract_recurring_invoicing_marker.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/contract_recurring_invoicing_marker/tests/test_contract_recurring_invoicing_marker.py b/contract_recurring_invoicing_marker/tests/test_contract_recurring_invoicing_marker.py index 607bb7db4..c0c605065 100644 --- a/contract_recurring_invoicing_marker/tests/test_contract_recurring_invoicing_marker.py +++ b/contract_recurring_invoicing_marker/tests/test_contract_recurring_invoicing_marker.py @@ -31,9 +31,25 @@ class TestContractRecurringInvoicingMarker(common.TransactionCase): 'uom_id': self.uom.id})], }) - def test_invoice_with_marker(self): + def test_monthly_invoice_with_marker(self): self.contract.recurring_create_invoice() invoice = self.env['account.invoice'].search( [('partner_id', '=', self.partner.id)]) self.assertEqual( invoice.invoice_line[0].name, u'01/01/2016 - 01/31/2016') + + def test_daily_invoice_with_marker(self): + self.contract.recurring_rule_type = 'daily' + self.contract.recurring_create_invoice() + invoice = self.env['account.invoice'].search( + [('partner_id', '=', self.partner.id)]) + self.assertEqual( + invoice.invoice_line[0].name, u'01/01/2016 - 01/01/2016') + + def test_weekly_invoice_with_marker(self): + self.contract.recurring_rule_type = 'weekly' + self.contract.recurring_create_invoice() + invoice = self.env['account.invoice'].search( + [('partner_id', '=', self.partner.id)]) + self.assertEqual( + invoice.invoice_line[0].name, u'01/01/2016 - 01/07/2016') From 1aa8ad8d371ec05759188b95b9da4780c782aaeb Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 23 Feb 2016 15:54:34 +0100 Subject: [PATCH 5/7] [FIX] contract_recurring_invoicing_marker: License key --- contract_recurring_invoicing_marker/__openerp__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contract_recurring_invoicing_marker/__openerp__.py b/contract_recurring_invoicing_marker/__openerp__.py index f2efc5549..5f75e7f04 100644 --- a/contract_recurring_invoicing_marker/__openerp__.py +++ b/contract_recurring_invoicing_marker/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# (c) 2016 Serv. Tecnol. Avanzados - Pedro M. Baeza +# © 2016 Serv. Tecnol. Avanzados - Pedro M. Baeza # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html { @@ -12,6 +12,7 @@ 'depends': [ 'account_analytic_analysis', ], + 'license': 'AGPL-3', 'data': [ 'views/account_analytic_account_view.xml', ], From 7df454bc6ae05ad0a7d416e13828da341805ea1e Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 24 Feb 2016 12:29:54 +0100 Subject: [PATCH 6/7] [IMP] contract_recurring_invoicing_marker: Better inherability --- .../models/account_analytic_account.py | 13 +++++++++---- .../views/account_analytic_account_view.xml | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/contract_recurring_invoicing_marker/models/account_analytic_account.py b/contract_recurring_invoicing_marker/models/account_analytic_account.py index a134d75eb..b48285848 100644 --- a/contract_recurring_invoicing_marker/models/account_analytic_account.py +++ b/contract_recurring_invoicing_marker/models/account_analytic_account.py @@ -24,6 +24,12 @@ class AccountAnalyticAccount(models.Model): obj = self.with_context(old_date=old_date, next_date=new_date) return super(AccountAnalyticAccount, obj)._prepare_invoice(contract) + @api.model + def _insert_markers(self, line, date_start, date_end, date_format): + line = line.replace('#START#', date_start.strftime(date_format)) + line = line.replace('#END#', date_end.strftime(date_format)) + return line + @api.model def _prepare_invoice_line(self, line, invoice_id): res = super(AccountAnalyticAccount, self)._prepare_invoice_line( @@ -34,8 +40,7 @@ class AccountAnalyticAccount(models.Model): lang = lang_obj.search( [('code', '=', contract.partner_id.lang)]) date_format = lang.date_format or '%d/%M/%Y' - res['name'] = res['name'].replace( - '#START#', self.env.context['old_date'].strftime(date_format)) - res['name'] = res['name'].replace( - '#END#', self.env.context['next_date'].strftime(date_format)) + res['name'] = self._insert_markers( + res['name'], self.env.context['old_date'], + self.env.context['next_date'], date_format) return res diff --git a/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml b/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml index 5bc873584..fbbd330b0 100644 --- a/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml +++ b/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml @@ -8,7 +8,7 @@ - +

#START#: Start date of the invoiced period

#END#: End date of the invoiced period

From f43d6f8a975079c6789354b643e9182192d08438 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 7 Mar 2016 17:51:28 +0100 Subject: [PATCH 7/7] [FIX] contract_recurring_invoicing_marker: Incorrect default date format --- .../models/account_analytic_account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contract_recurring_invoicing_marker/models/account_analytic_account.py b/contract_recurring_invoicing_marker/models/account_analytic_account.py index b48285848..40ac46383 100644 --- a/contract_recurring_invoicing_marker/models/account_analytic_account.py +++ b/contract_recurring_invoicing_marker/models/account_analytic_account.py @@ -39,7 +39,7 @@ class AccountAnalyticAccount(models.Model): contract = line.analytic_account_id lang = lang_obj.search( [('code', '=', contract.partner_id.lang)]) - date_format = lang.date_format or '%d/%M/%Y' + date_format = lang.date_format or '%m/%d/%Y' res['name'] = self._insert_markers( res['name'], self.env.context['old_date'], self.env.context['next_date'], date_format)