Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][MIG] base_ubl_payment #155

Merged
merged 16 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions base_ubl_payment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
================
Base UBL Payment
================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/12.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-12-0/edi-12-0-base_ubl_payment
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/226/12.0
:alt: Try me on Runbot

|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 <https://github.com/OCA/edi/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 <https://github.com/OCA/edi/issues/new?body=module:%20base_ubl_payment%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Alexis de Lattre <alexis.delattre@akretion.com>
* Andrea Stirpe <a.stirpe@onestein.nl>

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 <https://github.com/OCA/edi/tree/12.0/base_ubl_payment>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions base_ubl_payment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
15 changes: 15 additions & 0 deletions base_ubl_payment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# © 2016-2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Base UBL Payment",
"version": "13.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"],
"external_dependencies": {"python": ["lxml"]},
"installable": True,
}
26 changes: 26 additions & 0 deletions base_ubl_payment/i18n/base_ubl_payment.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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"
"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
#: code:addons/base_ubl_payment/models/ubl.py:25
#, python-format
msgid "Missing 'UNECE Payment Mean' on payment type '%s' used by the payment mode '%s'."
msgstr ""

30 changes: 30 additions & 0 deletions base_ubl_payment/i18n/hr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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 <bole@dajmi5.com>\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
#: code:addons/base_ubl_payment/models/ubl.py:25
#, python-format
msgid "Missing 'UNECE Payment Mean' on payment type '%s' used by the payment mode '%s'."
msgstr ""
"Nedostaje UNECE šifra načina plaćanja '%s' korštenog na tipu plaćanja '%s'."
3 changes: 3 additions & 0 deletions base_ubl_payment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import ubl
89 changes: 89 additions & 0 deletions base_ubl_payment/models/ubl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# © 2016-2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# 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_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 '%s' "
"used by the payment mode '%s'."
)
% (payment_mode.payment_method_id.name, 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"]:
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 = 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
2 changes: 2 additions & 0 deletions base_ubl_payment/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Alexis de Lattre <alexis.delattre@akretion.com>
* Andrea Stirpe <a.stirpe@onestein.nl>
6 changes: 6 additions & 0 deletions base_ubl_payment/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
Binary file added base_ubl_payment/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading