diff --git a/account_einvoice_generate/models/account_move.py b/account_einvoice_generate/models/account_move.py index 0cc2a968d6..28f971290a 100644 --- a/account_einvoice_generate/models/account_move.py +++ b/account_einvoice_generate/models/account_move.py @@ -11,7 +11,7 @@ class AccountMove(models.Model): def get_payment_identifier(self): """This method is designed to be inherited in localization modules""" self.ensure_one() - return None + return self.payment_reference @api.model def _get_invoice_report_names(self): diff --git a/base_ubl_payment/README.rst b/base_ubl_payment/README.rst new file mode 100644 index 0000000000..fdc11c1504 --- /dev/null +++ b/base_ubl_payment/README.rst @@ -0,0 +1,83 @@ +================ +Base UBL Payment +================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5d8f1ed6a0406980d933f6c275dfbc46a8171e11fdebde49bbef014f0feec5af + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github + :target: https://github.com/OCA/edi/tree/16.0/base_ubl_payment + :alt: OCA/edi +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-base_ubl_payment + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module is a small module above the *base_ubl* module; +it adds the generation of the *PaymentMeans* UBL block. +I decided to make it a separate module because it depends +on the module *account_payment_unece* which itself depend on +*account_banking_payment_export*, and I didn't want to add +these dependencies on the *base_ubl* module. + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Alexis de Lattre +* Andrea Stirpe +* Dhara Solanki + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/edi `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_ubl_payment/__init__.py b/base_ubl_payment/__init__.py new file mode 100644 index 0000000000..31660d6a96 --- /dev/null +++ b/base_ubl_payment/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/base_ubl_payment/__manifest__.py b/base_ubl_payment/__manifest__.py new file mode 100644 index 0000000000..08ef37e127 --- /dev/null +++ b/base_ubl_payment/__manifest__.py @@ -0,0 +1,14 @@ +# © 2016-2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Base UBL Payment", + "version": "16.0.1.0.0", + "category": "Hidden", + "license": "AGPL-3", + "summary": "Payment-related code for Universal Business Language (UBL)", + "author": "Akretion,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/edi", + "depends": ["account_payment_unece", "base_ubl"], + "installable": True, +} diff --git a/base_ubl_payment/i18n/base_ubl_payment.pot b/base_ubl_payment/i18n/base_ubl_payment.pot new file mode 100644 index 0000000000..e2666986f8 --- /dev/null +++ b/base_ubl_payment/i18n/base_ubl_payment.pot @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_ubl_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \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: base_ubl_payment +#: model:ir.model,name:base_ubl_payment.model_base_ubl +msgid "Common methods to generate and parse UBL XML files" +msgstr "" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__display_name +msgid "Display Name" +msgstr "" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__id +msgid "ID" +msgstr "" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl____last_update +msgid "Last Modified on" +msgstr "" + +#. module: base_ubl_payment +#: code:addons/base_ubl_payment/models/ubl.py:0 +#, python-format +msgid "" +"Missing 'UNECE Payment Mean' on payment type '{method}' " +"used by the payment mode '{mode}'." +msgstr "" diff --git a/base_ubl_payment/i18n/es.po b/base_ubl_payment/i18n/es.po new file mode 100644 index 0000000000..34e4b15dad --- /dev/null +++ b/base_ubl_payment/i18n/es.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_ubl_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-22 20:34+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_ubl_payment +#: model:ir.model,name:base_ubl_payment.model_base_ubl +msgid "Common methods to generate and parse UBL XML files" +msgstr "Métodos habituales para generar y analizar archivos XML UBL" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__id +msgid "ID" +msgstr "ID" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl____last_update +msgid "Last Modified on" +msgstr "Última Modificación el" + +#. module: base_ubl_payment +#: code:addons/base_ubl_payment/models/ubl.py:0 +#, python-format +msgid "" +"Missing 'UNECE Payment Mean' on payment type '{method}' " +"used by the payment mode '{mode}'." +msgstr "" +"Falta 'UNECE Payment Mean' en el tipo de pago '{method}' utilizado por el modo de " +"pago '{mode}'." diff --git a/base_ubl_payment/i18n/fr.po b/base_ubl_payment/i18n/fr.po new file mode 100644 index 0000000000..14bec0505e --- /dev/null +++ b/base_ubl_payment/i18n/fr.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_ubl_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-05-29 11:08+0000\n" +"Last-Translator: Claude R Perrin \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_ubl_payment +#: model:ir.model,name:base_ubl_payment.model_base_ubl +msgid "Common methods to generate and parse UBL XML files" +msgstr "Méthodes courantes pour générer et analyser les fichiers XML UBL" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__id +msgid "ID" +msgstr "ID" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: base_ubl_payment +#: code:addons/base_ubl_payment/models/ubl.py:0 +#, python-format +msgid "" +"Missing 'UNECE Payment Mean' on payment type '{method}' " +"used by the payment mode '{mode}'." +msgstr "" +"'Moyen de paiement UNECE’ manquant sur le type de paiement '{method}' utilisé par " +"le mode de paiement '{mode}'." diff --git a/base_ubl_payment/i18n/hr.po b/base_ubl_payment/i18n/hr.po new file mode 100644 index 0000000000..6d6fbbe42f --- /dev/null +++ b/base_ubl_payment/i18n/hr.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_ubl_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-11-12 17:34+0000\n" +"Last-Translator: Bole \n" +"Language-Team: none\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 3.8\n" + +#. module: base_ubl_payment +#: model:ir.model,name:base_ubl_payment.model_base_ubl +msgid "Common methods to generate and parse UBL XML files" +msgstr "Zajedničke metode za generiranje i parsiranje UBL XML datoteka" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__display_name +msgid "Display Name" +msgstr "" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__id +msgid "ID" +msgstr "" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl____last_update +msgid "Last Modified on" +msgstr "" + +#. module: base_ubl_payment +#: code:addons/base_ubl_payment/models/ubl.py:0 +#, python-format +msgid "" +"Missing 'UNECE Payment Mean' on payment type '{method}' " +"used by the payment mode '{mode}'." +msgstr "" +"Nedostaje UNECE šifra načina plaćanja '{method}' korštenog na tipu plaćanja '{mode}'." diff --git a/base_ubl_payment/i18n/nl.po b/base_ubl_payment/i18n/nl.po new file mode 100644 index 0000000000..30906764d3 --- /dev/null +++ b/base_ubl_payment/i18n/nl.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_ubl_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-12-13 02:36+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: base_ubl_payment +#: model:ir.model,name:base_ubl_payment.model_base_ubl +msgid "Common methods to generate and parse UBL XML files" +msgstr "" +"Gemeenschappelijke code voor het genereren en verwerken van UBL XML bestanden" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__display_name +msgid "Display Name" +msgstr "" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl__id +msgid "ID" +msgstr "" + +#. module: base_ubl_payment +#: model:ir.model.fields,field_description:base_ubl_payment.field_base_ubl____last_update +msgid "Last Modified on" +msgstr "" + +#. module: base_ubl_payment +#: code:addons/base_ubl_payment/models/ubl.py:0 +#, python-format +msgid "" +"Missing 'UNECE Payment Mean' on payment type '{method}' " +"used by the payment mode '{mode}'." +msgstr "" +"Ontbrekende 'UNECE betaalmethode' voor betalingstype '{method}' gebruikt door " +"betaalmethode '{mode}'." diff --git a/base_ubl_payment/models/__init__.py b/base_ubl_payment/models/__init__.py new file mode 100644 index 0000000000..7ec1c77b3e --- /dev/null +++ b/base_ubl_payment/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import ubl diff --git a/base_ubl_payment/models/ubl.py b/base_ubl_payment/models/ubl.py new file mode 100644 index 0000000000..5cf2b1fdb8 --- /dev/null +++ b/base_ubl_payment/models/ubl.py @@ -0,0 +1,101 @@ +# © 2016-2017 Akretion (Alexis de Lattre ) +# Copyright 2023 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import logging + +from lxml import etree + +from odoo import _, api, models +from odoo.exceptions import UserError + +logger = logging.getLogger(__name__) + + +class BaseUbl(models.AbstractModel): + _inherit = "base.ubl" + + @api.model + def _ubl_convert_payment_identifier(self, payment_identifier): + """Reformat localized payment identifier in an UBL compatible format""" + if not payment_identifier: + return payment_identifier + return payment_identifier.replace("+", "").replace("/", "") + + @api.model + def _ubl_add_payment_means( + self, + partner_bank, + payment_mode, + date_due, + parent_node, + ns, + payment_identifier=None, + version="2.1", + ): + pay_means = etree.SubElement(parent_node, ns["cac"] + "PaymentMeans") + pay_means_code = etree.SubElement( + pay_means, ns["cbc"] + "PaymentMeansCode", listID="UN/ECE 4461" + ) + # Why not schemeAgencyID='6' + schemeID + if payment_mode: # type is a required field on payment_mode + if not payment_mode.payment_method_id.unece_id: + raise UserError( + _( + "Missing 'UNECE Payment Mean' on payment type '{method}' " + "used by the payment mode '{mode}'." + ).format( + method=payment_mode.payment_method_id.name, + mode=payment_mode.name, + ) + ) + pay_means_code.text = payment_mode.payment_method_id.unece_code + else: + pay_means_code.text = "31" + logger.warning( + "Missing payment mode on invoice ID %d. " + "Using 31 (wire transfer) as UNECE code as fallback " + "for payment mean", + self.id, + ) + if date_due: + pay_due_date = etree.SubElement(pay_means, ns["cbc"] + "PaymentDueDate") + pay_due_date.text = date_due.strftime("%Y-%m-%d") + if pay_means_code.text in ["30", "31", "42", "58", "59"]: + if ( + not partner_bank + and payment_mode + and payment_mode.bank_account_link == "fixed" + and payment_mode.fixed_journal_id + ): + partner_bank = payment_mode.fixed_journal_id.bank_account_id + if partner_bank and partner_bank.acc_type == "iban": + # In the Chorus specs, they except 'IBAN' in PaymentChannelCode + # I don't know if this usage is common or not + payment_channel_code = etree.SubElement( + pay_means, ns["cbc"] + "PaymentChannelCode" + ) + payment_channel_code.text = "IBAN" + if payment_identifier: + payment_id = etree.SubElement(pay_means, ns["cbc"] + "PaymentID") + payment_id.text = self._ubl_convert_payment_identifier( + payment_identifier + ) + payee_fin_account = etree.SubElement( + pay_means, ns["cac"] + "PayeeFinancialAccount" + ) + payee_fin_account_id = etree.SubElement( + payee_fin_account, ns["cbc"] + "ID", schemeName="IBAN" + ) + payee_fin_account_id.text = partner_bank.sanitized_acc_number + if partner_bank.bank_bic: + financial_inst_branch = etree.SubElement( + payee_fin_account, ns["cac"] + "FinancialInstitutionBranch" + ) + financial_inst = etree.SubElement( + financial_inst_branch, ns["cac"] + "FinancialInstitution" + ) + financial_inst_id = etree.SubElement( + financial_inst, ns["cbc"] + "ID", schemeName="BIC" + ) + financial_inst_id.text = partner_bank.bank_bic diff --git a/base_ubl_payment/readme/CONTRIBUTORS.rst b/base_ubl_payment/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..8af1ca18c0 --- /dev/null +++ b/base_ubl_payment/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Alexis de Lattre +* Andrea Stirpe +* Dhara Solanki +* Jacques-Etienne Baudoux (BCIM) diff --git a/base_ubl_payment/readme/DESCRIPTION.rst b/base_ubl_payment/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..eeed096dea --- /dev/null +++ b/base_ubl_payment/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module is a small module above the *base_ubl* module; +it adds the generation of the *PaymentMeans* UBL block. +I decided to make it a separate module because it depends +on the module *account_payment_unece* which itself depend on +*account_banking_payment_export*, and I didn't want to add +these dependencies on the *base_ubl* module. diff --git a/base_ubl_payment/static/description/icon.png b/base_ubl_payment/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/base_ubl_payment/static/description/icon.png differ diff --git a/base_ubl_payment/static/description/index.html b/base_ubl_payment/static/description/index.html new file mode 100644 index 0000000000..1ddca41109 --- /dev/null +++ b/base_ubl_payment/static/description/index.html @@ -0,0 +1,428 @@ + + + + + + +Base UBL Payment + + + +
+

Base UBL Payment

+ + +

Beta License: AGPL-3 OCA/edi Translate me on Weblate Try me on Runboat

+

This module is a small module above the base_ubl module; +it adds the generation of the PaymentMeans UBL block. +I decided to make it a separate module because it depends +on the module account_payment_unece which itself depend on +account_banking_payment_export, and I didn’t want to add +these dependencies on the base_ubl module.

+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/edi project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/setup/base_ubl_payment/odoo/addons/base_ubl_payment b/setup/base_ubl_payment/odoo/addons/base_ubl_payment new file mode 120000 index 0000000000..0d989e3001 --- /dev/null +++ b/setup/base_ubl_payment/odoo/addons/base_ubl_payment @@ -0,0 +1 @@ +../../../../base_ubl_payment \ No newline at end of file diff --git a/setup/base_ubl_payment/setup.py b/setup/base_ubl_payment/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/base_ubl_payment/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)