From cb970873295d200ecba28c77fb36cf2ca9bb944d Mon Sep 17 00:00:00 2001 From: stenex Date: Mon, 8 May 2023 17:27:06 +0200 Subject: [PATCH 1/2] [IMP] Add INVOICEMONTHNAME marker to line description [FIX] contract: Set fixed date to check test correctly. We need to set a fixed date for teststest_check_month_name_marker to check against the month of the date we are set (otherwise it would check against the month of today). --- contract/README.rst | 63 +++++++++++++------------- contract/models/contract_line.py | 23 ++++++++++ contract/readme/USAGE.md | 6 +-- contract/static/description/index.html | 9 ++-- contract/tests/test_contract.py | 11 ++++- contract/views/contract.xml | 7 +++ contract/views/contract_template.xml | 2 + 7 files changed, 82 insertions(+), 39 deletions(-) diff --git a/contract/README.rst b/contract/README.rst index 635369116..14f423db8 100644 --- a/contract/README.rst +++ b/contract/README.rst @@ -57,21 +57,22 @@ Usage 2. When creating a contract, fill fields for selecting the invoicing parameters: - - a journal - - a price list (optional) + - a journal + - a price list (optional) 3. And add the lines to be invoiced with: - - the product with a description, a quantity and a price - - the recurrence parameters: interval (days, weeks, months, months - last day or years), start date, date of next invoice (automatically - computed, can be modified) and end date (optional) - - auto-price, for having a price automatically obtained from the - price list - - #START# or #END# in the description field to display the start/end - date of the invoiced period in the invoice line description - - pre-paid (invoice at period start) or post-paid (invoice at start - of next period) + - the product with a description, a quantity and a price + - the recurrence parameters: interval (days, weeks, months, months + last day or years), start date, date of next invoice + (automatically computed, can be modified) and end date (optional) + - auto-price, for having a price automatically obtained from the + price list + - #START# - #END# or #INVOICEMONTHNAME# in the description field to + display the start/end date or the start month of the invoiced + period in the invoice line description + - pre-paid (invoice at period start) or post-paid (invoice at start + of next period) 4. The "Generate Recurring Invoices from Contracts" cron runs daily to generate the invoices. If you are in debug mode, you can click on the @@ -85,7 +86,7 @@ Usage price list and lines when creating a contract. To use it, just select the template on the contract and fields will be filled automatically. -- Contracts appear in portal to following users in every contract: +- Contracts appear in portal to following users in every contract: |image| @@ -100,8 +101,8 @@ Usage Known issues / Roadmap ====================== -- Recover states and others functional fields in Contracts. -- Add recurrence flag at template level. +- Recover states and others functional fields in Contracts. +- Add recurrence flag at template level. Bug Tracker =========== @@ -125,33 +126,33 @@ Authors Contributors ------------ -- Angel Moya +- Angel Moya -- Dave Lasley +- Dave Lasley -- Miquel Raïch +- Miquel Raïch -- Souheil Bejaoui +- Souheil Bejaoui -- Thomas Binsfeld +- Thomas Binsfeld -- Guillaume Vandamme +- Guillaume Vandamme -- Raphaël Reverdy +- Raphaël Reverdy -- `Tecnativa `__: +- `Tecnativa `__: - - Pedro M. Baeza - - Carlos Dauden - - Vicent Cubells - - Rafael Blasco - - Víctor Martínez + - Pedro M. Baeza + - Carlos Dauden + - Vicent Cubells + - Rafael Blasco + - Víctor Martínez -- Iván Antón +- Iván Antón -- `APSL `__: +- `APSL `__: - - Antoni Marroig + - Antoni Marroig Maintainers ----------- diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py index c3aa471a4..0a99b8f72 100644 --- a/contract/models/contract_line.py +++ b/contract/models/contract_line.py @@ -595,6 +595,23 @@ class ContractLine(models.Model): ) return first_date_invoiced, last_date_invoiced, recurring_next_date + def _translate_marker_month_name(self, month_name): + months = { + "January": _("January"), + "February": _("February"), + "March": _("March"), + "April": _("April"), + "May": _("May"), + "June": _("June"), + "July": _("July"), + "August": _("August"), + "September": _("September"), + "October": _("October"), + "November": _("November"), + "December": _("December"), + } + return months[month_name] + def _insert_markers(self, first_date_invoiced, last_date_invoiced): self.ensure_one() lang_obj = self.env["res.lang"] @@ -603,6 +620,12 @@ class ContractLine(models.Model): name = self.name name = name.replace("#START#", first_date_invoiced.strftime(date_format)) name = name.replace("#END#", last_date_invoiced.strftime(date_format)) + name = name.replace( + "#INVOICEMONTHNAME#", + self.with_context(lang=lang.code)._translate_marker_month_name( + first_date_invoiced.strftime("%B") + ), + ) return name def _update_recurring_next_date(self): diff --git a/contract/readme/USAGE.md b/contract/readme/USAGE.md index c7ab9b7ae..8cc5f3181 100644 --- a/contract/readme/USAGE.md +++ b/contract/readme/USAGE.md @@ -11,9 +11,9 @@ (automatically computed, can be modified) and end date (optional) - auto-price, for having a price automatically obtained from the price list - - \#START# or \#END# in the description field to display the - start/end date of the invoiced period in the invoice line - description + - \#START# - \#END# or \#INVOICEMONTHNAME# in the description field + to display the start/end date or the start month of the invoiced + period in the invoice line description - pre-paid (invoice at period start) or post-paid (invoice at start of next period) 4. The "Generate Recurring Invoices from Contracts" cron runs daily to diff --git a/contract/static/description/index.html b/contract/static/description/index.html index 58299d582..b0c3a8cf3 100644 --- a/contract/static/description/index.html +++ b/contract/static/description/index.html @@ -410,12 +410,13 @@ parameters:
  • And add the lines to be invoiced with:
    • the product with a description, a quantity and a price
    • the recurrence parameters: interval (days, weeks, months, months -last day or years), start date, date of next invoice (automatically -computed, can be modified) and end date (optional)
    • +last day or years), start date, date of next invoice +(automatically computed, can be modified) and end date (optional)
    • auto-price, for having a price automatically obtained from the price list
    • -
    • #START# or #END# in the description field to display the start/end -date of the invoiced period in the invoice line description
    • +
    • #START# - #END# or #INVOICEMONTHNAME# in the description field to +display the start/end date or the start month of the invoiced +period in the invoice line description
    • pre-paid (invoice at period start) or post-paid (invoice at start of next period)
    diff --git a/contract/tests/test_contract.py b/contract/tests/test_contract.py index 77e8f5c2a..4a7ddb48b 100644 --- a/contract/tests/test_contract.py +++ b/contract/tests/test_contract.py @@ -8,6 +8,7 @@ from collections import namedtuple from datetime import timedelta from dateutil.relativedelta import relativedelta +from freezegun import freeze_time from odoo import fields from odoo.exceptions import UserError, ValidationError @@ -141,7 +142,7 @@ class TestContractBase(common.TransactionCase): 0, { "product_id": False, - "name": "Header for Services", + "name": "Header for #INVOICEMONTHNAME# Services", "display_type": "line_section", }, ), @@ -2385,3 +2386,11 @@ class TestContract(TestContractBase): self.assertEqual(len(self.contract._get_related_invoices()), 4) self.contract.recurring_create_invoice() self.assertEqual(len(self.contract._get_related_invoices()), 4) + + @freeze_time("2023-05-01") + def test_check_month_name_marker(self): + """Set fixed date to check test correctly.""" + self.contract3.contract_line_ids.date_start = fields.Date.today() + self.contract3.contract_line_ids.recurring_next_date = fields.Date.today() + invoice_id = self.contract3.recurring_create_invoice() + self.assertEqual(invoice_id.invoice_line_ids[0].name, "Header for May Services") diff --git a/contract/views/contract.xml b/contract/views/contract.xml index eae34394e..d2ac27cc3 100644 --- a/contract/views/contract.xml +++ b/contract/views/contract.xml @@ -478,6 +478,13 @@ the invoiced period

    +

    + #INVOICEMONTHNAME# + : Invoice month name + of + the + invoiced period +

    diff --git a/contract/views/contract_template.xml b/contract/views/contract_template.xml index 8e9bf9451..f93ca395e 100644 --- a/contract/views/contract_template.xml +++ b/contract/views/contract_template.xml @@ -76,6 +76,8 @@

    #START#: Start date of the invoiced period

    #END#: End date of the invoiced period

    +

    #INVOICEMONTHNAME#: Invoice month name of the invoiced period

    From 537fdbf549f2aa00360ac9122c6b3cbe268de626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Thu, 5 Dec 2024 10:24:19 +0100 Subject: [PATCH 2/2] [I18N] contract: Spanish translations --- contract/i18n/contract.pot | 101 ++++++++++++++++++++++++++++++++ contract/i18n/es.po | 114 ++++++++++++++++++++++++++++++++++--- 2 files changed, 208 insertions(+), 7 deletions(-) diff --git a/contract/i18n/contract.pot b/contract/i18n/contract.pot index e79203347..0c40f1875 100644 --- a/contract/i18n/contract.pot +++ b/contract/i18n/contract.pot @@ -113,6 +113,23 @@ msgstr "" msgid "#END#: End date of the invoiced period" msgstr "" +#. module: contract +#: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view +msgid "" +"#INVOICEMONTHNAME#\n" +" : Invoice month name\n" +" of\n" +" the\n" +" invoiced period" +msgstr "" + +#. module: contract +#: model_terms:ir.ui.view,arch_db:contract.contract_template_form_view +msgid "" +"#INVOICEMONTHNAME#: Invoice month name of the invoiced " +"period" +msgstr "" + #. module: contract #: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view msgid "" @@ -320,6 +337,13 @@ msgstr "" msgid "Analytic Precision" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "April" +msgstr "" + #. module: contract #: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view #: model_terms:ir.ui.view,arch_db:contract.contract_contract_search_view @@ -352,6 +376,13 @@ msgstr "" msgid "Attachment Count" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "August" +msgstr "" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__is_auto_renew #: model:ir.model.fields,field_description:contract.field_contract_line__is_auto_renew @@ -934,6 +965,13 @@ msgstr "" msgid "Day(s)" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "December" +msgstr "" + #. module: contract #: model:ir.model.fields,help:contract.field_contract_abstract_contract_line__note_invoicing_mode #: model:ir.model.fields,help:contract.field_contract_line__note_invoicing_mode @@ -1016,6 +1054,13 @@ msgid "" "%(ue)s" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "February" +msgstr "" + #. module: contract #: model_terms:ir.ui.view,arch_db:contract.contract_contract_search_view msgid "Finished" @@ -1243,6 +1288,13 @@ msgstr "" msgid "Is suspension without end date" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "January" +msgstr "" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_abstract_contract__journal_id #: model:ir.model.fields,field_description:contract.field_contract_contract__journal_id @@ -1261,6 +1313,20 @@ msgstr "" msgid "Journal Item" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "July" +msgstr "" + +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "June" +msgstr "" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__last_date_invoiced #: model:ir.model.fields,field_description:contract.field_contract_contract__last_date_invoiced @@ -1327,6 +1393,13 @@ msgstr "" msgid "Manually Invoice Sale Contracts" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "March" +msgstr "" + #. module: contract #: model:ir.model.fields,help:contract.field_contract_abstract_contract__line_recurrence #: model:ir.model.fields,help:contract.field_contract_contract__line_recurrence @@ -1336,6 +1409,13 @@ msgid "" "all together for the whole contract." msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "May" +msgstr "" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_contract__message_has_error msgid "Message Delivery error" @@ -1459,6 +1539,13 @@ msgstr "" msgid "Notes" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "November" +msgstr "" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_contract__message_needaction_counter msgid "Number of Actions" @@ -1493,6 +1580,13 @@ msgstr "" msgid "Number of messages with delivery error" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "October" +msgstr "" + #. module: contract #: model:ir.model.fields,field_description:contract.field_account_bank_statement_line__old_contract_id #: model:ir.model.fields,field_description:contract.field_account_move__old_contract_id @@ -1768,6 +1862,13 @@ msgstr "" msgid "Sent" msgstr "" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "September" +msgstr "" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__sequence #: model:ir.model.fields,field_description:contract.field_contract_line__sequence diff --git a/contract/i18n/es.po b/contract/i18n/es.po index ec986be90..002d33f82 100644 --- a/contract/i18n/es.po +++ b/contract/i18n/es.po @@ -9,8 +9,6 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 19:17+0000\n" -"PO-Revision-Date: 2024-09-03 21:25+0200\n" "Last-Translator: Sergio Teruel \n" "Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" "Language: es\n" @@ -238,6 +236,29 @@ msgstr "" msgid "#END#: End date of the invoiced period" msgstr "#END#: Fecha fin del periodo facturado" +#. module: contract +#: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view +msgid "" +"#INVOICEMONTHNAME#\n" +" : Invoice month name\n" +" of\n" +" the\n" +" invoiced period" +msgstr "" +"#INVOICEMONTHNAME#\n" +" : Nombe del mes\n" +" del\n" +" periodo facturado" + +#. module: contract +#: model_terms:ir.ui.view,arch_db:contract.contract_template_form_view +msgid "" +"#INVOICEMONTHNAME#: Invoice month name of the invoiced " +"period" +msgstr "" +"#INVOICEMONTHNAME#: FechaNombre del mes del periodo " +"facturado" + #. module: contract #: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view msgid "" @@ -451,6 +472,13 @@ msgstr "Búsqueda de distribución analítica" msgid "Analytic Precision" msgstr "Precisión analítica" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "April" +msgstr "Abril" + #. module: contract #: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view #: model_terms:ir.ui.view,arch_db:contract.contract_contract_search_view @@ -483,6 +511,13 @@ msgstr "Socio asociado" msgid "Attachment Count" msgstr "Nº de archivos adjuntos" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "August" +msgstr "Agosto" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__is_auto_renew #: model:ir.model.fields,field_description:contract.field_contract_line__is_auto_renew @@ -1094,6 +1129,13 @@ msgstr "Fecha de siguiente factura" msgid "Day(s)" msgstr "Día(s)" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "December" +msgstr "Diciembre" + #. module: contract #: model:ir.model.fields,help:contract.field_contract_abstract_contract_line__note_invoicing_mode #: model:ir.model.fields,help:contract.field_contract_line__note_invoicing_mode @@ -1184,6 +1226,13 @@ msgstr "" "Fallo al procesar el contrato %(name)s [id: %(id)s]:\n" "%(ue)s" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "February" +msgstr "Febrero" + #. module: contract #: model_terms:ir.ui.view,arch_db:contract.contract_contract_search_view msgid "Finished" @@ -1419,6 +1468,13 @@ msgstr "Es nota recurrente" msgid "Is suspension without end date" msgstr "Es suspensión sin fecha de finalización" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "January" +msgstr "Enero" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_abstract_contract__journal_id #: model:ir.model.fields,field_description:contract.field_contract_contract__journal_id @@ -1437,6 +1493,20 @@ msgstr "Entrada diaria" msgid "Journal Item" msgstr "Apunte contable" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "July" +msgstr "Julio" + +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "June" +msgstr "Junio" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__last_date_invoiced #: model:ir.model.fields,field_description:contract.field_contract_contract__last_date_invoiced @@ -1504,6 +1574,13 @@ msgstr "Facturar manualmente contratos de compra" msgid "Manually Invoice Sale Contracts" msgstr "Facturar manualmente contratos de venta" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "March" +msgstr "Marzo" + #. module: contract #: model:ir.model.fields,help:contract.field_contract_abstract_contract__line_recurrence #: model:ir.model.fields,help:contract.field_contract_contract__line_recurrence @@ -1515,6 +1592,13 @@ msgstr "" "Marque esta casilla si desea controlar la recurrencia a nivel de línea en " "lugar de todos juntos para todo el contrato." +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "May" +msgstr "Mayo" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_contract__message_has_error msgid "Message Delivery error" @@ -1638,6 +1722,13 @@ msgstr "Modo de facturación de la nota" msgid "Notes" msgstr "Notas" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "November" +msgstr "Noviembre" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_contract__message_needaction_counter msgid "Number of Actions" @@ -1674,6 +1765,13 @@ msgstr "Número de mensajes que requieren una acción" msgid "Number of messages with delivery error" msgstr "Número de mensajes con error de entrega" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "October" +msgstr "Octubre" + #. module: contract #: model:ir.model.fields,field_description:contract.field_account_bank_statement_line__old_contract_id #: model:ir.model.fields,field_description:contract.field_account_move__old_contract_id @@ -1950,6 +2048,13 @@ msgstr "Enviar por correo electrónico" msgid "Sent" msgstr "Enviado" +#. module: contract +#. odoo-python +#: code:addons/contract/models/contract_line.py:0 +#, python-format +msgid "September" +msgstr "Septiembre" + #. module: contract #: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__sequence #: model:ir.model.fields,field_description:contract.field_contract_line__sequence @@ -2419,8 +2524,3 @@ msgid "" msgstr "" "{{ object.company_id.name }} Contrato (Ref {{ object.name or 'n/a' }}) - " "Modificaciones" - -#, fuzzy -#~| msgid "Next Activity Deadline" -#~ msgid "Next Activity Calendar Event" -#~ msgstr "Fecha límite de la siguiente actividad"