Merge pull request #129 from Noviat/20.0

Syncing from upstream Noviat/account_ebics (20.0)
This commit is contained in:
braintec authored and GitHub committed 2026-11-17 06:45:21 +01:00
commit f8bd8e2745
79 files changed
+15174

No files matched your search

+8
View File
@@ -9,6 +9,14 @@
<!-- prettier-ignore-start -->
[//]: # (addons)
Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
[account_ebics](account_ebics/) | 20.0.1.0.0 | | Download bank statements and upload payment files directly from Odoo, using the European EBICS standard
[account_ebics_oe](account_ebics_oe/) | 20.0.1.0.0 | | Place the EBICS menus in the Odoo Enterprise accounting application
[//]: # (end addons)
<!-- prettier-ignore-end -->
+261
View File
@@ -0,0 +1,261 @@
======================
EBICS Banking Protocol
======================
**Exchange files directly with your banks from Odoo, with no portal and nobody logging in.**
EBICS, the Electronic Banking Internet Communication Standard, is the channel European
banks open to companies that want their software to talk to the bank. Bank statements are
downloaded on a schedule and payment files are uploaded from Odoo, authenticated by your
own cryptographic keys instead of a login page.
This module implements that protocol in Odoo. It is developed and maintained by
Noviat, and follows each new version of Odoo, which matters when a bank connection has to
survive your next migration.
If you are still working out whether EBICS is the right channel for you, we explain it
without the jargon, with screen recordings of the flow in Odoo, on
`noviat.com/ebics <https://www.noviat.com/ebics>`_.
.. image:: https://raw.githubusercontent.com/Noviat/account_ebics/19.0/account_ebics/static/description/ebics_flow.png
:alt: Statements come down as camt.053 or camt.052 files, payment files go up as pain.001 or pain.008, and your keys stay on your own server
:width: 100%
What you get
============
- **Statements that arrive on their own.** A scheduled task collects the files your bank
publishes, for every account, and processes them into bank statements.
- **Payments that leave the same way.** A payment batch or a payment order is uploaded to
the bank in the format the bank expects, without exporting a file and re-uploading it
somewhere else.
- **Several companies, one connection.** Keys are held per bank rather than per company:
when fifteen entities bank with the same institution, the bank sends a single daily file
carrying fifteen statements and the module puts each statement in the right company.
- **No bank credentials in Odoo.** The connection uses your own company keys, generated on
your side and kept on your server. Access to the EBICS configuration is a permission of
its own ('EBICS Manager'), separate from ordinary accounting rights.
- **A test mode, where your bank offers one.** French banks accept a test flag, so a file
can be submitted and validated before anything is switched to production. German and
Swiss banks generally do not: there the first payment is a real one, kept small and sent
to an account you control.
- **A trace of every exchange.** Each download and each upload is a record, with the file
it carried, the moment it happened and the user behind it.
**EBICS 2.4**, **EBICS 2.5** and **EBICS 3.0** are supported. EBICS 3.0, the current
specification since December 2022, names what is exchanged with BTF instead of the
country-specific order type codes of EBICS 2.x. Many banks still run 2.4 or 2.5 in parallel.
What travels over the link
==========================
- **Coming in:** camt.053 for the end of day statement, camt.052 for intraday movements
where the bank offers them, and national formats such as the French CFONB.
- **Going out:** pain.001 for credit transfers and pain.008 for direct debits, generated by
Odoo from your payment batches.
We do not process MT940 statements: the format carries bank and country specific variations,
and the Odoo community stopped maintaining a general parser for it after Odoo 10. Where a
bank publishes camt.053 alongside it, which is now the usual case, that is the format to use.
Which banks
===========
Any bank that publishes an EBICS access point can be connected. The standard is maintained by
EBICS SC, a company held by the German, French, Swiss and Austrian banking bodies
(DK, CFONB, SIX and PSA), and it is the standard corporate channel in those countries.
To check a specific bank before you start, joonis publishes a public directory at
`joonis.de/en/fintech/banks <https://www.joonis.de/en/fintech/banks/>`_. Enter a BIC and it
returns the SEPA services the bank offers, the EBICS versions it supports and its Host-ID.
A bank missing from that directory is not a no: it is joonis' own list, not an official
register. Ask your bank whether it publishes an EBICS access point.
What it costs
=============
**This module is free software**, published under LGPL-3. There is no licence fee, no
subscription and no per-connection charge from Noviat.
It does however rely on the `fintech <https://pypi.python.org/pypi/fintech>`_ library from
joonis, and that library requires a **commercial licence for production use**: as soon as
you upload SEPA files with more than five transactions, retrieve statements older than the
last three days, or use the distributed signature. The licence is contracted directly with
joonis, not with Noviat.
joonis charges a one-off setup fee plus a monthly fee per EBICS user id. Current pricing is
published on
`joonis.de <https://www.joonis.de/en/fintech/prices/>`_.
Your bank may also charge a subscription for the EBICS channel itself. It varies from one
bank to another and is billed by the bank, separately from anything on the Odoo side.
Requirements
============
The module depends on two Python libraries:
- `fintech <https://pypi.python.org/pypi/fintech>`_
- `cryptography <https://pypi.python.org/pypi/cryptography>`_
Because the connection needs a Python library and your key files on the server, it runs on
**Odoo.sh** or on an **on-premise** installation.
The EBICS test mode for uploads requires fintech 4.3.4 or higher for EBICS 2.x and fintech
7.2.7 or higher for EBICS 3.0. SWIFT 3SKey support requires fintech 6.4 or higher, and the signature passphrase
fintech 7.3.1 or higher.
Fintech licence
---------------
With a fintech licence, add its parameters to the ``[options]`` section of the Odoo server
configuration file:
- ``fintech_register_name``: the name of the licensee;
- ``fintech_register_keycode``: the keycode of the licensed version.
Example::
; fintech
fintech_register_name = MyCompany
fintech_register_keycode = AB1CD-E2FG-3H-IJ4K-5L
Companion modules
=================
From this repository:
- **EBICS - Odoo Enterprise Integration** (``account_ebics_oe``): required on Odoo
Enterprise; installed automatically.
- **EBICS - Scheduled File Import** (``account_ebics_batch``): downloads and processes the
files of every connection on a schedule.
- **EBICS - Batch Payments (Odoo Enterprise)** (``account_ebics_batch_payment``): uploads
the batch payments of the Odoo Enterprise ``account_batch_payment`` module.
- **EBICS - Payment Orders (OCA)** (``account_ebics_payment_order``): uploads the payment
orders of the OCA ``account_payment_order`` module
(`OCA/bank-payment <https://github.com/OCA/bank-payment>`_).
To process the downloaded statements, install the module of each format you receive:
- **camt.053, camt.052 and camt.054**: ``account_statement_import_camt``
(`OCA/bank-statement-import <https://github.com/OCA/bank-statement-import>`_). For
camt.053, the Odoo Enterprise ``account_bank_statement_import_camt`` works too.
- **French CFONB**: ``account_statement_import_fr_cfonb``
(`OCA/l10n-france <https://github.com/OCA/l10n-france>`_).
Recommended with several financial journals: ``account_usability``
(`OCA/account-financial-tools <https://github.com/OCA/account-financial-tools>`_), which adds
accounting menus such as a list of all bank statements, including those downloaded by the
scheduled import.
Getting your bank online
========================
The configuration on the Odoo side takes fifteen to thirty minutes. What sets the pace of a
project is the bank, and it is almost never for a technical reason:
- **The bank opens the access.** You receive the host ID, the address of the access point,
your partner and user identifiers, and a letter carrying the hash values of the bank's keys.
- **INI and HIA.** Odoo generates your key pairs for signature, authentication and encryption,
sends the public keys to the bank and produces the initialisation letters, which you print,
sign and send. The bank compares them by hand with the keys it received online.
- **HPB.** Once the bank has activated your access, you retrieve its public keys and compare
their hash values with the letter it sent you. That comparison is what makes the channel
trustworthy.
- **The first exchange.** Statements come down first. Payments follow, as a test file where
the bank supports the test flag, otherwise as a real transfer of a small amount.
Count in weeks per bank rather than days, and start the contract and the paperwork early.
Configuration
=============
The menus are those of Odoo Enterprise; on Odoo Community, the application is called
*Invoicing* instead of *Accounting*.
**Who may configure.** In *Settings > Users*, add the users who maintain the EBICS
configuration to the **EBICS Manager** group.
**File formats.** In *Accounting > Configuration > EBICS > EBICS File Formats*, check that the
formats you exchange with your banks are defined; the common ones are created at
installation. A missing format can be reported on
`GitHub <https://github.com/Noviat/account_ebics/issues>`_.
A download format can carry a **Download Process Method**, run by the *Process* button of a
downloaded file: ``camt.053``, ``camt.052``, ``camt.054`` and ``cfonb120``. Each needs the
module of its format (see Companion modules); Odoo tells you which one when it is missing.
**Bank connections.** In *Accounting > Configuration > EBICS > EBICS Configuration*, create one
connection per bank contract, with the identifiers your bank sent you.
.. image:: https://raw.githubusercontent.com/Noviat/account_ebics/19.0/account_ebics/static/description/ebics_download.png
:alt: A downloaded camt.053 statement file in Odoo, before processing
:width: 100%
Usage
=====
The **EBICS Processing** menu, in the top bar of the Accounting application, lists the
downloaded and uploaded files and offers manual downloads and uploads.
Downloaded files are processed into bank statements. Uploads are launched from the payment
batch or the payment order, with the format set in the configuration: on the payment
mode for a payment order, on the journal's payment method for a batch payment.
.. image:: https://raw.githubusercontent.com/Noviat/account_ebics/19.0/account_ebics/static/description/ebics_upload.png
:alt: Uploading a pain.001 SEPA credit transfer file over EBICS 3.0, with the test mode option
:width: 100%
Diagnostics
===========
To diagnose the connection with your bank, add this line to the Odoo server configuration
file::
log_handler = fintech.ebics:DEBUG
EBICS return codes
------------------
During an upload or a download, your bank may return an error code, for example::
EBICS Functional Error:
EBICS_NO_DOWNLOAD_DATA_AVAILABLE (code: 90005)
The codes are explained on `ebics.org <https://www.ebics.org>`_ and in the ``doc`` folder of
this module (``EBICS_Annex1_ReturnCodes``).
Electronic Distributed Signature (EDS)
--------------------------------------
Where your bank supports EBICS T, Odoo prepares the file and holds no signing credentials
at all: the payment is approved in your own signing application, which is what a segregation
of duties policy usually demands. Where it does not, which happens with German and Swiss
banks, the signing key sits on your Odoo server, and you can protect it with a separate
signature passphrase that is never stored and is asked for every signed transaction.
External signing apps include BankingVEU
(`Android <https://play.google.com/store/apps/details?id=subsembly.bankingveu>`_,
`iOS <https://apps.apple.com/de/app/bankingveu/id1578694190>`_).
Roadmap
=======
- Import externally generated keys and certificates (today only the 3SKey signature
certificate).
- Support the SWIFT 3SKey signing JavaScript library
(`SConnect <https://www2.swift.com/3skey/help/sconnect.html>`_).
Issues and pull requests are welcome on
`GitHub <https://github.com/Noviat/account_ebics>`_.
Credits
=======
This module is developed and maintained by `Noviat <https://www.noviat.com>`_, Odoo
integrator in Belgium, specialised in accounting and finance since 2009.
We implement it, we configure the connection with your banks and we support you through the
first cycles. If you want help getting a bank online, tell us which banks you use:
https://www.noviat.com/ebics
+31
View File
@@ -0,0 +1,31 @@
import functools
import logging
from odoo import api
_logger = logging.getLogger(__name__)
try:
from . import models
from . import wizards
except Exception: # noqa: BLE001 - the module must load without fintech
_logger.warning("Import Error, check if fintech lib has been installed")
@functools.cached_property
def neutralized(self):
return bool(
self["ir.config_parameter"].sudo().get_param("database.is_neutralized")
or self["ir.ui.view"]
.sudo()
.search_count(
[
("key", "in", ("web.neutralize_banner", "website.neutralize_ribbon")),
("active", "=", True),
]
)
)
api.Environment.neutralized = neutralized
neutralized.__set_name__(api.Environment, "neutralized")
+35
View File
@@ -0,0 +1,35 @@
# Copyright 2015 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "EBICS Banking Protocol",
"summary": "Download bank statements and upload payment "
"files directly from Odoo, using the European EBICS standard",
"version": "20.0.1.0.0",
"license": "LGPL-3",
"author": "Noviat",
"website": "https://www.noviat.com/",
"category": "Accounting & Finance",
"depends": ["account"],
"data": [
"security/ebics_security.xml",
"security/ir.access.csv",
"data/ebics_file_format.xml",
"views/ebics_config_views.xml",
"views/ebics_file_views.xml",
"views/ebics_userid_views.xml",
"views/ebics_file_format_views.xml",
"wizards/ebics_change_passphrase.xml",
"wizards/ebics_xfer.xml",
"wizards/ebics_admin_order.xml",
"views/menu.xml",
],
"application": True,
"external_dependencies": {
"python": [
"fintech",
"cryptography",
]
},
"images": ["static/description/banner.png"],
}
+216
View File
@@ -0,0 +1,216 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<!-- Download formats -->
<record id="ebics_ff_C52" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">camt.052</field>
<field name="type">down</field>
<field name="order_type">C52</field>
<field name="download_process_method">camt.052</field>
<field
name="description"
>bank to customer account report in format camt.052</field>
<field name="suffix">c52.xml</field>
</record>
<record id="ebics_ff_Z52" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">camt.052</field>
<field name="type">down</field>
<field name="order_type">Z52</field>
<field name="download_process_method">camt.052</field>
<field
name="description"
>bank to customer account report in format camt.052</field>
<field name="suffix">c52.xml</field>
</record>
<record id="ebics_ff_C53" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">camt.053</field>
<field name="type">down</field>
<field name="order_type">C53</field>
<field name="download_process_method">camt.053</field>
<field
name="description"
>Bank to customer statement report in format camt.053</field>
<field name="suffix">c53.xml</field>
</record>
<record id="ebics_ff_Z53" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">camt.053</field>
<field name="type">down</field>
<field name="order_type">Z53</field>
<field name="download_process_method">camt.053</field>
<field
name="description"
>Bank to customer statement report in format camt.053</field>
<field name="suffix">c53.xml</field>
</record>
<record id="ebics_ff_C54" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">camt.054</field>
<field name="type">down</field>
<field name="order_type">C54</field>
<field name="download_process_method">camt.054</field>
<field
name="description"
>Bank to customer debit credit notification in format camt.054</field>
<field name="suffix">c52.xml</field>
</record>
<record id="ebics_ff_Z54" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">camt.054</field>
<field name="type">down</field>
<field name="order_type">Z54</field>
<field name="download_process_method">camt.054</field>
<field
name="description"
>Bank to customer debit credit notification in format camt.054</field>
<field name="suffix">c52.xml</field>
</record>
<record id="ebics_ff_FDL_camt_xxx_cfonb120_stm" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">camt.xxx.cfonb120.stm</field>
<field name="type">down</field>
<field name="order_type">FDL</field>
<field name="download_process_method">cfonb120</field>
<field
name="description"
>Bank to customer statement report in format cfonb120</field>
<field name="suffix">cfonb120.dat</field>
</record>
<record id="ebics_ff_CDZ" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.002</field>
<field name="type">down</field>
<field name="order_type">CDZ</field>
<field
name="description"
>Payment status report for direct debit in format pain.002</field>
<field name="suffix">psr.xml</field>
</record>
<record id="ebics_ff_Z01" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.002</field>
<field name="type">down</field>
<field name="order_type">Z01</field>
<field name="download_process_method">pain.002</field>
<field
name="description"
>Payment status report for direct debit in format pain.002</field>
<field name="suffix">psr.xml</field>
</record>
<record id="ebics_ff_btf_cfonb120" model="ebics.file.format">
<field name="ebics_version">3</field>
<field name="type">down</field>
<field name="order_type">BTD</field>
<field name="download_process_method">cfonb120</field>
<field
name="description"
>Bank to customer statement report in format cfonb120</field>
<field name="suffix">cfonb120.dat</field>
<field name="btf_service">EOP</field>
<field name="btf_message">cfonb120</field>
</record>
<!-- Upload formats -->
<record id="ebics_ff_LCR" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.xxx.cfonb160.dco</field>
<field name="type">up</field>
<field name="order_type">FUL</field>
<field name="description">Remises de LCR</field>
<field name="suffix">txt</field>
</record>
<record id="ebics_ff_CCT" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.001.001.03</field>
<field name="type">up</field>
<field name="order_type">CCT</field>
<field name="description">Payment Order in format pain.001.001.03</field>
<field name="suffix">xml</field>
</record>
<record id="ebics_ff_XE2" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.001.001.03</field>
<field name="type">up</field>
<field name="order_type">XE2</field>
<field name="description">Payment Order in format pain.001.001.03</field>
<field name="suffix">xml</field>
</record>
<record id="ebics_ff_CDD" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.008.001.02.sdd</field>
<field name="type">up</field>
<field name="order_type">CDD</field>
<field
name="description"
>Sepa Core Direct Debit Order in format pain.008.001.02</field>
<field name="suffix">xml</field>
</record>
<record id="ebics_ff_XE3" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.008.001.02.sdd</field>
<field name="type">up</field>
<field name="order_type">XE3</field>
<field
name="description"
>Sepa Core Direct Debit Order in format pain.008.001.02</field>
<field name="suffix">xml</field>
</record>
<record id="ebics_ff_CDB" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.008.001.02.sbb</field>
<field name="type">up</field>
<field name="order_type">CDB</field>
<field
name="description"
>Sepa Direct Debit (B2B) Order in format pain.008.001.02</field>
<field name="suffix">xml</field>
</record>
<record id="ebics_ff_XE4" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.008.001.02.sbb</field>
<field name="type">up</field>
<field name="order_type">XE4</field>
<field
name="description"
>Sepa Direct Debit (B2B) Order in format pain.008.001.02</field>
<field name="suffix">xml</field>
</record>
<record id="ebics_ff_FUL_pain_001_001_02_sct" model="ebics.file.format">
<field name="ebics_version">2</field>
<field name="name">pain.001.001.02.sct</field>
<field name="type">up</field>
<field name="order_type">FUL</field>
<field name="description">Payment Order in format pain.001.001.02</field>
<field name="suffix">xml</field>
</record>
<record id="ebics_ff_btf_SCT" model="ebics.file.format">
<field name="ebics_version">3</field>
<field name="type">up</field>
<field name="order_type">BTU</field>
<field name="description">SEPA credit transfer</field>
<field name="btf_service">SCT</field>
<field name="btf_message">pain.001</field>
<field name="btf_scope">GLB</field>
</record>
</odoo>
+1
View File
@@ -0,0 +1 @@
UPDATE ebics_userid SET active = false;
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+7
View File
@@ -0,0 +1,7 @@
from . import fintech_ebics_register
from . import account_bank_statement
from . import account_journal
from . import ebics_config
from . import ebics_file
from . import ebics_file_format
from . import ebics_userid
@@ -0,0 +1,11 @@
# Copyright 2009-2024 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from odoo import fields, models
class AccountBankStatement(models.Model):
_inherit = "account.bank.statement"
ebics_file_id = fields.Many2one(comodel_name="ebics.file", string="EBICS Data File")
import_format = fields.Char(readonly=True)
+28
View File
@@ -0,0 +1,28 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from odoo import api, fields, models
class AccountJournal(models.Model):
_inherit = "account.journal"
ebics_config_ids = fields.Many2many(
comodel_name="ebics.config",
relation="account_journal_ebics_config_rel",
readonly=True,
string="EBICS Configs",
)
ebics_config_id = fields.Many2one(
comodel_name="ebics.config",
compute="_compute_ebics_config_id",
compute_sudo=True,
string="EBICS Config",
)
@api.depends("ebics_config_ids")
def _compute_ebics_config_id(self):
for rec in self:
rec.ebics_config_id = rec.ebics_config_ids.filtered(
lambda r: r.state == "confirm"
)[:1]
+204
View File
@@ -0,0 +1,204 @@
# Copyright 2009-2024 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import logging
import os
import re
from odoo import api, fields, models
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__) # lint-ignore=unused-logger
class EbicsConfig(models.Model):
"""
EBICS configuration is stored in a separate object in order to
allow extra security policies on this object.
"""
_name = "ebics.config"
_description = "EBICS Configuration"
_order = "name"
name = fields.Char(
required=True,
)
journal_ids = fields.Many2many(
comodel_name="account.journal",
relation="account_journal_ebics_config_rel",
string="Bank Accounts",
domain="[('type', '=', 'bank')]",
)
ebics_host = fields.Char(
string="EBICS HostID",
required=True,
help="Contact your bank to get the EBICS HostID."
"\nIn France the BIC is usually allocated to the HostID "
"whereas in Germany it tends to be an institute specific string "
"of 8 characters.",
)
ebics_url = fields.Char(
string="EBICS URL",
required=True,
help="Contact your bank to get the EBICS URL.",
)
ebics_version = fields.Selection(
selection=[
("H003", "H003 (2.4)"),
("H004", "H004 (2.5)"),
("H005", "H005 (3.0)"),
],
string="EBICS protocol version",
required=True,
default="H004",
)
ebics_partner = fields.Char(
string="EBICS PartnerID",
required=True,
help="Organizational unit (company or individual) "
"that concludes a contract with the bank. "
"\nIn this contract it will be agreed which order types "
"(file formats) are used, which accounts are concerned, "
"which of the customer's users (subscribers) "
"communicate with the EBICS bank server and the authorisations "
"that these users will possess. "
"\nIt is identified by the PartnerID.",
)
ebics_userid_ids = fields.One2many(
comodel_name="ebics.userid",
inverse_name="ebics_config_id",
string="EBICS UserID",
help="Human users or a technical system that is/are "
"assigned to a customer. "
"\nOn the EBICS bank server it is identified "
"by the combination of UserID and PartnerID. "
"The technical subscriber serves only for the data exchange "
"between customer and financial institution. "
"The human user also can authorise orders.",
)
# We store the EBICS keys in a separate directory in the file system.
# This directory requires special protection to reduce fraude.
ebics_keys = fields.Char(
string="EBICS Keys Root",
required=True,
default=lambda self: self._default_ebics_keys(),
help="Root Directory for storing the EBICS Keys.",
)
ebics_key_version = fields.Selection(
selection=[("A005", "A005 (RSASSA-PKCS1-v1_5)"), ("A006", "A006 (RSASSA-PSS)")],
string="EBICS key version",
default="A006",
help="The key version of the electronic signature.",
)
ebics_key_bitlength = fields.Integer(
string="EBICS key bitlength",
default=2048,
help="The bit length of the generated keys. "
"\nThe value must be between 1536 and 4096.",
)
ebics_file_format_ids = fields.Many2many(
comodel_name="ebics.file.format",
column1="config_id",
column2="format_id",
string="EBICS File Format",
)
state = fields.Selection(
selection=[("draft", "Draft"), ("confirm", "Confirmed")],
default="draft",
required=True,
readonly=True,
)
order_number = fields.Char(
size=4,
help="Specify the number for the next order."
"\nThis number should match the following pattern : "
"[A-Z]{1}[A-Z0-9]{3}",
)
active = fields.Boolean(default=True)
company_ids = fields.Many2many(
comodel_name="res.company",
relation="ebics_config_res_company_rel",
string="Companies",
compute="_compute_company_ids",
store=True,
help="Companies sharing this EBICS contract.",
)
@api.model
def _default_ebics_keys(self):
return f"/etc/odoo/ebics_keys/{self.env.cr.dbname}"
@api.constrains("ebics_key_bitlength")
def _check_ebics_key_bitlength(self):
for cfg in self:
if cfg.ebics_version == "H005" and cfg.ebics_key_bitlength < 2048:
raise UserError(self.env._("EBICS key bitlength must be >= 2048."))
@api.constrains("order_number")
def _check_order_number(self):
for cfg in self:
nbr = cfg.order_number
ok = True
if nbr:
if len(nbr) != 4:
ok = False
else:
pattern = re.compile("[A-Z]{1}[A-Z0-9]{3}")
if not pattern.match(nbr):
ok = False
if not ok:
raise UserError(
self.env._( # pylint: disable=W8120
"Order Number should comply with the following pattern:"
"\n[A-Z]{1}[A-Z0-9]{3}"
)
)
@api.depends("journal_ids.company_id")
def _compute_company_ids(self):
for rec in self:
rec.company_ids = rec.journal_ids.mapped("company_id")
@api.ondelete(at_uninstall=False)
def _unlink_except_confirm(self):
if any(rec.state == "confirm" for rec in self):
raise UserError(
self.env._("You cannot remove active EBICS configurations.")
)
def set_to_draft(self):
return self.write({"state": "draft"})
def set_to_confirm(self):
return self.write({"state": "confirm"})
def _get_order_number(self):
return self.order_number
def _update_order_number(self, OrderID):
o_list = list(OrderID)
for i, c in enumerate(reversed(o_list), start=1):
if c == "9":
o_list[-i] = "A"
break
if c == "Z":
o_list[-i] = "0"
continue
o_list[-i] = chr(ord(c) + 1)
break
next_order_number = "".join(o_list)
if "ZZZZ" in (OrderID, next_order_number):
next_order_number = "A000"
self.order_number = next_order_number
def _check_ebics_keys(self):
dirname = self.ebics_keys or ""
if not os.path.exists(dirname):
raise UserError(
self.env._(
"EBICS Keys Root Directory %(dir)s is not available."
"\nPlease contact your system administrator.",
dir=dirname,
)
)
+658
View File
@@ -0,0 +1,658 @@
# Copyright 2009-2025 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import logging
from copy import deepcopy
from sys import exc_info
from traceback import format_exception
from lxml import etree
from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.modules import module as odoo_module
from odoo.addons.base.models.res_partner_bank import sanitize_account_number
_logger = logging.getLogger(__name__) # lint-ignore=unused-logger
DUP_CHECK_FORMATS = ["cfonb120", "camt053"]
class EbicsFile(models.Model):
_name = "ebics.file"
_description = "Object to store EBICS Data Files"
_order = "date desc"
_name_uniq = models.Constraint(
"unique (name, format_id)",
"This File has already been down- or uploaded !",
)
name = fields.Char(string="Filename")
data = fields.Binary(string="File", readonly=True)
format_id = fields.Many2one(
comodel_name="ebics.file.format", string="EBICS File Formats", readonly=True
)
download_process_method = fields.Selection(
related="format_id.download_process_method"
)
type = fields.Selection(related="format_id.type")
date_from = fields.Date(
readonly=True, help="'Date From' as entered in the download wizard."
)
date_to = fields.Date(
readonly=True, help="'Date To' as entered in the download wizard."
)
date = fields.Datetime(
required=True, readonly=True, help="File Upload/Download date"
)
bank_statement_ids = fields.One2many(
comodel_name="account.bank.statement",
inverse_name="ebics_file_id",
string="Generated Bank Statements",
readonly=True,
)
state = fields.Selection(
[("draft", "Draft"), ("done", "Done")],
default="draft",
required=True,
readonly=True,
)
user_id = fields.Many2one(
comodel_name="res.users",
default=lambda self: self.env.user,
readonly=True,
)
ebics_userid_id = fields.Many2one(
comodel_name="ebics.userid",
string="EBICS UserID",
ondelete="restrict",
readonly=True,
)
note = fields.Text(string="Notes")
ebics_order_number = fields.Char(string="EBICS OrderID", readonly=True)
pain_state = fields.Selection(
[("draft", "Draft"), ("uploaded", "Uploaded"), ("error", "Error")],
default="draft",
readonly=True,
)
note_process = fields.Text(
string="Process Notes",
readonly=True,
)
company_ids = fields.Many2many(
comodel_name="res.company",
string="Companies",
readonly=True,
help="Companies sharing this EBICS file.",
)
@api.ondelete(at_uninstall=False)
def _unlink_except_done(self):
if any(rec.state == "done" for rec in self):
raise UserError(
self.env._("You can only remove EBICS files in state 'Draft'.")
)
def unlink(self):
ff_methods = self._file_format_methods()
for ebics_file in self:
# execute format specific actions
ff = ebics_file.format_id.download_process_method
if ff in ff_methods:
if ff_methods[ff].get("unlink"):
ff_methods[ff]["unlink"]()
# remove bank statements
ebics_file.bank_statement_ids.unlink()
return super().unlink()
def set_to_draft(self):
return self.write({"state": "draft"})
def set_to_done(self):
return self.write({"state": "done"})
def process(self):
self.ensure_one()
self = self.with_context(allowed_company_ids=self.env.user.company_ids.ids)
self.note_process = ""
ff_methods = self._file_format_methods()
ff = self.format_id.download_process_method
if ff in ff_methods:
if ff_methods[ff].get("process"):
res = ff_methods[ff]["process"]()
self.state = "done"
return res
else:
return self._process_undefined_format()
def action_open_bank_statements(self):
self.ensure_one()
action = self.env["ir.actions.act_window"]._for_xml_id(
"account.action_bank_statement_tree"
)
domain = [("id", "in", self.env.context.get("statement_ids"))]
action["domain"] = domain
return action
def button_close(self):
self.ensure_one()
return {"type": "ir.actions.act_window_close"}
def _file_format_methods(self):
"""
Extend this dictionary in order to add support
for extra file formats.
"""
res = {
"cfonb120": {
"process": self._process_cfonb120,
"unlink": self._unlink_cfonb120,
},
"camt.052": {
"process": self._process_camt052,
"unlink": self._unlink_camt052,
},
"camt.053": {
"process": self._process_camt053,
"unlink": self._unlink_camt053,
},
"camt.054": {
"process": self._process_camt054,
"unlink": self._unlink_camt054,
},
"pain.002": {
"process": self._process_pain002,
"unlink": self._unlink_pain002,
},
}
return res
def _check_import_module(self, module, raise_if_not_found=True):
mod = (
self.env["ir.module.module"]
.sudo()
.search([("name", "=like", module), ("state", "=", "installed")])
)
if not mod:
if raise_if_not_found:
raise UserError(
self.env._(
"The module to process the '%(ebics_format)s' format is not "
"installed on your system. "
"\nPlease install module '%(module)s'",
ebics_format=self.format_id.name,
module=module,
)
)
return False
return True
def _lookup_journal(self, res, acc_number, currency_code):
currency = self.env["res.currency"].search(
[("name", "=ilike", currency_code)], limit=1
)
journal = self.env["account.journal"]
if not currency:
message = self.env._("Currency %(cc)s not found.", cc=currency_code)
res["notifications"].append({"type": "error", "message": message})
return (currency, journal)
journals = self.env["account.journal"].search(
[
("type", "=", "bank"),
(
"bank_account_id.sanitized_account_number",
"ilike",
acc_number,
),
]
)
if not journals:
message = self.env._(
"No financial journal found for Account Number %(nbr)s, "
"Currency %(cc)s",
nbr=acc_number,
cc=currency_code,
)
res["notifications"].append({"type": "error", "message": message})
return (currency, journal)
for jrnl in journals:
journal_currency = jrnl.currency_id or jrnl.company_id.currency_id
if journal_currency != currency:
continue
journal = jrnl
break
if not journal:
message = self.env._(
"No financial journal found for Account Number %(nbr)s, "
"Currency %(cc)s",
nbr=acc_number,
cc=currency_code,
)
res["notifications"].append({"type": "error", "message": message})
return (currency, journal)
def _process_download_result(self, res, file_format=None):
"""
We perform a duplicate statement check after the creation of the bank
statements since we rely on Odoo Enterprise or OCA modules for the
bank statement creation.
From a development standpoint (code creation/maintenance) a check after
creation is the easiest way.
"""
statement_ids = res["statement_ids"]
notifications = res["notifications"]
statements = self.env["account.bank.statement"].sudo().browse(statement_ids)
if statements:
statements.write({"import_format": file_format})
statements = self._statement_duplicate_check(res, statements)
elif not notifications:
notifications.append(
{
"type": "warning",
"message": self.env._("This file doesn't contain any transaction."),
}
)
st_cnt = len(statements)
warning_cnt = error_cnt = 0
if notifications:
errors = []
warnings = []
for notif in notifications:
if isinstance(notif, dict):
if notif.get("type") == "error":
error_cnt += 1
parts = [notif[k] for k in notif if k in ("message", "details")]
errors.append("\n".join(parts) + "\n")
elif notif.get("type") == "warning":
warning_cnt += 1
parts = [notif[k] for k in notif if k in ("message", "details")]
warnings.append("\n".join(parts) + "\n")
else:
warning_cnt += 1
warnings.append(": ".join([*next(iter(notif.items()))]) + "\n")
elif isinstance(notif, str):
warning_cnt += 1
warnings.append(notif + "\n")
self.note_process += self.env._("Process file %(fn)s results:", fn=self.name)
if error_cnt:
self.note_process += "\n\n" + self.env._("Errors") + ":\n"
self.note_process += "\n".join(errors)
self.note_process += "\n\n"
self.note_process += self.env._("Number of errors: %(nr)s", nr=error_cnt)
if warning_cnt:
self.note_process += "\n\n" + self.env._("Warnings") + ":\n"
self.note_process += "\n".join(warnings)
self.note_process += "\n\n"
self.note_process += self.env._(
"Number of warnings: %(nr)s", nr=warning_cnt
)
self.note_process += "\n"
if st_cnt:
self.note_process += "\n\n"
self.note_process += self.env._(
"%(st_cnt)s bank statement%(sp)s been imported: ",
st_cnt=st_cnt,
sp=(st_cnt == 1 and self.env._(" has")) or self.env._("s have"),
)
self.note_process += "\n"
for statement in statements:
self.note_process += "\n" + self.env._(
"Statement %(st)s dated %(date)s (Company: %(cpy)s)",
st=statement.name,
date=statement.date,
cpy=statement.company_id.name,
)
if statements:
self.sudo().bank_statement_ids = [(4, x) for x in statements.ids]
company_ids = self.sudo().bank_statement_ids.mapped("company_id").ids
self.company_ids = [(6, 0, company_ids)]
ctx = dict(self.env.context, statement_ids=statements.ids)
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref(f"{module}.ebics_file_view_form_result")
return {
"name": self.env._("Import EBICS File"),
"res_id": self.id,
"view_mode": "form",
"res_model": self._name,
"view_id": result_view.id,
"target": "new",
"context": ctx,
"type": "ir.actions.act_window",
}
def _statement_duplicate_check(self, res, statements):
"""
This check is required for import modules that do not
set the 'unique_import_id' on the statement lines.
E.g. OCA camt import
"""
to_unlink = self.env["account.bank.statement"]
for statement in statements.filtered(
lambda r: r.import_format in DUP_CHECK_FORMATS
):
dup = self.env["account.bank.statement"].search_count(
[
("id", "!=", statement.id),
("name", "=", statement.name),
("company_id", "=", statement.company_id.id),
("date", "=", statement.date),
("import_format", "=", statement.import_format),
]
)
if dup:
message = self.env._(
"Statement %(st_name)s dated %(date)s has already been imported.",
st_name=statement.name,
date=statement.date,
)
res["notifications"].append({"type": "warning", "message": message})
to_unlink += statement
res["statement_ids"] = [
x for x in res["statement_ids"] if x not in to_unlink.ids
]
statements -= to_unlink
to_unlink.unlink()
return statements
def _process_cfonb120(self):
import_module = "account_statement_import_fr_cfonb"
self._check_import_module(import_module)
res = {"statement_ids": [], "notifications": []}
st_datas = self._split_cfonb(res)
if st_datas:
self._process_bank_statement_oca(res, st_datas)
return self._process_download_result(res, file_format="cfonb120")
def _unlink_cfonb120(self):
"""
Placeholder for cfonb120 specific actions before removing the
EBICS data file and its related bank statements.
"""
def _split_cfonb(self, res):
"""
Split CFONB file received via EBICS per statement.
Statements without transactions are removed.
"""
datas = []
file_data = bytes(self.data).replace(b"\n", b"").replace(b"\r", b"")
if len(file_data) % 120:
message = self.env._(
"Incorrect CFONB120 file:\nthe file is not divisible in 120 char lines"
)
res["notifications"].append({"type": "error", "message": message})
return datas
lines = [file_data[i : i + 120] for i in range(0, len(file_data), 120)]
st_lines = b""
transactions = False
for line in lines:
rec_type = line[0:2]
currency_code = line[16:19].decode()
acc_number = line[21:32].decode()
st_lines += line + b"\n"
if rec_type == b"04":
transactions = True
if rec_type == b"07":
if transactions:
currency, journal = self._lookup_journal(
res, acc_number, currency_code
)
if currency and journal:
datas.append(
{
"acc_number": acc_number,
"journal_id": journal.id,
"company_id": journal.company_id.id,
"data": st_lines,
}
)
st_lines = b""
transactions = False
return datas
def _process_camt052(self):
import_module = "account_statement_import_camt"
self._check_import_module(import_module)
return self._process_camt053(file_format="camt052")
def _unlink_camt052(self):
"""
Placeholder for camt052 specific actions before removing the
EBICS data file and its related bank statements.
"""
def _process_camt054(self):
import_module = "account_statement_import_camt"
self._check_import_module(import_module)
return self._process_camt053(file_format="camt054")
def _unlink_camt054(self):
"""
Placeholder for camt054 specific actions before removing the
EBICS data file and its related bank statements.
"""
def _process_camt053(self, file_format=None):
"""
The Odoo standard statement import is based on manual selection
of a financial journal before importing the electronic statement file.
An EBICS download may return a single file containing a large number of
statements from different companies/journals.
Hence we need to split the CAMT file into
single statement CAMT files before we can call the logic
implemented by the Odoo OE or Community CAMT parsers.
"""
modules = [
("oca", "account_statement_import_camt"),
("oe", "account_bank_statement_import_camt"),
]
author = False
for entry in modules:
if self._check_import_module(entry[1], raise_if_not_found=False):
author = entry[0]
break
if not author:
raise UserError(
self.env._(
"The module to process the '%(ebics_format)s' format is "
"not installed on your system. "
"\nPlease install one of the following modules: \n%(modules)s.",
ebics_format=self.format_id.name,
modules=", ".join([x[1] for x in modules]),
)
)
res = {"statement_ids": [], "notifications": []}
st_datas = self._split_camt(res)
if author == "oca":
self._process_bank_statement_oca(res, st_datas)
else:
self._process_bank_statement_oe(res, st_datas)
file_format = file_format or "camt053"
return self._process_download_result(res, file_format=file_format)
def _process_bank_statement_oca(self, res, st_datas):
for st_data in st_datas:
try:
with self.env.cr.savepoint():
self._create_bank_statement_oca(res, st_data)
except UserError as e:
res["notifications"].append(
{"type": "error", "message": "".join(e.args)}
)
# Each statement fails alone; the traceback is reported to the user
except Exception: # noqa: BLE001
tb = "".join(format_exception(*exc_info()))
res["notifications"].append({"type": "error", "message": tb})
def _create_bank_statement_oca(self, res, st_data):
wiz = (
self.env["account.statement.import"]
.with_company(st_data["company_id"])
.with_context(active_model="ebics.file")
.create({"statement_filename": self.name})
)
wiz.import_single_file(st_data["data"], res)
def _process_bank_statement_oe(self, res, st_datas):
"""
We execute a cr.commit() after every statement import since we get a
'savepoint does not exist' error when using 'with self.env.cr.savepoint()'.
The commit is skipped when running tests.
"""
# Registry.in_test_mode() and thread.testing are gone in 19.0
testing = odoo_module.current_test
for st_data in st_datas:
try:
self._create_bank_statement_oe(res, st_data)
if not testing:
self.env.cr.commit() # pylint: disable=E8102
except UserError as e:
msg = "".join(e.args)
msg += "\n"
msg += self.env._(
"Statement for Account Number %(nr)s has not been processed.",
nr=st_data["acc_number"],
)
res["notifications"].append({"type": "error", "message": msg})
# Each statement fails alone; the traceback is reported to the user
except Exception: # noqa: BLE001
tb = "".join(format_exception(*exc_info()))
res["notifications"].append({"type": "error", "message": tb})
def _create_bank_statement_oe(self, res, st_data):
attachment = (
self.env["ir.attachment"]
.with_company(st_data["company_id"])
.create(
{
"name": self.name,
"raw": st_data["data"],
}
)
)
journal = (
self.env["account.journal"]
.with_company(st_data["company_id"])
.browse(st_data["journal_id"])
)
act = journal._import_bank_statement(attachment)
for entry in act["domain"]:
if (
isinstance(entry, tuple)
and entry[0] == "statement_id"
and entry[1] == "in"
):
res["statement_ids"].extend(entry[2])
break
notifications = act["context"]["notifications"]
if notifications:
res["notifications"].append(act["context"]["notifications"])
def _unlink_camt053(self):
"""
Placeholder for camt053 specific actions before removing the
EBICS data file and its related bank statements.
"""
def _split_camt(self, res):
"""
Split CAMT file received via EBICS per statement.
Statements without transactions are removed.
"""
datas = []
file_data = bytes(self.data)
try:
root = etree.fromstring(file_data, parser=etree.XMLParser(recover=True))
except etree.XMLSyntaxError:
root = None
if root is None:
message = self.env._("Invalid XML file.")
res["notifications"].append({"type": "error", "message": message})
return datas
ns = {k or "ns": v for k, v in root.nsmap.items()}
camt_variant = ns["ns"].split("camt.")[1][:3]
variant_tags = {
"052": "Rpt",
"053": "Stmt",
"054": "Ntfctn",
}
camt_tag = variant_tags[camt_variant]
stmts = root[0].findall(f"ns:{camt_tag}", ns)
for i, stmt in enumerate(stmts):
acc_ids = stmt.xpath(
"ns:Acct/ns:Id/ns:IBAN/text() | ns:Acct/ns:Id/ns:Othr/ns:Id/text()",
namespaces=ns,
)
acc_number = acc_ids and sanitize_account_number(acc_ids[0])
if not acc_number:
message = self.env._("No bank account number found.")
res["notifications"].append({"type": "error", "message": message})
continue
if not stmt.findall("ns:Ntry", ns):
continue
currency_codes = stmt.xpath(
"ns:Acct/ns:Ccy/text() | ns:Bal/ns:Amt/@Ccy", namespaces=ns
)
if not currency_codes and camt_variant == "054":
currency_codes = stmt.xpath("ns:Ntry/ns:Amt/@Ccy", namespaces=ns)
if not currency_codes:
message = self.env._(
"No currency found in statement for Account Number %(nbr)s.",
nbr=acc_number,
)
res["notifications"].append({"type": "error", "message": message})
continue
currency_code = currency_codes[0]
# some banks (e.g. COMMERZBANK) add the currency as the last 3 digits
# of the bank account number hence we need to remove this since otherwise
# the journal matching logic fails
if acc_number[-3:] == currency_code:
acc_number = acc_number[:-3]
root_new = deepcopy(root)
for j, el in enumerate(root_new[0].findall(f"ns:{camt_tag}", ns)):
if j != i:
el.getparent().remove(el)
currency, journal = self._lookup_journal(res, acc_number, currency_code)
if not (currency and journal):
continue
datas.append(
{
"acc_number": acc_number,
"journal_id": journal.id,
"company_id": journal.company_id.id,
"data": etree.tostring(root_new),
}
)
return datas
def _process_pain002(self):
"""
Placeholder for processing pain.002 files.
TODO:
add import logic based upon OCA 'account_payment_return_import'
"""
def _unlink_pain002(self):
"""
Placeholder for pain.002 specific actions before removing the
EBICS data file.
"""
def _process_undefined_format(self):
raise UserError(
self.env._(
"The current version of the 'account_ebics' module "
"has no support to automatically process EBICS files "
"with format %s.",
self.format_id.name,
)
)
+119
View File
@@ -0,0 +1,119 @@
# Copyright 2009-2024 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from odoo import api, fields, models
class EbicsFileFormat(models.Model):
_name = "ebics.file.format"
_description = "EBICS File Formats"
_order = "type,name,order_type"
ebics_version = fields.Selection(
selection=[
("2", "2"),
("3", "3"),
],
string="EBICS protocol version",
required=True,
default="2",
)
name = fields.Char(
string="Request Type",
help="E.g. camt.xxx.cfonb120.stm, pain.001.001.03.sct.\n"
"Specify camt.052, camt.053, camt.054 for camt "
"Order Types such as C53, Z53, C54, Z54.\n"
"This name has to match the 'Request Type' in your "
"EBICS contract for Order Type 'FDL' or 'FUL'.\n",
)
type = fields.Selection(
selection=[("down", "Download"), ("up", "Upload")], required=True
)
order_type = fields.Char(
required=True,
help="EBICS 3.0: BTD (download) or BTU (upload).\n"
"EBICS 2.0: E.g. C53 (check your EBICS contract). "
"For most banks in France you should use the "
"format neutral Order Types 'FUL' for upload "
"and 'FDL' for download.",
)
download_process_method = fields.Selection(
selection="_selection_download_process_method",
help="Enable processing within Odoo of the downloaded file "
"via the 'Process' button."
"E.g. specify camt.053 to import a camt.053 file and create "
"a bank statement.",
)
# TODO:
# move signature_class parameter so that it can be set per EBICS config
signature_class = fields.Selection(
selection=[("E", "Single signature"), ("T", "Transport signature")],
help="Please doublecheck the security of your Odoo "
"ERP system when using class 'E' to prevent unauthorised "
"users to make supplier payments."
"\nLeave this field empty to use the default "
"defined for your EBICS UserID.",
)
description = fields.Char()
suffix = fields.Char(
help="Specify the filename suffix for this File Format.\nE.g. c53.xml",
)
# EBICS 3.0 BTF
btf_service = fields.Char(
string="BTF Service",
help="BTF Service Name)\n"
"The service code name consisting of 3 alphanumeric characters "
"[A-Z0-9] (e.g. SCT, SDD, STM, EOP)",
)
btf_message = fields.Char(
string="BTF Message Name",
help="BTF Message Name\n"
"The message name consisting of up to 10 alphanumeric characters "
"[a-z0-9.] (eg. pain.001, pain.008, camt.053)",
)
btf_scope = fields.Char(
string="BTF Scope",
help="Scope of service.\n"
"Either an ISO-3166 ALPHA 2 country code or an issuer code "
"of 3 alphanumeric characters [A-Z0-9].",
)
btf_option = fields.Char(
string="BTF Option",
help="The service option code consisting of 3-10 alphanumeric "
"characters [A-Z0-9] (eg. COR, B2B)",
)
btf_container = fields.Char(
string="BTF Container",
help="Type of container consisting of 3 characters [A-Z] (eg. XML, ZIP).",
)
btf_version = fields.Char(
string="BTF Version",
help="Message version consisting of 2 numeric characters [0-9] (eg. 03).",
)
btf_variant = fields.Char(
string="BTF Variant",
help="Message variant consisting of 3 numeric characters [0-9] (eg. 001).",
)
btf_format = fields.Char(
string="BTF Format",
help="Message format consisting of 1-4 alphanumeric characters [A-Z0-9] "
"(eg. XML, JSON, PDF).",
)
@api.model
def _selection_download_process_method(self):
methods = self.env["ebics.file"]._file_format_methods().keys()
return [(x, x) for x in methods]
@api.onchange("type")
def _onchange_type(self):
if self.type == "up":
self.download_process_method = False
@api.depends("ebics_version", "name", "btf_message", "description")
def _compute_display_name(self):
for rec in self:
name = (rec.ebics_version == "2" and rec.name) or rec.btf_message
if rec.description:
name += " - " + rec.description
rec.display_name = name
+609
View File
@@ -0,0 +1,609 @@
# Copyright 2009-2024 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import base64
import logging
import os
from sys import exc_info
from traceback import format_exception
from urllib.error import URLError
from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.tools.binary import BinaryBytes
_logger = logging.getLogger(__name__)
try:
import fintech
from fintech.ebics import (
EbicsBank,
EbicsClient,
EbicsFunctionalError,
EbicsKeyRing,
EbicsTechnicalError,
EbicsUser,
)
fintech.cryptolib = "cryptography"
except ImportError:
_logger.warning("Failed to import fintech")
INI_LETTER_LANGS = ["en", "de", "fr"]
class EbicsBank(EbicsBank):
def _next_order_id(self, partnerid):
"""
EBICS protocol version H003 requires generation of the OrderID.
The OrderID must be a string between 'A000' and 'ZZZZ' and
unique for each partner id.
"""
return (hasattr(self, "_order_number") and self._order_number) or "A000"
class EbicsUserID(models.Model):
_name = "ebics.userid"
_description = "EBICS UserID"
_order = "name"
name = fields.Char(
string="EBICS UserID",
required=True,
help="Human users or a technical system that is/are "
"assigned to a customer. "
"\nOn the EBICS bank server it is identified "
"by the combination of UserID and PartnerID. "
"The technical subscriber serves only for the data exchange "
"between customer and financial institution. "
"The human user also can authorise orders.",
)
ebics_config_id = fields.Many2one(
comodel_name="ebics.config",
string="EBICS Configuration",
ondelete="cascade",
required=True,
)
ebics_version = fields.Selection(related="ebics_config_id.ebics_version")
user_ids = fields.Many2many(
comodel_name="res.users",
string="Users",
required=True,
domain=[("share", "=", False)],
help="Users who are allowed to use this EBICS UserID for bank transactions.",
)
signature_class = fields.Selection(
selection=[("E", "Single signature"), ("T", "Transport signature")],
required=True,
default="T",
help="Default signature class."
"This default can be overriden for specific "
"EBICS transactions (cf. File Formats).",
)
transaction_rights = fields.Selection(
selection=[
("both", "Download and Upload"),
("down", "Download Only"),
("up", "Upload Only"),
],
string="Allowed Transactions",
default="both",
required=True,
help="Use this parameter to limit the transactions for this User "
"to downloads or uploads.",
)
ebics_keys_fn = fields.Char(compute="_compute_ebics_keys_fn")
ebics_keys_found = fields.Boolean(compute="_compute_ebics_keys_found")
ebics_passphrase = fields.Char(string="EBICS Passphrase")
ebics_passphrase_store = fields.Boolean(
string="Store EBICS Passphrase",
default=True,
help="When you uncheck this option the passphrase to unlock "
"your private key will not be stored in the database. "
"We recommend to use this if you want to upload signed "
"payment orders via EBICS.\nYou will be prompted to enter the "
"passphrase for every EBICS transaction, hence do not uncheck this "
"option on a userid for automated EBICS downloads.",
)
ebics_passphrase_required = fields.Boolean(
compute="_compute_ebics_passphrase_view_modifiers"
)
ebics_passphrase_invisible = fields.Boolean(
compute="_compute_ebics_passphrase_view_modifiers"
)
ebics_passphrase_store_readonly = fields.Boolean(
compute="_compute_ebics_passphrase_view_modifiers"
)
ebics_sig_passphrase = fields.Char(
string="EBICS Signature Passphrase",
help="You can set here a different passphrase for the EBICS "
"signing key. This passphrase will never be stored hence "
"you'll need to specify your passphrase for each transaction that "
"requires a digital signature.",
)
ebics_sig_passphrase_invisible = fields.Boolean(
compute="_compute_ebics_sig_passphrase_invisible"
)
ebics_ini_letter = fields.Binary(
string="EBICS INI Letter",
readonly=True,
help="INI-letter PDF document to be sent to your bank.",
)
ebics_ini_letter_fn = fields.Char(string="INI-letter Filename", readonly=True)
ebics_public_bank_keys = fields.Binary(
string="EBICS Public Bank Keys",
readonly=True,
help="EBICS Public Bank Keys to be checked for consistency.",
)
ebics_public_bank_keys_fn = fields.Char(
string="EBICS Public Bank Keys Filename", readonly=True
)
swift_3skey = fields.Boolean(
string="Enable 3SKey support",
help="Transactions for this user will be signed "
"by means of the SWIFT 3SKey token.",
)
swift_3skey_certificate = fields.Binary(string="3SKey Certficate")
swift_3skey_certificate_fn = fields.Char(string="3SKey Certificate Filename")
# X.509 Distinguished Name attributes used to
# create self-signed X.509 certificates
ebics_key_x509 = fields.Boolean(
string="X509 support",
help="Set this flag in order to work with self-signed X.509 certificates",
)
ebics_key_x509_dn_cn = fields.Char(
string="Common Name [CN]",
)
ebics_key_x509_dn_o = fields.Char(
string="Organization Name [O]",
)
ebics_key_x509_dn_ou = fields.Char(
string="Organizational Unit Name [OU]",
)
ebics_key_x509_dn_c = fields.Char(
string="Country Name [C]",
)
ebics_key_x509_dn_st = fields.Char(
string="State Or Province Name [ST]",
)
ebics_key_x509_dn_l = fields.Char(
string="Locality Name [L]",
)
ebics_key_x509_dn_e = fields.Char(
string="Email Address",
)
state = fields.Selection(
[
("draft", "Draft"),
("init", "Initialisation"),
("get_bank_keys", "Get Keys from Bank"),
("to_verify", "Verification"),
("active_keys", "Active Keys"),
],
default="draft",
required=True,
readonly=True,
)
active = fields.Boolean(default=True)
company_ids = fields.Many2many(
comodel_name="res.company",
string="Companies",
required=True,
help="Companies sharing this EBICS contract.",
)
@api.depends("name", "ebics_config_id.ebics_keys")
def _compute_ebics_keys_fn(self):
for rec in self:
keys_dir = rec.ebics_config_id.ebics_keys
rec.ebics_keys_fn = (
rec.name
and keys_dir
and (keys_dir + "/" + rec.name.replace(" ", "_") + "_keys")
)
@api.depends("ebics_keys_fn")
def _compute_ebics_keys_found(self):
for rec in self:
rec.ebics_keys_found = rec.ebics_keys_fn and os.path.isfile(
rec.ebics_keys_fn
)
@api.depends("state", "ebics_passphrase", "ebics_keys_found")
def _compute_ebics_passphrase_view_modifiers(self):
for rec in self:
rec.ebics_passphrase_required = False
rec.ebics_passphrase_invisible = True
rec.ebics_passphrase_store_readonly = True
if rec.state == "draft":
rec.ebics_passphrase_required = True
rec.ebics_passphrase_invisible = (
rec.ebics_keys_found and True
) or False
rec.ebics_passphrase_store_readonly = False
elif rec.state == "init":
rec.ebics_passphrase_required = False
rec.ebics_passphrase_invisible = True
elif rec.state in ("get_bank_keys", "to_verify"):
rec.ebics_passphrase_required = not rec.ebics_passphrase
rec.ebics_passphrase_invisible = rec.ebics_passphrase
@api.depends("state")
def _compute_ebics_sig_passphrase_invisible(self):
for rec in self:
rec.ebics_sig_passphrase_invisible = True
if fintech.__version_info__ < (7, 3, 1):
continue
if rec.transaction_rights != "down" and rec.state == "draft":
rec.ebics_sig_passphrase_invisible = False
@api.constrains("ebics_key_x509")
def _check_ebics_key_x509(self):
for cfg in self:
if cfg.ebics_version == "H005" and not cfg.ebics_key_x509:
raise UserError(
self.env._("X.509 certificates must be used with EBICS 3.0.")
)
@api.constrains("ebics_passphrase")
def _check_ebics_passphrase(self):
for rec in self:
if rec.ebics_passphrase and len(rec.ebics_passphrase) < 8:
raise UserError(
self.env._("The Passphrase must be at least 8 characters long")
)
@api.constrains("ebics_sig_passphrase")
def _check_ebics_sig_passphrase(self):
for rec in self:
if rec.ebics_sig_passphrase and len(rec.ebics_sig_passphrase) < 8:
raise UserError(
self.env._(
"The Signature Passphrase must be at least 8 characters long"
)
)
@api.onchange("ebics_version")
def _onchange_ebics_version(self):
if self.ebics_version == "H005":
self.ebics_key_x509 = True
@api.onchange("signature_class")
def _onchange_signature_class(self):
if self.signature_class == "T":
self.swift_3skey = False
@api.onchange("ebics_passphrase_store", "ebics_passphrase")
def _onchange_ebics_passphrase_store(self):
if self.ebics_passphrase_store:
if self.ebics_passphrase:
# check passphrase before db store
keyring_params = {
"keys": self.ebics_keys_fn,
"passphrase": self.ebics_passphrase,
}
try:
keyring = EbicsKeyRing(**keyring_params)
# fintech <= 7.4.3 does not have a call to check if a
# passphrase matches with the value stored in the keyfile.
# We get around this limitation as follows:
# Get user keys to check for valid passphrases
# It will raise a ValueError on invalid passphrases,
# or a RuntimeError when the keyring is already open
# in this process with another passphrase.
keyring["#USER"] # pylint: disable=pointless-statement
except (ValueError, RuntimeError) as err: # noqa: F841
raise UserError(self.env._("Passphrase mismatch.")) # noqa: B904
elif self.state != "draft":
self.ebics_passphrase = False
@api.onchange("swift_3skey")
def _onchange_swift_3skey(self):
if self.swift_3skey:
self.ebics_key_x509 = True
def set_to_draft(self):
return self.write({"state": "draft"})
def set_to_active_keys(self):
vals = {"state": "active_keys"}
self._update_passphrase_vals(vals)
return self.write(vals)
def set_to_get_bank_keys(self):
self.ensure_one()
if self.ebics_config_id.state != "draft":
raise UserError(
self.env._(
"Set the EBICS Configuation record to 'Draft' "
"before starting the Key Renewal process."
)
)
return self.write({"state": "get_bank_keys"})
def ebics_init_1(self): # noqa: C901
"""
Initialization of bank keys - Step 1:
Create new keys and certificates for this user
"""
self.ensure_one()
if self.state != "draft":
raise UserError(
self.env._("Set state to 'draft' before Bank Key (re)initialisation.")
)
if not self.ebics_passphrase:
raise UserError(self.env._("Set a passphrase."))
if self.swift_3skey and not self.swift_3skey_certificate:
raise UserError(self.env._("3SKey certificate missing."))
ebics_version = self.ebics_config_id.ebics_version
try:
keyring_params = {
"keys": self.ebics_keys_fn,
"passphrase": self.ebics_passphrase,
}
if self.ebics_sig_passphrase:
keyring_params["sig_passphrase"] = self.ebics_sig_passphrase
keyring = EbicsKeyRing(**keyring_params)
bank = EbicsBank(
keyring=keyring,
hostid=self.ebics_config_id.ebics_host,
url=self.ebics_config_id.ebics_url,
)
user = EbicsUser(
keyring=keyring,
partnerid=self.ebics_config_id.ebics_partner,
userid=self.name,
)
except Exception as err:
exctype, value = exc_info()[:2]
error = self.env._("EBICS Initialisation Error:")
error += "\n" + str(exctype) + "\n" + str(value)
raise UserError(error) from err
self.ebics_config_id._check_ebics_keys()
if not os.path.isfile(self.ebics_keys_fn):
try:
# TODO:
# enable import of all type of certicates: A00x, X002, E002
if self.swift_3skey:
kwargs = {
self.ebics_config_id.ebics_key_version: base64.decodebytes(
self.swift_3skey_certificate
),
}
user.import_certificates(**kwargs)
user.create_keys(
keyversion=self.ebics_config_id.ebics_key_version,
bitlength=self.ebics_config_id.ebics_key_bitlength,
)
except Exception as err:
exctype, value = exc_info()[:2]
error = self.env._("EBICS Initialisation Error:")
error += "\n" + str(exctype) + "\n" + str(value)
raise UserError(error) from err
if self.swift_3skey and not self.ebics_key_x509:
raise UserError(
self.env._(
"The current version of this module "
"requires to X509 support when enabling 3SKey"
)
)
if self.ebics_key_x509:
dn_attrs = {
"commonName": self.ebics_key_x509_dn_cn,
"organizationName": self.ebics_key_x509_dn_o,
"organizationalUnitName": self.ebics_key_x509_dn_ou,
"countryName": self.ebics_key_x509_dn_c,
"stateOrProvinceName": self.ebics_key_x509_dn_st,
"localityName": self.ebics_key_x509_dn_l,
"emailAddress": self.ebics_key_x509_dn_e,
}
kwargs = {k: v for k, v in dn_attrs.items() if v}
user.create_certificates(**kwargs)
try:
client = EbicsClient(bank, user, version=ebics_version)
except RuntimeError as err:
e = exc_info()
error = self.env._("EBICS Initialization Error:")
error += "\n"
error += err.args[0]
raise UserError(error) from err
# Send the public electronic signature key to the bank.
ebics_config_bank = self.ebics_config_id.journal_ids[:1].bank_account_id
if not ebics_config_bank:
raise UserError(
self.env._(
"No bank defined for the financial journal of the EBICS Config"
)
)
try:
supported_versions = client.HEV()
if supported_versions and ebics_version not in supported_versions:
err_msg = self.env._("EBICS version mismatch.") + "\n"
err_msg += self.env._("Versions supported by your bank:")
for k in supported_versions:
err_msg += f"\n{k}: {supported_versions[k]} "
raise UserError(err_msg)
if ebics_version == "H003":
bank._order_number = self.ebics_config_id._get_order_number()
OrderID = client.INI()
_logger.info("%s, EBICS INI command, OrderID=%s", self._name, OrderID)
if ebics_version == "H003":
self.ebics_config_id._update_order_number(OrderID)
except URLError as err:
exctype, value = exc_info()[:2]
tb = "".join(format_exception(*exc_info()))
_logger.error(
"EBICS INI command error\nUserID: %s\n%s",
self.name,
tb,
)
raise UserError(
self.env._(
"urlopen error:\n url '%(url)s' - %(val)s",
url=self.ebics_config_id.ebics_url,
val=str(value),
)
) from err
except EbicsFunctionalError as err:
e = exc_info()
error = self.env._("EBICS Functional Error:")
error += "\n"
error += f"{e[1].message} (code: {e[1].code})"
raise UserError(error) from err
except EbicsTechnicalError as err:
e = exc_info()
error = self.env._("EBICS Technical Error:")
error += "\n"
error += f"{e[1].message} (code: {e[1].code})"
raise UserError(error) from err
# Send the public authentication and encryption keys to the bank.
if ebics_version == "H003":
bank._order_number = self.ebics_config_id._get_order_number()
OrderID = client.HIA()
_logger.info("%s, EBICS HIA command, OrderID=%s", self._name, OrderID)
if ebics_version == "H003":
self.ebics_config_id._update_order_number(OrderID)
# Create an INI-letter which must be printed and sent to the bank.
cc = ebics_config_bank.country_id.code
if cc in ["FR", "DE"]:
lang = cc
else:
lang = self.env.user.lang[:2]
lang = lang.lower()
lang = lang if lang in INI_LETTER_LANGS else "en"
fn_date = fields.Date.today().isoformat()
fn = f"{self.ebics_config_id.ebics_host}_ini_letter_{fn_date}.pdf"
letter = user.create_ini_letter(bankname=ebics_config_bank.bank_name, lang=lang)
vals = {
"ebics_ini_letter": BinaryBytes(letter),
"ebics_ini_letter_fn": fn,
"state": "init",
}
self._update_passphrase_vals(vals)
return self.write(vals)
def ebics_init_2(self):
"""
Initialization of bank keys - Step 2:
Activation of the account by the bank.
"""
self.ensure_one()
if self.state != "init":
raise UserError(self.env._("Set state to 'Initialisation'."))
vals = {"state": "get_bank_keys"}
self._update_passphrase_vals(vals)
return self.write(vals)
def ebics_init_3(self):
"""
Initialization of bank keys - Step 3:
After the account has been activated the public bank keys
must be downloaded and checked for consistency.
"""
self.ensure_one()
if self.state != "get_bank_keys":
raise UserError(self.env._("Set state to 'Get Keys from Bank'."))
try:
keyring = EbicsKeyRing(
keys=self.ebics_keys_fn, passphrase=self.ebics_passphrase
)
bank = EbicsBank(
keyring=keyring,
hostid=self.ebics_config_id.ebics_host,
url=self.ebics_config_id.ebics_url,
)
user = EbicsUser(
keyring=keyring,
partnerid=self.ebics_config_id.ebics_partner,
userid=self.name,
)
client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version)
except Exception as err:
exctype, value = exc_info()[:2]
error = self.env._("EBICS Initialisation Error:")
error += "\n" + str(exctype) + "\n" + str(value)
raise UserError(error) from err
try:
public_bank_keys = client.HPB()
except EbicsFunctionalError as err:
e = exc_info()
error = self.env._("EBICS Functional Error:")
error += "\n"
error += f"{e[1].message} (code: {e[1].code})"
raise UserError(error) from err
except Exception as err:
exctype, value = exc_info()[:2]
error = self.env._("EBICS Initialisation Error:")
error += "\n" + str(exctype) + "\n" + str(value)
raise UserError(error) from err
public_bank_keys = public_bank_keys.encode()
fn_date = fields.Date.today().isoformat()
fn = f"{self.ebics_config_id.ebics_host}_public_bank_keys_{fn_date}.txt"
vals = {
"ebics_public_bank_keys": BinaryBytes(public_bank_keys),
"ebics_public_bank_keys_fn": fn,
"state": "to_verify",
}
self._update_passphrase_vals(vals)
return self.write(vals)
def ebics_init_4(self):
"""
Initialization of bank keys - Step 2:
Confirm Verification of the public bank keys
and activate the bank keys.
"""
self.ensure_one()
if self.state != "to_verify":
raise UserError(self.env._("Set state to 'Verification'."))
keyring = EbicsKeyRing(
keys=self.ebics_keys_fn, passphrase=self.ebics_passphrase
)
bank = EbicsBank(
keyring=keyring,
hostid=self.ebics_config_id.ebics_host,
url=self.ebics_config_id.ebics_url,
)
bank.activate_keys()
vals = {"state": "active_keys"}
self._update_passphrase_vals(vals)
return self.write(vals)
def change_passphrase(self):
self.ensure_one()
ctx = dict(self.env.context, default_ebics_userid_id=self.id)
module = __name__.split("addons.")[1].split(".")[0]
view = self.env.ref(f"{module}.ebics_change_passphrase_view_form")
return {
"name": self.env._("EBICS keys change passphrase"),
"view_mode": "form",
"res_model": "ebics.change.passphrase",
"view_id": view.id,
"target": "new",
"context": ctx,
"type": "ir.actions.act_window",
}
def _update_passphrase_vals(self, vals):
"""
Remove non-stored passphrases from db after e.g. successfull init_1
"""
if vals["state"] in ("init", "get_bank_keys", "to_verify", "active_keys"):
if not self.ebics_passphrase_store:
vals["ebics_passphrase"] = False
if self.ebics_sig_passphrase:
vals["ebics_sig_passphrase"] = False
@@ -0,0 +1,45 @@
# Copyright 2009-2024 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import logging
from sys import exc_info
from traceback import format_exception
from odoo.tools import config
_logger = logging.getLogger(__name__)
try:
import fintech
except ImportError:
fintech = None
_logger.warning("Failed to import fintech")
fintech_register_name = config.get("fintech_register_name")
fintech_register_keycode = config.get("fintech_register_keycode")
fintech_register_users = config.get("fintech_register_users")
try:
if fintech:
fintech_register_users = (
fintech_register_users
and [x.strip() for x in fintech_register_users.split(",")]
) or None
fintech.cryptolib = "cryptography"
fintech.register(
name=fintech_register_name,
keycode=fintech_register_keycode,
users=fintech_register_users,
)
except RuntimeError as e:
if str(e) == "'register' can be called only once":
pass
else:
_logger.error(str(e))
fintech.register()
except Exception: # noqa: BLE001 - logged with the traceback, then retried
msg = "fintech.register error"
tb = "".join(format_exception(*exc_info()))
msg += f"\n{tb}"
_logger.error(msg)
fintech.register()
+3
View File
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="res_groups_privilege_ebics_manager" model="res.groups.privilege">
<field name="name">EBICS</field>
<field name="category_id" ref="base.module_category_accounting" />
</record>
<record id="group_ebics_manager" model="res.groups">
<field name="name">EBICS Manager</field>
<field name="privilege_id" ref="res_groups_privilege_ebics_manager" />
</record>
</odoo>
+15
View File
@@ -0,0 +1,15 @@
id,name,model_id,group_id/id,operation,domain
access_ebics_config_manager,ebics_config manager,ebics.config,account_ebics.group_ebics_manager,crud,
access_ebics_config_user,ebics_config user,ebics.config,account.group_account_invoice,r,
access_ebics_userid_manager,ebics_userid manager,ebics.userid,account_ebics.group_ebics_manager,crud,
access_ebics_userid_user,ebics_userid user,ebics.userid,account.group_account_invoice,r,
access_ebics_file_format_manager,ebics_file_format manager,ebics.file.format,account_ebics.group_ebics_manager,crud,
access_ebics_file_format_user,ebics_file_format user,ebics.file.format,account.group_account_invoice,r,
access_ebics_file_manager,ebics_file manager,ebics.file,account_ebics.group_ebics_manager,crud,
access_ebics_file_user,ebics_file user,ebics.file,account.group_account_invoice,cru,
access_ebics_change_passphrase,access_ebics_change_passphrase,ebics.change.passphrase,account_ebics.group_ebics_manager,cru,
access_ebics_xfer,access_ebics_xfer,ebics.xfer,account.group_account_invoice,cru,
access_ebics_admin_order,access_ebics_admin_order,ebics.admin.order,account_ebics.group_ebics_manager,cru,
ebics_config_comp_rule,EBICS Configuration model company rule,ebics.config,,crud,"['|', ('company_ids', '=', False), ('company_ids', 'in', company_ids)]"
ebics_userid_comp_rule,EBICS UserID model company rule,ebics.userid,,crud,"['|', ('company_ids', '=', False), ('company_ids', 'in', company_ids)]"
ebics_file_comp_rule,EBICS File model company rule,ebics.file,,crud,"['|', ('company_ids', '=', False), ('company_ids', 'in', company_ids)]"
1 id name model_id group_id/id operation domain
2 access_ebics_config_manager ebics_config manager ebics.config account_ebics.group_ebics_manager crud
3 access_ebics_config_user ebics_config user ebics.config account.group_account_invoice r
4 access_ebics_userid_manager ebics_userid manager ebics.userid account_ebics.group_ebics_manager crud
5 access_ebics_userid_user ebics_userid user ebics.userid account.group_account_invoice r
6 access_ebics_file_format_manager ebics_file_format manager ebics.file.format account_ebics.group_ebics_manager crud
7 access_ebics_file_format_user ebics_file_format user ebics.file.format account.group_account_invoice r
8 access_ebics_file_manager ebics_file manager ebics.file account_ebics.group_ebics_manager crud
9 access_ebics_file_user ebics_file user ebics.file account.group_account_invoice cru
10 access_ebics_change_passphrase access_ebics_change_passphrase ebics.change.passphrase account_ebics.group_ebics_manager cru
11 access_ebics_xfer access_ebics_xfer ebics.xfer account.group_account_invoice cru
12 access_ebics_admin_order access_ebics_admin_order ebics.admin.order account_ebics.group_ebics_manager cru
13 ebics_config_comp_rule EBICS Configuration model company rule ebics.config crud ['|', ('company_ids', '=', False), ('company_ids', 'in', company_ids)]
14 ebics_userid_comp_rule EBICS UserID model company rule ebics.userid crud ['|', ('company_ids', '=', False), ('company_ids', 'in', company_ids)]
15 ebics_file_comp_rule EBICS File model company rule ebics.file crud ['|', ('company_ids', '=', False), ('company_ids', 'in', company_ids)]
Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

+226
View File
@@ -0,0 +1,226 @@
<!-- Generated from README.rst: edit the README, not this file. -->
<div class="section" id="ebics-banking-protocol">
<h1>EBICS Banking Protocol</h1>
<p><strong>Exchange files directly with your banks from Odoo, with no portal and nobody logging in.</strong></p>
<p>EBICS, the Electronic Banking Internet Communication Standard, is the channel European
banks open to companies that want their software to talk to the bank. Bank statements are
downloaded on a schedule and payment files are uploaded from Odoo, authenticated by your
own cryptographic keys instead of a login page.</p>
<p>This module implements that protocol in Odoo. It is developed and maintained by
Noviat, and follows each new version of Odoo, which matters when a bank connection has to
survive your next migration.</p>
<p>If you are still working out whether EBICS is the right channel for you, we explain it
without the jargon, with screen recordings of the flow in Odoo, on
<a class="reference external" href="https://www.noviat.com/ebics">noviat.com/ebics</a>.</p>
<img alt="Statements come down as camt.053 or camt.052 files, payment files go up as pain.001 or pain.008, and your keys stay on your own server" src="ebics_flow.png" style="width: 100%;" />
<div class="section" id="what-you-get">
<h2>What you get</h2>
<ul class="simple">
<li><strong>Statements that arrive on their own.</strong> A scheduled task collects the files your bank
publishes, for every account, and processes them into bank statements.</li>
<li><strong>Payments that leave the same way.</strong> A payment batch or a payment order is uploaded to
the bank in the format the bank expects, without exporting a file and re-uploading it
somewhere else.</li>
<li><strong>Several companies, one connection.</strong> Keys are held per bank rather than per company:
when fifteen entities bank with the same institution, the bank sends a single daily file
carrying fifteen statements and the module puts each statement in the right company.</li>
<li><strong>No bank credentials in Odoo.</strong> The connection uses your own company keys, generated on
your side and kept on your server. Access to the EBICS configuration is a permission of
its own ('EBICS Manager'), separate from ordinary accounting rights.</li>
<li><strong>A test mode, where your bank offers one.</strong> French banks accept a test flag, so a file
can be submitted and validated before anything is switched to production. German and
Swiss banks generally do not: there the first payment is a real one, kept small and sent
to an account you control.</li>
<li><strong>A trace of every exchange.</strong> Each download and each upload is a record, with the file
it carried, the moment it happened and the user behind it.</li>
</ul>
<p><strong>EBICS 2.4</strong>, <strong>EBICS 2.5</strong> and <strong>EBICS 3.0</strong> are supported. EBICS 3.0, the current
specification since December 2022, names what is exchanged with BTF instead of the
country-specific order type codes of EBICS 2.x. Many banks still run 2.4 or 2.5 in parallel.</p>
</div>
<div class="section" id="what-travels-over-the-link">
<h2>What travels over the link</h2>
<ul class="simple">
<li><strong>Coming in:</strong> camt.053 for the end of day statement, camt.052 for intraday movements
where the bank offers them, and national formats such as the French CFONB.</li>
<li><strong>Going out:</strong> pain.001 for credit transfers and pain.008 for direct debits, generated by
Odoo from your payment batches.</li>
</ul>
<p>We do not process MT940 statements: the format carries bank and country specific variations,
and the Odoo community stopped maintaining a general parser for it after Odoo 10. Where a
bank publishes camt.053 alongside it, which is now the usual case, that is the format to use.</p>
</div>
<div class="section" id="which-banks">
<h2>Which banks</h2>
<p>Any bank that publishes an EBICS access point can be connected. The standard is maintained by
EBICS SC, a company held by the German, French, Swiss and Austrian banking bodies
(DK, CFONB, SIX and PSA), and it is the standard corporate channel in those countries.</p>
<p>To check a specific bank before you start, joonis publishes a public directory at
<a class="reference external" href="https://www.joonis.de/en/fintech/banks/">joonis.de/en/fintech/banks</a>. Enter a BIC and it
returns the SEPA services the bank offers, the EBICS versions it supports and its Host-ID.</p>
<p>A bank missing from that directory is not a no: it is joonis' own list, not an official
register. Ask your bank whether it publishes an EBICS access point.</p>
</div>
<div class="section" id="what-it-costs">
<h2>What it costs</h2>
<p><strong>This module is free software</strong>, published under LGPL-3. There is no licence fee, no
subscription and no per-connection charge from Noviat.</p>
<p>It does however rely on the <a class="reference external" href="https://pypi.python.org/pypi/fintech">fintech</a> library from
joonis, and that library requires a <strong>commercial licence for production use</strong>: as soon as
you upload SEPA files with more than five transactions, retrieve statements older than the
last three days, or use the distributed signature. The licence is contracted directly with
joonis, not with Noviat.</p>
<p>joonis charges a one-off setup fee plus a monthly fee per EBICS user id. Current pricing is
published on
<a class="reference external" href="https://www.joonis.de/en/fintech/prices/">joonis.de</a>.</p>
<p>Your bank may also charge a subscription for the EBICS channel itself. It varies from one
bank to another and is billed by the bank, separately from anything on the Odoo side.</p>
</div>
<div class="section" id="requirements">
<h2>Requirements</h2>
<p>The module depends on two Python libraries:</p>
<ul class="simple">
<li><a class="reference external" href="https://pypi.python.org/pypi/fintech">fintech</a></li>
<li><a class="reference external" href="https://pypi.python.org/pypi/cryptography">cryptography</a></li>
</ul>
<p>Because the connection needs a Python library and your key files on the server, it runs on
<strong>Odoo.sh</strong> or on an <strong>on-premise</strong> installation.</p>
<p>The EBICS test mode for uploads requires fintech 4.3.4 or higher for EBICS 2.x and fintech
7.2.7 or higher for EBICS 3.0. SWIFT 3SKey support requires fintech 6.4 or higher, and the signature passphrase
fintech 7.3.1 or higher.</p>
<div class="section" id="fintech-licence">
<h3>Fintech licence</h3>
<p>With a fintech licence, add its parameters to the <tt class="docutils literal">[options]</tt> section of the Odoo server
configuration file:</p>
<ul class="simple">
<li><tt class="docutils literal">fintech_register_name</tt>: the name of the licensee;</li>
<li><tt class="docutils literal">fintech_register_keycode</tt>: the keycode of the licensed version.</li>
</ul>
<p>Example:</p>
<pre class="literal-block">
; fintech
fintech_register_name = MyCompany
fintech_register_keycode = AB1CD-E2FG-3H-IJ4K-5L
</pre>
</div>
</div>
<div class="section" id="companion-modules">
<h2>Companion modules</h2>
<p>From this repository:</p>
<ul class="simple">
<li><strong>EBICS - Odoo Enterprise Integration</strong> (<tt class="docutils literal">account_ebics_oe</tt>): required on Odoo
Enterprise; installed automatically.</li>
<li><strong>EBICS - Scheduled File Import</strong> (<tt class="docutils literal">account_ebics_batch</tt>): downloads and processes the
files of every connection on a schedule.</li>
<li><strong>EBICS - Batch Payments (Odoo Enterprise)</strong> (<tt class="docutils literal">account_ebics_batch_payment</tt>): uploads
the batch payments of the Odoo Enterprise <tt class="docutils literal">account_batch_payment</tt> module.</li>
<li><strong>EBICS - Payment Orders (OCA)</strong> (<tt class="docutils literal">account_ebics_payment_order</tt>): uploads the payment
orders of the OCA <tt class="docutils literal">account_payment_order</tt> module
(<a class="reference external" href="https://github.com/OCA/bank-payment">OCA/bank-payment</a>).</li>
</ul>
<p>To process the downloaded statements, install the module of each format you receive:</p>
<ul class="simple">
<li><strong>camt.053, camt.052 and camt.054</strong>: <tt class="docutils literal">account_statement_import_camt</tt>
(<a class="reference external" href="https://github.com/OCA/bank-statement-import">OCA/bank-statement-import</a>). For
camt.053, the Odoo Enterprise <tt class="docutils literal">account_bank_statement_import_camt</tt> works too.</li>
<li><strong>French CFONB</strong>: <tt class="docutils literal">account_statement_import_fr_cfonb</tt>
(<a class="reference external" href="https://github.com/OCA/l10n-france">OCA/l10n-france</a>).</li>
</ul>
<p>Recommended with several financial journals: <tt class="docutils literal">account_usability</tt>
(<a class="reference external" href="https://github.com/OCA/account-financial-tools">OCA/account-financial-tools</a>), which adds
accounting menus such as a list of all bank statements, including those downloaded by the
scheduled import.</p>
</div>
<div class="section" id="getting-your-bank-online">
<h2>Getting your bank online</h2>
<p>The configuration on the Odoo side takes fifteen to thirty minutes. What sets the pace of a
project is the bank, and it is almost never for a technical reason:</p>
<ul class="simple">
<li><strong>The bank opens the access.</strong> You receive the host ID, the address of the access point,
your partner and user identifiers, and a letter carrying the hash values of the bank's keys.</li>
<li><strong>INI and HIA.</strong> Odoo generates your key pairs for signature, authentication and encryption,
sends the public keys to the bank and produces the initialisation letters, which you print,
sign and send. The bank compares them by hand with the keys it received online.</li>
<li><strong>HPB.</strong> Once the bank has activated your access, you retrieve its public keys and compare
their hash values with the letter it sent you. That comparison is what makes the channel
trustworthy.</li>
<li><strong>The first exchange.</strong> Statements come down first. Payments follow, as a test file where
the bank supports the test flag, otherwise as a real transfer of a small amount.</li>
</ul>
<p>Count in weeks per bank rather than days, and start the contract and the paperwork early.</p>
</div>
<div class="section" id="configuration">
<h2>Configuration</h2>
<p>The menus are those of Odoo Enterprise; on Odoo Community, the application is called
<em>Invoicing</em> instead of <em>Accounting</em>.</p>
<p><strong>Who may configure.</strong> In <em>Settings &gt; Users</em>, add the users who maintain the EBICS
configuration to the <strong>EBICS Manager</strong> group.</p>
<p><strong>File formats.</strong> In <em>Accounting &gt; Configuration &gt; EBICS &gt; EBICS File Formats</em>, check that the
formats you exchange with your banks are defined; the common ones are created at
installation. A missing format can be reported on
<a class="reference external" href="https://github.com/Noviat/account_ebics/issues">GitHub</a>.</p>
<p>A download format can carry a <strong>Download Process Method</strong>, run by the <em>Process</em> button of a
downloaded file: <tt class="docutils literal">camt.053</tt>, <tt class="docutils literal">camt.052</tt>, <tt class="docutils literal">camt.054</tt> and <tt class="docutils literal">cfonb120</tt>. Each needs the
module of its format (see Companion modules); Odoo tells you which one when it is missing.</p>
<p><strong>Bank connections.</strong> In <em>Accounting &gt; Configuration &gt; EBICS &gt; EBICS Configuration</em>, create one
connection per bank contract, with the identifiers your bank sent you.</p>
<img alt="A downloaded camt.053 statement file in Odoo, before processing" src="ebics_download.png" style="width: 100%;" />
</div>
<div class="section" id="usage">
<h2>Usage</h2>
<p>The <strong>EBICS Processing</strong> menu, in the top bar of the Accounting application, lists the
downloaded and uploaded files and offers manual downloads and uploads.</p>
<p>Downloaded files are processed into bank statements. Uploads are launched from the payment
batch or the payment order, with the format set in the configuration: on the payment
mode for a payment order, on the journal's payment method for a batch payment.</p>
<img alt="Uploading a pain.001 SEPA credit transfer file over EBICS 3.0, with the test mode option" src="ebics_upload.png" style="width: 100%;" />
</div>
<div class="section" id="diagnostics">
<h2>Diagnostics</h2>
<p>To diagnose the connection with your bank, add this line to the Odoo server configuration
file:</p>
<pre class="literal-block">
log_handler = fintech.ebics:DEBUG
</pre>
<div class="section" id="ebics-return-codes">
<h3>EBICS return codes</h3>
<p>During an upload or a download, your bank may return an error code, for example:</p>
<pre class="literal-block">
EBICS Functional Error:
EBICS_NO_DOWNLOAD_DATA_AVAILABLE (code: 90005)
</pre>
<p>The codes are explained on <a class="reference external" href="https://www.ebics.org">ebics.org</a> and in the <tt class="docutils literal">doc</tt> folder of
this module (<tt class="docutils literal">EBICS_Annex1_ReturnCodes</tt>).</p>
</div>
<div class="section" id="electronic-distributed-signature-eds">
<h3>Electronic Distributed Signature (EDS)</h3>
<p>Where your bank supports EBICS T, Odoo prepares the file and holds no signing credentials
at all: the payment is approved in your own signing application, which is what a segregation
of duties policy usually demands. Where it does not, which happens with German and Swiss
banks, the signing key sits on your Odoo server, and you can protect it with a separate
signature passphrase that is never stored and is asked for every signed transaction.</p>
<p>External signing apps include BankingVEU
(<a class="reference external" href="https://play.google.com/store/apps/details?id=subsembly.bankingveu">Android</a>,
<a class="reference external" href="https://apps.apple.com/de/app/bankingveu/id1578694190">iOS</a>).</p>
</div>
</div>
<div class="section" id="roadmap">
<h2>Roadmap</h2>
<ul class="simple">
<li>Import externally generated keys and certificates (today only the 3SKey signature
certificate).</li>
<li>Support the SWIFT 3SKey signing JavaScript library
(<a class="reference external" href="https://www2.swift.com/3skey/help/sconnect.html">SConnect</a>).</li>
</ul>
<p>Issues and pull requests are welcome on
<a class="reference external" href="https://github.com/Noviat/account_ebics">GitHub</a>.</p>
</div>
<div class="section" id="credits">
<h2>Credits</h2>
<p>This module is developed and maintained by <a class="reference external" href="https://www.noviat.com">Noviat</a>, Odoo
integrator in Belgium, specialised in accounting and finance since 2009.</p>
<p>We implement it, we configure the connection with your banks and we support you through the
first cycles. If you want help getting a bank online, tell us which banks you use:
<a class="reference external" href="https://www.noviat.com/ebics">https://www.noviat.com/ebics</a></p>
</div>
</div>
+7
View File
@@ -0,0 +1,7 @@
from . import test_ebics_admin_wizards
from . import test_ebics_config
from . import test_ebics_file
from . import test_ebics_file_split
from . import test_ebics_userid
from . import test_ebics_xfer
from . import test_ebics_xfer_client
+198
View File
@@ -0,0 +1,198 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from contextlib import contextmanager
from unittest.mock import patch
from odoo import Command, fields
from odoo.tools import file_open
from odoo.tools.binary import BinaryBytes
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
# Synthetic files: structures mirror real bank files, all values are invented.
SAMPLES_DIR = "account_ebics/tests/samples"
# Bank accounts used in the samples (fictitious, checksum-valid).
IBAN_CMB = "FR7615589297011000000010111"
IBAN_CA833 = [
"FR7613306000012000000020197",
"FR7613306000012000000020294",
"FR7613306000012000000020391",
]
IBAN_LCL = [
"FR7630002004563000000030102",
"FR7630002004563000000030296",
"FR7630002004563000000030393",
"FR7630002004563000000030490",
]
IBAN_CA879 = [
"FR7617906000324000000040136",
"FR7617906000324000000040233",
"FR7617906000324000000040330",
"FR7617906000324000000040427",
]
IBAN_CIC = "FR7630087331005000000050175"
IBAN_HVB = "DE54793200750010000001"
IBAN_SPK = "DE52305500000010000002"
IBAN_MULTI = ["DE69370400440010000003", "DE42370400440010000004"]
IBAN_SUFFIX = "DE15370400440010000005"
def read_sample(name):
with file_open(f"{SAMPLES_DIR}/{name}", "rb") as f:
return f.read()
class FakeEbicsClient:
"""Stand-in for fintech.ebics.EbicsClient, returned by a patched
ebics.xfer._setup_client so that no keyring and no bank are needed.
:param downloads: dict order type ("BTD", "FDL" or the EBICS 2 order
type) -> bytes (or dict of document name -> bytes) to return.
:param error: exception instance raised by every transfer call.
"""
def __init__(self, downloads=None, order_id="N001", error=None):
self.downloads = downloads or {}
self.order_id = order_id
self.error = error
self.uploads = []
self.confirmed = []
self.last_trans_id = "TRANS0001"
def _download(self, key):
if self.error:
raise self.error
return self.downloads[key]
def _upload(self, key, data, kwargs):
if self.error:
raise self.error
self.uploads.append((key, data, kwargs))
return self.order_id
def BTD(self, btf, start=None, end=None, **kwargs):
return self._download("BTD")
def FDL(self, filetype, start=None, end=None):
return self._download("FDL")
def download(self, order_type, params=None):
return self._download(order_type)
def BTU(self, btf, data, **kwargs):
return self._upload("BTU", data, kwargs)
def FUL(self, filetype, data, **kwargs):
return self._upload("FUL", data, kwargs)
def upload(self, order_type, data):
return self._upload(order_type, data, {})
def confirm_download(self, trans_id=None, success=True):
self.confirmed.append((trans_id, success))
class EbicsTestCommon(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env.user.group_ids |= cls.env.ref("account_ebics.group_ebics_manager")
cls.eur = cls.env.ref("base.EUR")
cls.eur.active = True
cls.company = cls.env.company
cls.ebics_config = cls.env["ebics.config"].create(
{
"name": "Test Bank",
"ebics_host": "TESTHOST",
"ebics_url": "https://ebics.example.invalid/ebics",
"ebics_partner": "PARTNER1",
"ebics_version": "H004",
"state": "confirm",
}
)
cls.ebics_userid = cls.env["ebics.userid"].create(
{
"name": "USER1",
"ebics_config_id": cls.ebics_config.id,
"user_ids": [Command.set(cls.env.user.ids)],
"company_ids": [Command.set(cls.company.ids)],
"ebics_passphrase": "test-passphrase",
"ebics_passphrase_store": True,
"state": "active_keys",
}
)
cls.ff_camt053 = cls.env.ref("account_ebics.ebics_ff_C53")
cls.ff_cfonb120 = cls.env.ref(
"account_ebics.ebics_ff_FDL_camt_xxx_cfonb120_stm"
)
cls.ff_btd_cfonb120 = cls.env.ref("account_ebics.ebics_ff_btf_cfonb120")
@classmethod
def _create_bank_journal(cls, code, acc_number, currency=None):
# sudo: accountants may not create bank accounts (res.partner.bank)
journal = (
cls.env["account.journal"]
.sudo()
.create(
{
"name": f"Bank {code}",
"code": code,
"type": "bank",
"bank_account_number": acc_number,
"currency_id": (currency or cls.eur).id,
"company_id": cls.company.id,
}
)
.sudo(False)
)
cls.ebics_config.journal_ids = [Command.link(journal.id)]
return journal
@classmethod
def _create_ebics_file(cls, sample, file_format, name=None):
return cls.env["ebics.file"].create(
{
"name": name or sample,
"data": BinaryBytes(read_sample(sample)),
"date": fields.Datetime.now(),
"format_id": file_format.id,
}
)
@staticmethod
def _new_res():
return {"statement_ids": [], "notifications": []}
@contextmanager
def _fake_client(self, client):
xfer_class = type(self.env["ebics.xfer"])
with patch.object(xfer_class, "_setup_client", return_value=client):
yield client
def _download_wizard(self, file_format, **vals):
return (
self.env["ebics.xfer"]
.with_context(ebics_download=True)
.create(
{
"ebics_config_id": self.ebics_config.id,
"ebics_userid_id": self.ebics_userid.id,
"format_id": file_format.id,
**vals,
}
)
)
def _upload_wizard(self, file_format, data=b"<Document/>", fname="pay.xml", **vals):
return self.env["ebics.xfer"].create(
{
"ebics_config_id": self.ebics_config.id,
"ebics_userid_id": self.ebics_userid.id,
"format_id": file_format.id,
"upload_data": BinaryBytes(data),
"upload_fname": fname,
**vals,
}
)
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02"><BkToCstmrStmt><GrpHdr><MsgId>MSG-TEST-0001</MsgId><CreDtTm>2026-10-13T22:00:00</CreDtTm></GrpHdr><Stmt><Id>SUFFIX-STMT-1</Id><ElctrncSeqNb>1</ElctrncSeqNb><CreDtTm>2026-10-13T22:00:00</CreDtTm><Acct><Id><Othr><Id>0010000005EUR</Id></Othr></Id><Ccy>EUR</Ccy></Acct><Bal><Tp><CdOrPrtry><Cd>OPBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">10.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Bal><Tp><CdOrPrtry><Cd>CLBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">15.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Ntry><NtryRef>SUFFIX-0001</NtryRef><Amt Ccy="EUR">5.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Sts><Cd>BOOK</Cd></Sts><BookgDt><Dt>2026-10-13</Dt></BookgDt><ValDt><Dt>2026-10-13</Dt></ValDt><AcctSvcrRef>SUFFIX-0001</AcctSvcrRef><BkTxCd><Domn><Cd>PMNT</Cd><Fmly><Cd>ICDT</Cd><SubFmlyCd>ESCT</SubFmlyCd></Fmly></Domn><Prtry><Cd>NTRF+116</Cd><Issr>DK</Issr></Prtry></BkTxCd><NtryDtls><TxDtls><Refs><AcctSvcrRef>SUFFIX-0001</AcctSvcrRef></Refs><Amt Ccy="EUR">5.00</Amt><RmtInf><Ustrd>Rho refund</Ustrd></RmtInf></TxDtls></NtryDtls></Ntry></Stmt></BkToCstmrStmt></Document>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.08"><BkToCstmrStmt><GrpHdr><MsgId>MSG-TEST-0001</MsgId><CreDtTm>2026-10-13T22:00:00</CreDtTm></GrpHdr><Stmt><Id>HVB-STMT-0001</Id><ElctrncSeqNb>1</ElctrncSeqNb><CreDtTm>2026-10-13T22:00:00</CreDtTm><Acct><Id><IBAN>DE54793200750010000001</IBAN></Id><Ccy>EUR</Ccy></Acct><Bal><Tp><CdOrPrtry><Cd>OPBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">5000.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Bal><Tp><CdOrPrtry><Cd>CLBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">3992.50</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Bal><Tp><CdOrPrtry><Cd>CLAV</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">3992.50</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Ntry><NtryRef>HVB-0001</NtryRef><Amt Ccy="EUR">150.00</Amt><CdtDbtInd>DBIT</CdtDbtInd><Sts><Cd>BOOK</Cd></Sts><BookgDt><Dt>2026-10-13</Dt></BookgDt><ValDt><Dt>2026-10-13</Dt></ValDt><AcctSvcrRef>HVB-0001</AcctSvcrRef><BkTxCd><Domn><Cd>PMNT</Cd><Fmly><Cd>ICDT</Cd><SubFmlyCd>ESCT</SubFmlyCd></Fmly></Domn><Prtry><Cd>NTRF+116</Cd><Issr>DK</Issr></Prtry></BkTxCd><NtryDtls><TxDtls><Refs><AcctSvcrRef>HVB-0001</AcctSvcrRef><EndToEndId>E2E-LAMBDA-118</EndToEndId></Refs><Amt Ccy="EUR">150.00</Amt><RmtInf><Ustrd>Rechnung 2026-118 Lambda GmbH</Ustrd></RmtInf></TxDtls></NtryDtls></Ntry><Ntry><NtryRef>HVB-0002</NtryRef><Amt Ccy="EUR">857.50</Amt><CdtDbtInd>DBIT</CdtDbtInd><Sts><Cd>BOOK</Cd></Sts><BookgDt><Dt>2026-10-13</Dt></BookgDt><ValDt><Dt>2026-10-13</Dt></ValDt><AcctSvcrRef>HVB-0002</AcctSvcrRef><BkTxCd><Domn><Cd>PMNT</Cd><Fmly><Cd>ICDT</Cd><SubFmlyCd>ESCT</SubFmlyCd></Fmly></Domn><Prtry><Cd>NTRF+116</Cd><Issr>DK</Issr></Prtry></BkTxCd><NtryDtls><TxDtls><Refs><AcctSvcrRef>HVB-0002</AcctSvcrRef></Refs><Amt Ccy="EUR">857.50</Amt><AmtDtls><InstdAmt><Amt Ccy="USD">1000.00</Amt></InstdAmt></AmtDtls><Chrgs><TtlChrgsAndTaxAmt Ccy="EUR">12.50</TtlChrgsAndTaxAmt></Chrgs><RmtInf><Ustrd>Zahlung USD Mu Inc</Ustrd></RmtInf></TxDtls></NtryDtls></Ntry></Stmt></BkToCstmrStmt></Document>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02"><BkToCstmrStmt><GrpHdr><MsgId>MSG-TEST-0001</MsgId><CreDtTm>2026-10-13T22:00:00</CreDtTm></GrpHdr><Stmt><Id>MULTI-STMT-1</Id><ElctrncSeqNb>1</ElctrncSeqNb><CreDtTm>2026-10-13T22:00:00</CreDtTm><Acct><Id><IBAN>DE69370400440010000003</IBAN></Id><Ccy>EUR</Ccy></Acct><Bal><Tp><CdOrPrtry><Cd>OPBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">100.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Bal><Tp><CdOrPrtry><Cd>CLBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">130.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Ntry><NtryRef>MULTI-0001</NtryRef><Amt Ccy="EUR">30.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Sts><Cd>BOOK</Cd></Sts><BookgDt><Dt>2026-10-13</Dt></BookgDt><ValDt><Dt>2026-10-13</Dt></ValDt><AcctSvcrRef>MULTI-0001</AcctSvcrRef><BkTxCd><Domn><Cd>PMNT</Cd><Fmly><Cd>ICDT</Cd><SubFmlyCd>ESCT</SubFmlyCd></Fmly></Domn><Prtry><Cd>NTRF+116</Cd><Issr>DK</Issr></Prtry></BkTxCd><NtryDtls><TxDtls><Refs><AcctSvcrRef>MULTI-0001</AcctSvcrRef></Refs><Amt Ccy="EUR">30.00</Amt><RmtInf><Ustrd>Omikron payment</Ustrd></RmtInf></TxDtls></NtryDtls></Ntry></Stmt><Stmt><Id>MULTI-STMT-2</Id><ElctrncSeqNb>1</ElctrncSeqNb><CreDtTm>2026-10-13T22:00:00</CreDtTm><Acct><Id><IBAN>DE42370400440010000004</IBAN></Id><Ccy>EUR</Ccy></Acct><Bal><Tp><CdOrPrtry><Cd>OPBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">200.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Bal><Tp><CdOrPrtry><Cd>CLBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">180.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Ntry><NtryRef>MULTI-0002</NtryRef><Amt Ccy="EUR">20.00</Amt><CdtDbtInd>DBIT</CdtDbtInd><Sts><Cd>BOOK</Cd></Sts><BookgDt><Dt>2026-10-13</Dt></BookgDt><ValDt><Dt>2026-10-13</Dt></ValDt><AcctSvcrRef>MULTI-0002</AcctSvcrRef><BkTxCd><Domn><Cd>PMNT</Cd><Fmly><Cd>ICDT</Cd><SubFmlyCd>ESCT</SubFmlyCd></Fmly></Domn><Prtry><Cd>NTRF+116</Cd><Issr>DK</Issr></Prtry></BkTxCd><NtryDtls><TxDtls><Refs><AcctSvcrRef>MULTI-0002</AcctSvcrRef></Refs><Amt Ccy="EUR">20.00</Amt><RmtInf><Ustrd>Pi fee</Ustrd></RmtInf></TxDtls></NtryDtls></Ntry></Stmt></BkToCstmrStmt></Document>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.08"><BkToCstmrStmt><GrpHdr><MsgId>MSG-TEST-0001</MsgId><CreDtTm>2026-10-13T22:00:00</CreDtTm></GrpHdr><Stmt><Id>NOACC-STMT-1</Id><ElctrncSeqNb>1</ElctrncSeqNb><CreDtTm>2026-10-13T22:00:00</CreDtTm><Acct><Ccy>EUR</Ccy></Acct><Bal><Tp><CdOrPrtry><Cd>OPBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">1.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Bal><Tp><CdOrPrtry><Cd>CLBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">2.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Ntry><NtryRef>NOACC-0001</NtryRef><Amt Ccy="EUR">1.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Sts><Cd>BOOK</Cd></Sts><BookgDt><Dt>2026-10-13</Dt></BookgDt><ValDt><Dt>2026-10-13</Dt></ValDt><AcctSvcrRef>NOACC-0001</AcctSvcrRef><BkTxCd><Domn><Cd>PMNT</Cd><Fmly><Cd>ICDT</Cd><SubFmlyCd>ESCT</SubFmlyCd></Fmly></Domn><Prtry><Cd>NTRF+116</Cd><Issr>DK</Issr></Prtry></BkTxCd><NtryDtls><TxDtls><Refs><AcctSvcrRef>NOACC-0001</AcctSvcrRef></Refs><Amt Ccy="EUR">1.00</Amt><RmtInf><Ustrd>Sigma</Ustrd></RmtInf></TxDtls></NtryDtls></Ntry></Stmt></BkToCstmrStmt></Document>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.08"><BkToCstmrStmt><GrpHdr><MsgId>MSG-TEST-0001</MsgId><CreDtTm>2026-10-13T22:00:00</CreDtTm></GrpHdr><Stmt><Id>EMPTY-STMT-1</Id><ElctrncSeqNb>1</ElctrncSeqNb><CreDtTm>2026-10-13T22:00:00</CreDtTm><Acct><Id><IBAN>DE52305500000010000002</IBAN></Id><Ccy>EUR</Ccy></Acct><Bal><Tp><CdOrPrtry><Cd>OPBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">720.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Bal><Tp><CdOrPrtry><Cd>CLBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">720.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal></Stmt></BkToCstmrStmt></Document>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.08"><BkToCstmrStmt><GrpHdr><MsgId>MSG-TEST-0001</MsgId><CreDtTm>2026-10-13T22:00:00</CreDtTm></GrpHdr><Stmt><Id>SPK-STMT-0001</Id><ElctrncSeqNb>1</ElctrncSeqNb><CreDtTm>2026-10-13T22:00:00</CreDtTm><Acct><Id><IBAN>DE52305500000010000002</IBAN></Id><Ccy>EUR</Ccy></Acct><Bal><Tp><CdOrPrtry><Cd>OPBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">720.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Bal><Tp><CdOrPrtry><Cd>CLBD</Cd></CdOrPrtry></Tp><Amt Ccy="EUR">1065.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Dt><Dt>2026-10-13</Dt></Dt></Bal><Ntry><NtryRef>SPK-0001</NtryRef><Amt Ccy="EUR">400.00</Amt><CdtDbtInd>CRDT</CdtDbtInd><Sts><Cd>BOOK</Cd></Sts><BookgDt><Dt>2026-10-13</Dt></BookgDt><ValDt><Dt>2026-10-13</Dt></ValDt><AcctSvcrRef>SPK-0001</AcctSvcrRef><BkTxCd><Domn><Cd>PMNT</Cd><Fmly><Cd>ICDT</Cd><SubFmlyCd>ESCT</SubFmlyCd></Fmly></Domn><Prtry><Cd>NTRF+116</Cd><Issr>DK</Issr></Prtry></BkTxCd><NtryDtls><TxDtls><Refs><AcctSvcrRef>SPK-0001</AcctSvcrRef></Refs><Amt Ccy="EUR">400.00</Amt><RmtInf><Ustrd>Gutschrift Nu KG</Ustrd></RmtInf></TxDtls></NtryDtls></Ntry><Ntry><NtryRef>SPK-0002</NtryRef><Amt Ccy="EUR">55.00</Amt><CdtDbtInd>DBIT</CdtDbtInd><Sts><Cd>BOOK</Cd></Sts><BookgDt><Dt>2026-10-13</Dt></BookgDt><ValDt><Dt>2026-10-13</Dt></ValDt><AcctSvcrRef>SPK-0002</AcctSvcrRef><BkTxCd><Domn><Cd>PMNT</Cd><Fmly><Cd>ICDT</Cd><SubFmlyCd>ESCT</SubFmlyCd></Fmly></Domn><Prtry><Cd>NTRF+116</Cd><Issr>DK</Issr></Prtry></BkTxCd><NtryDtls><TxDtls><Refs><AcctSvcrRef>SPK-0002</AcctSvcrRef></Refs><Amt Ccy="EUR">55.00</Amt><RmtInf><Ustrd>Lastschrift Xi Versicherung</Ustrd></RmtInf></TxDtls></NtryDtls></Ntry></Stmt></BkToCstmrStmt></Document>
@@ -0,0 +1 @@
0115589 29701EUR2 10000000101 131026 0000000015000{
@@ -0,0 +1,10 @@
0117906 00032EUR2 40000000401 131026** COMPTE COURANT 0000000000100{
0717906 00032EUR2 40000000401 131026--------------------------------------------------0000000000100{
0117906 00032EUR2 40000000402 131026** COMPTE EPARGNE 0000000000200{
0717906 00032EUR2 40000000402 131026--------------------------------------------------0000000000200{
0117906 00032EUR2 40000000403 131026 0000000000300{
0717906 00032EUR2 40000000403 131026 0000000000300{
0117906 00032EUR2 40000000404 131026 0000000040000{
0417906000000032EUR2 4000000040405131026 131026VIR ETA SA 0000000 0000000015000{
0417906000000032EUR2 4000000040405131026 131026PRLV THETA ASSURANCES 0000000 0000000002100}
0717906 00032EUR2 40000000404 131026 0000000052900{
@@ -0,0 +1,14 @@
0113306 00001EUR2 20000000201 131026 0000000084000{
0413306000000001EUR2 2000000020105131026 131026VIR SEPA RECU GAMMA SARL 0000000 0000000006400{
0513306000000001EUR2 2000000020105131026 NBEGAMMA SARL
0513306000000001EUR2 2000000020105131026 LCCFACT 99812
0513306000000001EUR2 2000000020105131026 REFE2E-GAMMA-1
0413306000000001EUR2 2000000020105131026 131026PRLV SEPA DELTA ENERGIE 0000000 0000000001325N
0513306000000001EUR2 2000000020105131026 NPYDELTA ENERGIE
0513306000000001EUR2 2000000020105131026 RUMRUM-DELTA-0042
0713306 00001EUR2 20000000201 131026 0000000089074E
0113306 00001EUR2 20000000202 131026 0000000012345{
0713306 00001EUR2 20000000202 131026 0000000012345{
0113306 00001EUR2 20000000203 131026 0000000000500{
0413306000000001EUR2 2000000020305131026 131026FRAIS TENUE DE COMPTE 0000000 0000000000099}
0713306 00001EUR2 20000000203 131026 0000000000401{
@@ -0,0 +1,14 @@
0130087 33100EUR2 50000000501 131026 0000000009900{
0430087000033100EUR2 5000000050105131026 131026VIR SEPA IOTA DISTRIBUTION 0000000 0000000021500{
0530087000033100EUR2 5000000050105131026 NOMIOTA DISTRIBUTION
0530087000033100EUR2 5000000050105131026 RIB30087331005000000050199
0530087000033100EUR2 5000000050105131026 IBEFR7630087331005000000050199
0530087000033100EUR2 5000000050105131026 CBECMCIFRPP
0530087000033100EUR2 5000000050105131026 LCCFACTURE 7731
0530087000033100EUR2 5000000050105131026 RCNSALE
0530087000033100EUR2 5000000050105131026 REFE2E-IOTA-7731
0430087000033100EUR2 5000000050105131026 131026PRLV SEPA KAPPA TELECOM 0000000 0000000000499R
0530087000033100EUR2 5000000050105131026 NPYKAPPA TELECOM
0530087000033100EUR2 5000000050105131026 RUMRUM-KAPPA-1
0530087000033100EUR2 5000000050105131026 LIBABONNEMENT
0730087 33100EUR2 50000000501 131026 0000000030900A
@@ -0,0 +1 @@
0115589 29701EUR2 10000000101 131026 0000000015000{ 0715589 29701EUR2 10000000101 131026 0000000015000{
@@ -0,0 +1 @@
0130002 00456EUR2 30000000301 131026 0000000001000{ 0730002 00456EUR2 30000000301 131026 0000000001000{ 0130002 00456EUR2 30000000302 131026 0000000025000{ 0430002000000456EUR2 3000000030205131026 131026VIR SEPA EPSILON SAS 0000000 0000000007800{ 0530002000000456EUR2 3000000030205131026 LIBACOMPTE CHANTIER 12 0430002000000456EUR2 3000000030205131026 131026CB STATION ZETA 0000000 0000000000612} 0730002 00456EUR2 30000000302 131026 0000000032188{ 0130002 00456EUR2 30000000303 131026 0000000000000{ 0730002 00456EUR2 30000000303 131026 0000000000000{ 0130002 00456EUR2 30000000304 131026 0000000003200{ 0430002000000456EUR2 3000000030405131026 131026REMISE CHEQUES 0000000 0000000004500{ 0730002 00456EUR2 30000000304 131026 0000000007700{
@@ -0,0 +1 @@
0115589 29701EUR2 10000000101 131026 0000000015000{ 0415589000029701EUR2 1000000010105131026 131026PRLV SEPA FOURNISSEUR ALPHA 0000000 0000000002504} 0515589000029701EUR2 1000000010105131026 LIBFACTURE 2026-0412 0515589000029701EUR2 1000000010105131026 RCNREF ALPHA 77881 0415589000029701EUR2 1000000010105131026 131026VIR SEPA CLIENT BETA 0000000 0000000012000{ 0515589000029701EUR2 1000000010105131026 LCCCOMMANDE 5521 0715589 29701EUR2 10000000101 131026 0000000024496{
+1
View File
@@ -0,0 +1 @@
this is not an xml document
@@ -0,0 +1,3 @@
Kundenprotokoll (PTK)
Auftragsart: C53 Auftragsnummer: A00T Teilnehmer: TESTUSER1
Status: Auftrag erfolgreich verarbeitet
@@ -0,0 +1,152 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import pprint
from unittest.mock import patch
from fintech.ebics import EbicsFunctionalError, EbicsKeyRing, EbicsTechnicalError
from odoo.exceptions import UserError
from odoo.tests import tagged
from .test_ebics_userid import EbicsKeysCommon
# Test passphrases for throwaway keys created in a temporary directory.
INIT_PHRASE = "init-passphrase"
NEXT_PHRASE = "next-passphrase"
OTHER_PHRASE = "other-passphrase"
WRONG_PHRASE = "wrong-passphrase"
@tagged("post_install", "-at_install")
class TestChangePassphrase(EbicsKeysCommon):
def setUp(self):
super().setUp()
self.userid = self._new_userid()
self._init_1(self.userid)
def _change(self, **vals):
wizard = self.env["ebics.change.passphrase"].create(
{"ebics_userid_id": self.userid.id, **vals}
)
wizard.change_passphrase()
return wizard
def test_change_passphrase(self):
wizard = self._change(
old_pass=INIT_PHRASE,
new_pass=NEXT_PHRASE,
new_pass_check=NEXT_PHRASE,
)
self.assertEqual(self.userid.ebics_passphrase, NEXT_PHRASE)
self.assertIn("has been changed", wizard.note)
keyring = EbicsKeyRing(keys=self.userid.ebics_keys_fn, passphrase=NEXT_PHRASE)
self.assertTrue(keyring["#USER"])
def test_wrong_old_passphrase(self):
with self.assertRaisesRegex(UserError, "Incorrect old passphrase"):
self._change(
old_pass=WRONG_PHRASE,
new_pass=NEXT_PHRASE,
new_pass_check=NEXT_PHRASE,
)
def test_verification_mismatch(self):
with self.assertRaisesRegex(UserError, "verification error"):
self._change(new_pass=NEXT_PHRASE, new_pass_check=OTHER_PHRASE)
def test_new_equals_old(self):
with self.assertRaisesRegex(UserError, "equal to old"):
self._change(new_pass=INIT_PHRASE, new_pass_check=INIT_PHRASE)
def test_wrong_old_passphrase_not_stored(self):
"""Without a stored passphrase, fintech rejects the wrong one."""
self.userid.ebics_passphrase_store = False
self.userid.ebics_passphrase = False
with self.assertRaisesRegex(UserError, "(?i)passphrase"):
self._change(
old_pass=WRONG_PHRASE,
new_pass=NEXT_PHRASE,
new_pass_check=NEXT_PHRASE,
)
def test_change_passphrase_not_stored(self):
"""The new passphrase must not be written when storing is off."""
self.userid.ebics_passphrase_store = False
self.userid.ebics_passphrase = False
wizard = self._change(
old_pass=INIT_PHRASE,
new_pass=NEXT_PHRASE,
new_pass_check=NEXT_PHRASE,
)
self.assertFalse(self.userid.ebics_passphrase)
self.assertIn("has been changed", wizard.note)
keyring = EbicsKeyRing(keys=self.userid.ebics_keys_fn, passphrase=NEXT_PHRASE)
self.assertTrue(keyring["#USER"])
class FakeAdminClient:
def __init__(self, error=None):
self.error = error
def _order(self, name):
if self.error:
raise self.error
return {"order": name, "Services": [{"ServiceName": "SCT"}]}
def HAA(self, parsed=False):
return self._order("HAA")
def HPD(self, parsed=False):
return self._order("HPD")
def HKD(self, parsed=False):
return self._order("HKD")
def HTD(self, parsed=False):
return self._order("HTD")
@tagged("post_install", "-at_install")
class TestAdminOrder(EbicsKeysCommon):
def _run(self, order_type, client):
wizard = self.env["ebics.admin.order"].create(
{
"ebics_config_id": self.ebics_config.id,
"ebics_userid_id": self.ebics_userid.id,
"admin_order_type": order_type,
}
)
wizard_class = type(wizard)
with patch.object(wizard_class, "_setup_client", return_value=client):
wizard.ebics_admin_order()
return wizard
def test_admin_orders(self):
for order_type in ("HAA", "HPD", "HKD", "HTD"):
with self.subTest(order_type=order_type):
wizard = self._run(order_type, FakeAdminClient())
expected = pprint.PrettyPrinter().pformat(
FakeAdminClient()._order(order_type)
)
self.assertEqual(wizard.note, expected)
def test_admin_order_errors(self):
cases = [
(EbicsTechnicalError("061001", "EBICS_AUTHENTICATION_FAILED"), "Technical"),
(
EbicsFunctionalError("091005", "EBICS_NO_DOWNLOAD_DATA_AVAILABLE"),
"Functional",
),
]
for error, expected in cases:
with self.subTest(error=type(error).__name__):
wizard = self._run("HAA", FakeAdminClient(error=error))
self.assertIn(
f"EBICS {expected} Error during execution of order HAA", wizard.note
)
self.assertIn(f"(code: {error.code})", wizard.note)
def test_admin_order_client_setup_failure(self):
wizard = self._run("HPD", False)
self.assertIn("client setup failed", wizard.note)
+52
View File
@@ -0,0 +1,52 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from odoo.exceptions import UserError
from odoo.tests import tagged
from .common import EbicsTestCommon
IBAN_FOR_COMPANY_TEST = "FR7630004000031234567890143"
@tagged("post_install", "-at_install")
class TestEbicsConfig(EbicsTestCommon):
def test_update_order_number(self):
cases = [
("A000", "A001"),
("A009", "A00A"),
("A00Z", "A010"),
("A0Z9", "A0ZA"),
("AZZZ", "B000"),
("ZZZY", "A000"),
# ZZZZ is accepted by the constraint, it must wrap as well
("ZZZZ", "A000"),
]
for current, expected in cases:
with self.subTest(current=current):
self.ebics_config._update_order_number(current)
self.assertEqual(self.ebics_config.order_number, expected)
def test_order_number_pattern(self):
for valid in ("A000", "B1Z9", "ZZZZ"):
with self.subTest(valid=valid):
self.ebics_config.order_number = valid
# No 5-character case: Char(size=4) truncates before the constraint runs.
for invalid in ("a001", "A01", "1000", "A-01"):
with self.subTest(invalid=invalid), self.assertRaises(UserError):
self.ebics_config.order_number = invalid
def test_unlink_confirmed_config_is_blocked(self):
with self.assertRaises(UserError):
self.ebics_config.unlink()
def test_unlink_draft_config(self):
self.ebics_userid.unlink()
self.ebics_config.set_to_draft()
self.ebics_config.unlink()
self.assertFalse(self.ebics_config.exists())
def test_company_ids_follow_journals(self):
journal = self._create_bank_journal("TCMP", IBAN_FOR_COMPANY_TEST)
self.assertEqual(self.ebics_config.company_ids, journal.company_id)
self.assertEqual(journal.ebics_config_id, self.ebics_config)
+170
View File
@@ -0,0 +1,170 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from unittest.mock import patch
from odoo import Command
from odoo.exceptions import UserError
from odoo.tests import tagged
from .common import IBAN_SPK, EbicsTestCommon
@tagged("post_install", "-at_install")
class TestEbicsFile(EbicsTestCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.journal = cls._create_bank_journal("TSPK", IBAN_SPK)
def _statement(self, name, date="2026-10-13", import_format="camt053"):
statement = self.env["account.bank.statement"].create(
{
"name": name,
"journal_id": self.journal.id,
"line_ids": [
Command.create(
{
"journal_id": self.journal.id,
"date": date,
"payment_ref": f"line {name}",
"amount": 10.0,
}
)
],
}
)
statement.import_format = import_format
return statement
def test_duplicate_statement_is_removed(self):
self._statement("ST-1")
duplicate = self._statement("ST-1")
res = self._new_res()
res["statement_ids"] = duplicate.ids
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
kept = ebics_file._statement_duplicate_check(res, duplicate)
self.assertFalse(kept)
self.assertFalse(duplicate.exists())
self.assertEqual(res["statement_ids"], [])
self.assertEqual(res["notifications"][0]["type"], "warning")
self.assertIn("ST-1", res["notifications"][0]["message"])
def test_duplicate_check_scope(self):
"""A checked statement only collides with the same name, date and format."""
# existing statements: same name, other date / same name, other format
self._statement("ST-2", date="2026-10-14")
self._statement("ST-2", import_format="cfonb120")
new = self._statement("ST-2")
# outside DUP_CHECK_FORMATS: never checked
unchecked = self._statement("ST-2", import_format="camt052")
statements = new | unchecked
res = self._new_res()
res["statement_ids"] = statements.ids
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
kept = ebics_file._statement_duplicate_check(res, statements)
self.assertEqual(kept, statements)
self.assertFalse(res["notifications"])
def test_process_result_note(self):
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
ebics_file.note_process = ""
statement = self._statement("ST-3")
res = {
"statement_ids": statement.ids,
"notifications": [
{"type": "error", "message": "Broken entry", "details": "line 4"},
{"type": "warning", "message": "Odd balance"},
{"info": "Something to know"},
"Plain text warning",
],
}
ebics_file._process_download_result(res, file_format="camt053")
note = ebics_file.note_process
self.assertIn("Broken entry\nline 4", note)
self.assertIn("Number of errors: 1", note)
self.assertIn("Number of warnings: 3", note)
self.assertIn("1 bank statement has been imported", note)
self.assertEqual(ebics_file.bank_statement_ids, statement)
self.assertEqual(statement.import_format, "camt053")
self.assertEqual(ebics_file.company_ids, self.company)
def test_process_result_empty_file(self):
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
ebics_file.note_process = ""
ebics_file._process_download_result(self._new_res(), file_format="camt053")
self.assertIn("doesn't contain any transaction", ebics_file.note_process)
def test_unlink_done_file_is_blocked(self):
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
ebics_file.set_to_done()
with self.assertRaises(UserError):
ebics_file.unlink()
def test_unlink_removes_statements(self):
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
statement = self._statement("ST-4")
statement.ebics_file_id = ebics_file
ebics_file.unlink()
self.assertFalse(statement.exists())
def test_unlink_pain002_file(self):
"""pain.002 processing is a placeholder: its files must stay removable."""
ebics_file = self._create_ebics_file(
"ptk_protocol.txt", self.env.ref("account_ebics.ebics_ff_Z01")
)
ebics_file.unlink()
self.assertFalse(ebics_file.exists())
def test_process_format_without_method(self):
"""Modelled on a Sparkasse customer protocol (PTK): stored, not processed."""
ptk = self.env["ebics.file.format"].create(
{"name": "PTK", "type": "down", "order_type": "PTK", "suffix": "txt"}
)
ebics_file = self._create_ebics_file("ptk_protocol.txt", ptk)
with self.assertRaisesRegex(UserError, "no support"):
ebics_file.process()
def test_check_import_module(self):
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
self.assertTrue(ebics_file._check_import_module("account_ebics"))
self.assertFalse(
ebics_file._check_import_module("no_such_module", raise_if_not_found=False)
)
with self.assertRaises(UserError):
ebics_file._check_import_module("no_such_module")
def test_enterprise_import_does_not_commit_in_tests(self):
"""The Enterprise path commits after each statement in production."""
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
statement = self._statement("ST-5")
st_datas = [{"acc_number": "0010000002", "journal_id": self.journal.id}]
def create_statement(res, st_data):
res["statement_ids"].append(statement.id)
file_class = type(ebics_file)
cursor_class = type(self.env.cr)
res = self._new_res()
with (
patch.object(
file_class, "_create_bank_statement_oe", side_effect=create_statement
),
patch.object(cursor_class, "commit", side_effect=AssertionError("commit")),
):
ebics_file._process_bank_statement_oe(res, st_datas)
self.assertEqual(res["statement_ids"], statement.ids)
self.assertFalse(res["notifications"])
def test_enterprise_import_reports_errors(self):
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
st_datas = [{"acc_number": "0010000002", "journal_id": self.journal.id}]
res = self._new_res()
with patch.object(
type(ebics_file),
"_create_bank_statement_oe",
side_effect=UserError("Journal mismatch"),
):
ebics_file._process_bank_statement_oe(res, st_datas)
self.assertIn("Journal mismatch", res["notifications"][0]["message"])
self.assertIn("0010000002", res["notifications"][0]["message"])
@@ -0,0 +1,230 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from lxml import etree
from odoo.tests import tagged
from .common import (
IBAN_CA833,
IBAN_CA879,
IBAN_CIC,
IBAN_CMB,
IBAN_HVB,
IBAN_LCL,
IBAN_MULTI,
IBAN_SPK,
IBAN_SUFFIX,
EbicsTestCommon,
)
@tagged("post_install", "-at_install")
class TestSplitCfonb(EbicsTestCommon):
"""EBICS files may hold several accounts and empty statements: they are
split per statement before being handed to the CFONB parser."""
def _split(self, sample):
ebics_file = self._create_ebics_file(sample, self.ff_cfonb120)
res = self._new_res()
return ebics_file._split_cfonb(res), res
def _lines(self, st_data):
return bytes(st_data["data"]).decode("latin-1").splitlines()
def test_no_line_terminator_single_account(self):
"""Modelled on Crédit Mutuel de Bretagne: no line terminator at all."""
journal = self._create_bank_journal("TCMB", IBAN_CMB)
datas, res = self._split("cfonb120_no_eol_single_account.dat")
self.assertFalse(res["notifications"])
self.assertEqual(len(datas), 1)
self.assertEqual(datas[0]["acc_number"], "10000000101")
self.assertEqual(datas[0]["journal_id"], journal.id)
self.assertEqual(datas[0]["company_id"], self.company.id)
lines = self._lines(datas[0])
self.assertEqual(
[x[:2] for x in lines], ["01", "04", "05", "05", "04", "05", "07"]
)
self.assertTrue(all(len(x) == 120 for x in lines))
def test_empty_statements_only(self):
self._create_bank_journal("TCMB", IBAN_CMB)
datas, res = self._split("cfonb120_no_eol_empty_only.dat")
self.assertEqual(datas, [])
self.assertFalse(res["notifications"])
def test_multi_account_with_complement_lines(self):
"""Modelled on Crédit Agricole: 3 accounts, the middle one empty, and a
positive-zero overpunch ('{') on its balance."""
j1 = self._create_bank_journal("TCA1", IBAN_CA833[0])
j3 = self._create_bank_journal("TCA3", IBAN_CA833[2])
datas, res = self._split("cfonb120_lf_multi_account_05.dat")
self.assertFalse(res["notifications"])
self.assertEqual([d["journal_id"] for d in datas], [j1.id, j3.id])
self.assertEqual(
[x[:2] for x in self._lines(datas[0])],
["01", "04", "05", "05", "05", "04", "05", "05", "07"],
)
def test_multi_account_missing_journal(self):
self._create_bank_journal("TCA1", IBAN_CA833[0])
datas, res = self._split("cfonb120_lf_multi_account_05.dat")
self.assertEqual(len(datas), 1)
self.assertEqual(len(res["notifications"]), 1)
self.assertEqual(res["notifications"][0]["type"], "error")
self.assertIn("20000000203", res["notifications"][0]["message"])
def test_no_line_terminator_mixed_empty_and_full(self):
"""Modelled on LCL: 4 accounts, no terminator, empty and full mixed."""
journals = [
self._create_bank_journal(f"TLC{i}", iban)
for i, iban in enumerate(IBAN_LCL)
]
datas, res = self._split("cfonb120_no_eol_multi_account_mixed.dat")
self.assertFalse(res["notifications"])
self.assertEqual(
[d["journal_id"] for d in datas], [journals[1].id, journals[3].id]
)
def test_minimal_file_without_complement_lines(self):
"""Modelled on Crédit Agricole 879: no 05 records, an account label in
the free zone of 01 and dashes in 07, three empty statements before
the only one with transactions."""
journal = self._create_bank_journal("TCA9", IBAN_CA879[3])
datas, res = self._split("cfonb120_lf_minimal_no_05.dat")
self.assertFalse(res["notifications"])
self.assertEqual(len(datas), 1)
self.assertEqual(datas[0]["journal_id"], journal.id)
self.assertEqual(
[x[:2] for x in self._lines(datas[0])], ["01", "04", "04", "07"]
)
def test_rich_complement_lines_are_kept(self):
"""Modelled on CIC: every 05 qualifier stays with its statement."""
self._create_bank_journal("TCIC", IBAN_CIC)
datas, res = self._split("cfonb120_lf_rich_05.dat")
self.assertFalse(res["notifications"])
self.assertEqual(len(datas), 1)
qualifiers = [x[45:48] for x in self._lines(datas[0]) if x[:2] == "05"]
self.assertEqual(
qualifiers,
["NOM", "RIB", "IBE", "CBE", "LCC", "RCN", "REF", "NPY", "RUM", "LIB"],
)
def test_bad_length(self):
datas, res = self._split("cfonb120_bad_length.dat")
self.assertEqual(datas, [])
self.assertEqual(res["notifications"][0]["type"], "error")
self.assertIn("120", res["notifications"][0]["message"])
def test_journal_in_other_currency(self):
usd = self.env.ref("base.USD")
self._create_bank_journal("TCMB", IBAN_CMB, currency=usd)
datas, res = self._split("cfonb120_no_eol_single_account.dat")
self.assertEqual(datas, [])
self.assertEqual(res["notifications"][0]["type"], "error")
@tagged("post_install", "-at_install")
class TestSplitCamt(EbicsTestCommon):
def _split(self, sample):
ebics_file = self._create_ebics_file(sample, self.ff_camt053)
res = self._new_res()
return ebics_file._split_camt(res), res
def _statements(self, st_data):
root = etree.fromstring(bytes(st_data["data"]))
ns = {"ns": root.nsmap[None]}
return root.xpath("//ns:Stmt/ns:Acct/ns:Id//text()", namespaces=ns)
def test_single_statement_clav_fx(self):
"""Modelled on UniCredit HVB: OPBD/CLBD/CLAV balances, FX entry."""
journal = self._create_bank_journal("THVB", IBAN_HVB)
datas, res = self._split("camt053_hvb_clav_fx.xml")
self.assertFalse(res["notifications"])
self.assertEqual(len(datas), 1)
self.assertEqual(datas[0]["journal_id"], journal.id)
self.assertEqual(datas[0]["acc_number"], IBAN_HVB)
def test_multi_account_is_split(self):
j1 = self._create_bank_journal("TMU1", IBAN_MULTI[0])
j2 = self._create_bank_journal("TMU2", IBAN_MULTI[1])
datas, res = self._split("camt053_multi_account.xml")
self.assertFalse(res["notifications"])
self.assertEqual([d["journal_id"] for d in datas], [j1.id, j2.id])
self.assertEqual(self._statements(datas[0]), [IBAN_MULTI[0]])
self.assertEqual(self._statements(datas[1]), [IBAN_MULTI[1]])
def test_currency_suffix_is_stripped(self):
"""Built from the code: some banks (e.g. Commerzbank) append the
currency to the account number."""
journal = self._create_bank_journal("TSUF", IBAN_SUFFIX)
datas, res = self._split("camt053_currency_suffix.xml")
self.assertFalse(res["notifications"])
self.assertEqual(datas[0]["acc_number"], "0010000005")
self.assertEqual(datas[0]["journal_id"], journal.id)
def test_statement_without_entries_is_skipped(self):
self._create_bank_journal("TSPK", IBAN_SPK)
datas, res = self._split("camt053_no_entries.xml")
self.assertEqual(datas, [])
self.assertFalse(res["notifications"])
def test_statement_without_account(self):
datas, res = self._split("camt053_no_account.xml")
self.assertEqual(datas, [])
self.assertEqual(res["notifications"][0]["type"], "error")
self.assertIn(
"No bank account number found", res["notifications"][0]["message"]
)
def test_invalid_xml(self):
datas, res = self._split("invalid.xml")
self.assertEqual(datas, [])
self.assertEqual(res["notifications"][0]["type"], "error")
self.assertIn("Invalid XML", res["notifications"][0]["message"])
@tagged("post_install", "-at_install")
class TestLookupJournal(EbicsTestCommon):
def setUp(self):
super().setUp()
self.ebics_file = self._create_ebics_file(
"camt053_sparkasse.xml", self.ff_camt053
)
self.res = self._new_res()
def test_unknown_currency(self):
currency, journal = self.ebics_file._lookup_journal(
self.res, "0010000002", "XYZ"
)
self.assertFalse(currency)
self.assertFalse(journal)
self.assertIn("XYZ", self.res["notifications"][0]["message"])
def test_no_journal(self):
currency, journal = self.ebics_file._lookup_journal(
self.res, "0010000002", "EUR"
)
self.assertEqual(currency, self.eur)
self.assertFalse(journal)
self.assertEqual(self.res["notifications"][0]["type"], "error")
def test_journal_currency_match(self):
expected = self._create_bank_journal("TSPK", IBAN_SPK)
currency, journal = self.ebics_file._lookup_journal(
self.res, "0010000002", "eur"
)
self.assertEqual(currency, self.eur)
self.assertEqual(journal, expected)
self.assertFalse(self.res["notifications"])
def test_journal_without_currency_uses_company_currency(self):
expected = self._create_bank_journal("TSPK", IBAN_SPK)
expected.sudo().currency_id = False
code = self.company.currency_id.name
currency, journal = self.ebics_file._lookup_journal(
self.res, "0010000002", code
)
self.assertEqual(currency, self.company.currency_id)
self.assertEqual(journal, expected)
+283
View File
@@ -0,0 +1,283 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import gc
import itertools
import os
import shutil
import tempfile
from unittest.mock import patch
from urllib.error import URLError
from fintech.ebics import EbicsFunctionalError, EbicsKeyRing, EbicsTechnicalError
from odoo import Command, fields
from odoo.exceptions import UserError
from odoo.tests import tagged
from odoo.tools import mute_logger
from odoo.addons.account_ebics.models import ebics_userid as ebics_userid_module
from .common import EbicsTestCommon
# Throwaway passphrase for keys created in a temporary directory.
WRONG_PHRASE = "wrong-passphrase"
PUBLIC_BANK_KEYS = (
"Public bank keys (simulated)\nX002 hash: 00 11 22\nE002 hash: 33 44 55\n"
)
def fake_init_client(hev=None, ini_error=None, hpb_error=None):
"""Return a stand-in for fintech's EbicsClient covering the bank side of
the key ceremony. Keys, certificates and the INI letter stay real."""
class FakeInitClient:
calls = []
def __init__(self, bank, user, version=None):
self.bank = bank
def HEV(self):
self.calls.append("HEV")
return hev if hev is not None else {"H004": "2.5", "H005": "3.0"}
def _order(self, name):
self.calls.append(name)
return self.bank._next_order_id("PARTNER1")
def INI(self):
if ini_error:
raise ini_error
return self._order("INI")
def HIA(self):
return self._order("HIA")
def HPB(self):
if hpb_error:
raise hpb_error
self.calls.append("HPB")
return PUBLIC_BANK_KEYS
return FakeInitClient
class EbicsKeysCommon(EbicsTestCommon):
"""Real keys in a temporary directory, simulated bank."""
_userid_seq = itertools.count(1)
@classmethod
def setUpClass(cls):
super().setUpClass()
keys_dir = tempfile.mkdtemp(prefix="ebics_keys_test_")
cls.addClassCleanup(shutil.rmtree, keys_dir, ignore_errors=True)
cls.ebics_config.write({"ebics_keys": keys_dir, "ebics_key_bitlength": 2048})
cls.journal = cls._create_bank_journal("TKEY", "FR7630004000031234567890143")
cls.bank_fr = cls.journal.bank_account_id.sudo()
cls.bank_fr.write(
{"bank_name": "Banque Test", "country_id": cls.env.ref("base.fr").id}
)
def _new_userid(self, **vals):
# A new name per test: fintech keeps open keyrings per file in-process.
return self.env["ebics.userid"].create(
{
"name": f"KEYUSER{next(self._userid_seq)}",
"ebics_config_id": self.ebics_config.id,
"user_ids": [Command.set(self.env.user.ids)],
"company_ids": [Command.set(self.company.ids)],
"ebics_passphrase": "init-passphrase",
**vals,
}
)
def _init_1(self, userid, client_class=None):
client_class = client_class or fake_init_client()
with patch.object(ebics_userid_module, "EbicsClient", client_class):
userid.ebics_init_1()
return client_class
@tagged("post_install", "-at_install")
class TestKeyCeremony(EbicsKeysCommon):
def test_full_ceremony(self):
userid = self._new_userid(ebics_key_x509=True, ebics_key_x509_dn_cn="Test")
client_class = self._init_1(userid)
self.assertEqual(client_class.calls, ["HEV", "INI", "HIA"])
self.assertEqual(userid.state, "init")
self.assertTrue(os.path.isfile(userid.ebics_keys_fn))
self.assertTrue(userid.ebics_keys_found)
self.assertTrue(bytes(userid.ebics_ini_letter).startswith(b"%PDF"))
today = fields.Date.today().isoformat()
self.assertEqual(userid.ebics_ini_letter_fn, f"TESTHOST_ini_letter_{today}.pdf")
userid.ebics_init_2()
self.assertEqual(userid.state, "get_bank_keys")
with patch.object(ebics_userid_module, "EbicsClient", client_class):
userid.ebics_init_3()
self.assertEqual(userid.state, "to_verify")
self.assertEqual(
bytes(userid.ebics_public_bank_keys).decode(), PUBLIC_BANK_KEYS
)
self.assertEqual(
userid.ebics_public_bank_keys_fn, f"TESTHOST_public_bank_keys_{today}.txt"
)
bank_class = ebics_userid_module.EbicsBank
with patch.object(bank_class, "activate_keys") as activate_keys:
userid.ebics_init_4()
activate_keys.assert_called_once()
self.assertEqual(userid.state, "active_keys")
# stored passphrase is kept
self.assertEqual(userid.ebics_passphrase, "init-passphrase")
def test_passphrase_not_stored_is_cleared(self):
userid = self._new_userid(ebics_passphrase_store=False)
self._init_1(userid)
self.assertFalse(userid.ebics_passphrase)
def test_existing_keys_are_kept(self):
"""A second init reuses the key file: reset tools must delete it."""
userid = self._new_userid()
self._init_1(userid)
with open(userid.ebics_keys_fn, "rb") as f:
keys = f.read()
userid.set_to_draft()
self._init_1(userid)
with open(userid.ebics_keys_fn, "rb") as f:
self.assertEqual(f.read(), keys)
def test_step_guards(self):
userid = self._new_userid()
userid.state = "init"
with self.assertRaisesRegex(UserError, "draft"):
userid.ebics_init_1()
userid.state = "draft"
for method in ("ebics_init_2", "ebics_init_3", "ebics_init_4"):
with self.subTest(method=method), self.assertRaises(UserError):
getattr(userid, method)()
def test_init_requires_passphrase(self):
userid = self._new_userid(ebics_passphrase=False)
with self.assertRaisesRegex(UserError, "passphrase"):
userid.ebics_init_1()
def test_3skey_requires_certificate(self):
userid = self._new_userid(swift_3skey=True)
with self.assertRaisesRegex(UserError, "3SKey certificate"):
userid.ebics_init_1()
def test_init_requires_a_journal_with_bank(self):
self.ebics_config.journal_ids = False
userid = self._new_userid()
with self.assertRaisesRegex(UserError, "No bank defined"):
self._init_1(userid)
def test_version_not_supported_by_bank(self):
userid = self._new_userid()
with self.assertRaisesRegex(UserError, "version mismatch"):
self._init_1(userid, fake_init_client(hev={"H003": "2.4"}))
self.assertEqual(userid.state, "draft")
def test_init_errors(self):
cases = [
(URLError("connection refused"), "urlopen error"),
(
EbicsFunctionalError("091002", "EBICS_INVALID_USER_OR_USER_STATE"),
"091002",
),
(EbicsTechnicalError("061001", "EBICS_AUTHENTICATION_FAILED"), "061001"),
]
for error, expected in cases:
with self.subTest(error=type(error).__name__):
userid = self._new_userid()
with (
mute_logger(ebics_userid_module.__name__),
self.assertRaisesRegex(UserError, expected),
):
self._init_1(userid, fake_init_client(ini_error=error))
def test_get_bank_keys_error(self):
userid = self._new_userid()
self._init_1(userid)
userid.ebics_init_2()
error = EbicsFunctionalError("091002", "EBICS_INVALID_USER_OR_USER_STATE")
client_class = fake_init_client(hpb_error=error)
with (
patch.object(ebics_userid_module, "EbicsClient", client_class),
self.assertRaisesRegex(UserError, "EBICS Functional Error"),
):
userid.ebics_init_3()
def test_h003_order_numbers(self):
self.ebics_config.write({"ebics_version": "H003", "order_number": "A000"})
userid = self._new_userid()
self._init_1(userid, fake_init_client(hev={"H003": "2.4"}))
# INI uses A000, HIA uses A001
self.assertEqual(self.ebics_config.order_number, "A002")
def test_ini_letter_language(self):
calls = []
class SpyUser(ebics_userid_module.EbicsUser):
def create_ini_letter(self, bankname, lang=None, **kwargs):
calls.append((bankname, lang))
return b"%PDF-1.4 spy"
cases = [
("base.fr", "fr_FR", "fr"),
("base.de", "fr_FR", "de"),
("base.be", "fr_FR", "fr"),
("base.be", "en_US", "en"),
]
for country, user_lang, expected in cases:
with self.subTest(country=country, user_lang=user_lang):
lang = (
self.env["res.lang"]
.sudo()
.with_context(active_test=False)
.search([("code", "=", user_lang)])
)
lang.active = True
self.bank_fr.country_id = self.env.ref(country)
self.env.user.lang = user_lang
userid = self._new_userid()
with patch.object(ebics_userid_module, "EbicsUser", SpyUser):
self._init_1(userid)
self.assertEqual(calls[-1], ("Banque Test", expected))
def test_key_renewal_requires_draft_config(self):
userid = self._new_userid()
with self.assertRaisesRegex(UserError, "Key Renewal"):
userid.set_to_get_bank_keys()
self.ebics_config.set_to_draft()
userid.set_to_get_bank_keys()
self.assertEqual(userid.state, "get_bank_keys")
def test_h005_requires_x509(self):
self.ebics_config.ebics_version = "H005"
with self.assertRaisesRegex(UserError, "X.509"):
self._new_userid(ebics_key_x509=False)
def test_stored_passphrase_is_checked(self):
userid = self._new_userid()
self._init_1(userid)
gc.collect() # no other keyring instance: fintech raises ValueError
userid.ebics_passphrase = WRONG_PHRASE
with self.assertRaisesRegex(UserError, "Passphrase mismatch"):
userid._onchange_ebics_passphrase_store()
def test_stored_passphrase_is_checked_with_open_keyring(self):
"""In a worker the keyring may already be open with the right
passphrase: fintech then raises RuntimeError."""
userid = self._new_userid()
self._init_1(userid)
open_keyring = EbicsKeyRing(
keys=userid.ebics_keys_fn, passphrase=userid.ebics_passphrase
)
userid.ebics_passphrase = WRONG_PHRASE
with self.assertRaisesRegex(UserError, "Passphrase mismatch"):
userid._onchange_ebics_passphrase_store()
del open_keyring
+249
View File
@@ -0,0 +1,249 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from datetime import date
from fintech.ebics import (
EbicsFunctionalError,
EbicsTechnicalError,
EbicsVerificationError,
)
from odoo.tests import tagged
from .common import EbicsTestCommon, FakeEbicsClient, read_sample
@tagged("post_install", "-at_install")
class TestEbicsXferDownload(EbicsTestCommon):
def test_line_terminator(self):
xfer = self.env["ebics.xfer"]
line_a, line_b = b"A" * 120, b"B" * 120
self.assertEqual(
xfer._handle_cfonb120(line_a + line_b), line_a + b"\n" + line_b + b"\n"
)
self.assertEqual(
xfer._handle_cfonb120(line_a + b"\r\n" + line_b + b"\r\n"),
line_a + b"\n" + line_b + b"\n",
)
self.assertEqual(
xfer._handle_cfonb240(line_a + line_b), line_a + line_b + b"\n"
)
# Current behaviour: an incomplete trailing line is dropped.
self.assertEqual(xfer._handle_cfonb120(line_a + b"C" * 10), line_a + b"\n")
def test_download_fdl_cfonb(self):
data = read_sample("cfonb120_no_eol_single_account.dat")
wizard = self._download_wizard(self.ff_cfonb120, date_to=date(2026, 10, 13))
with self._fake_client(FakeEbicsClient(downloads={"FDL": data})) as client:
action = wizard.ebics_download()
self.assertEqual(action["context"]["err_cnt"], 0)
ebics_file = self.env["ebics.file"].browse(action["context"]["ebics_file_ids"])
self.assertEqual(ebics_file.name, "TESTHOST_PARTNER1_2026-10-13.cfonb120.dat")
self.assertEqual(ebics_file.state, "draft")
self.assertEqual(ebics_file.ebics_userid_id, self.ebics_userid)
self.assertEqual(ebics_file.company_ids, self.ebics_config.company_ids)
# FDL CFONB downloads get a line terminator every 120 characters
stored = bytes(ebics_file.data)
self.assertEqual(stored.count(b"\n"), 7)
self.assertEqual(client.confirmed, [("TRANS0001", True)])
self.assertIn("is available for further processing", wizard.note)
def test_download_btd_cfonb(self):
data = read_sample("cfonb120_no_eol_single_account.dat")
wizard = self._download_wizard(self.ff_btd_cfonb120, date_to=date(2026, 10, 13))
with self._fake_client(FakeEbicsClient(downloads={"BTD": data})):
action = wizard.ebics_download()
ebics_file = self.env["ebics.file"].browse(action["context"]["ebics_file_ids"])
self.assertEqual(len(ebics_file), 1)
# BTD formats have no name, hence no line terminator handler.
self.assertEqual(bytes(ebics_file.data), data)
def test_same_name_in_another_format(self):
"""FDL and BTD CFONB formats share the file suffix: same file name,
but a different format is not a duplicate."""
data = read_sample("cfonb120_no_eol_single_account.dat")
names = []
for file_format, order_type in (
(self.ff_cfonb120, "FDL"),
(self.ff_btd_cfonb120, "BTD"),
):
wizard = self._download_wizard(file_format, date_to=date(2026, 10, 13))
client = FakeEbicsClient(downloads={order_type: data})
with self._fake_client(client):
action = wizard.ebics_download()
self.assertEqual(action["context"]["err_cnt"], 0)
ebics_file = self.env["ebics.file"].browse(
action["context"]["ebics_file_ids"]
)
names.append(ebics_file.name)
self.assertEqual(names[0], names[1])
def test_download_same_file_twice(self):
data = read_sample("cfonb120_no_eol_single_account.dat")
for expected_errors in (0, 1):
wizard = self._download_wizard(self.ff_cfonb120, date_to=date(2026, 10, 13))
with self._fake_client(FakeEbicsClient(downloads={"FDL": data})) as client:
action = wizard.ebics_download()
self.assertEqual(action["context"]["err_cnt"], expected_errors)
self.assertIn("has already been downloaded", wizard.note)
self.assertEqual(client.confirmed, [("TRANS0001", False)])
def test_download_several_documents(self):
ptk = self.env["ebics.file.format"].create(
{"name": "PTK", "type": "down", "order_type": "PTK", "suffix": "txt"}
)
data = read_sample("ptk_protocol.txt")
wizard = self._download_wizard(ptk)
client = FakeEbicsClient(downloads={"PTK": {"doc1": data, "doc2": data}})
with self._fake_client(client):
action = wizard.ebics_download()
ebics_files = self.env["ebics.file"].browse(action["context"]["ebics_file_ids"])
self.assertEqual(
sorted(ebics_files.mapped("name")),
["TESTHOST_PARTNER1_doc1.txt", "TESTHOST_PARTNER1_doc2.txt"],
)
# no processing method: the files are done right away
self.assertEqual(set(ebics_files.mapped("state")), {"done"})
def test_mark_as_downloaded(self):
data = read_sample("cfonb120_no_eol_single_account.dat")
wizard = self._download_wizard(self.ff_cfonb120).with_context(
ebics_mark_as_downloaded=True
)
with self._fake_client(FakeEbicsClient(downloads={"FDL": data})) as client:
action = wizard.ebics_download()
self.assertFalse(action["context"]["ebics_file_ids"])
self.assertEqual(client.confirmed, [("TRANS0001", True)])
def test_download_errors(self):
cases = [
(
EbicsFunctionalError("091005", "EBICS_NO_DOWNLOAD_DATA_AVAILABLE"),
"EBICS Functional Error",
"EBICS_NO_DOWNLOAD_DATA_AVAILABLE (code: 091005)",
),
(
EbicsTechnicalError("061002", "EBICS_INVALID_REQUEST"),
"EBICS Technical Error",
"EBICS_INVALID_REQUEST (code: 061002)",
),
(
EbicsVerificationError(),
"EBICS Verification Error",
"could not be verified",
),
(RuntimeError("socket closed"), "Unknown Error", "socket closed"),
]
for error, title, detail in cases:
with self.subTest(error=type(error).__name__):
wizard = self._download_wizard(self.ff_cfonb120)
with self._fake_client(FakeEbicsClient(error=error)) as client:
action = wizard.ebics_download()
self.assertEqual(action["context"]["err_cnt"], 1)
self.assertFalse(action["context"]["ebics_file_ids"])
self.assertIn(title, wizard.note)
self.assertIn(detail, wizard.note)
self.assertEqual(client.confirmed, [("TRANS0001", False)])
def test_client_setup_failure(self):
wizard = self._download_wizard(self.ff_cfonb120)
with self._fake_client(False):
action = wizard.ebics_download()
self.assertEqual(action["context"]["err_cnt"], 1)
self.assertIn("client setup failed", wizard.note)
@tagged("post_install", "-at_install")
class TestEbicsXferUpload(EbicsTestCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.ff_btu = cls.env["ebics.file.format"].create(
{
"type": "up",
"order_type": "BTU",
"btf_service": "SCT",
"btf_message": "pain.001",
"suffix": "xml",
}
)
cls.ff_ful = cls.env.ref("account_ebics.ebics_ff_LCR")
journal = cls._create_bank_journal("TUPL", "FR7630004000031234567890143")
journal.bank_account_id.sudo().write(
{"bank_name": "Test Bank FR", "country_id": cls.env.ref("base.fr").id}
)
def test_upload_btu(self):
wizard = self._upload_wizard(self.ff_btu, test_mode=True)
with self._fake_client(FakeEbicsClient(order_id="N042")) as client:
ebics_file = wizard._ebics_upload()
self.assertEqual(ebics_file.name, "pay.xml")
self.assertEqual(ebics_file.state, "done")
self.assertEqual(ebics_file.pain_state, "uploaded")
self.assertEqual(ebics_file.ebics_order_number, "N042")
self.assertEqual(client.uploads, [("BTU", b"<Document/>", {"TEST": "TRUE"})])
self.assertIn("OrderID N042", wizard.note)
# H004: the order number is managed by the bank
self.assertFalse(self.ebics_config.order_number)
def test_upload_same_name_twice(self):
"""The counter goes before the extension and does not stack up."""
names = []
for _i in range(4):
wizard = self._upload_wizard(self.ff_btu)
with self._fake_client(FakeEbicsClient()):
names.append(wizard._ebics_upload().name)
self.assertEqual(names, ["pay.xml", "pay_1.xml", "pay_2.xml", "pay_3.xml"])
# without extension
wizard = self._upload_wizard(self.ff_btu, fname="pay")
with self._fake_client(FakeEbicsClient()):
self.assertEqual(wizard._ebics_upload().name, "pay")
wizard = self._upload_wizard(self.ff_btu, fname="pay")
with self._fake_client(FakeEbicsClient()):
self.assertEqual(wizard._ebics_upload().name, "pay_1")
def test_upload_ful_h003_order_number(self):
self.ebics_config.write({"ebics_version": "H003", "order_number": "A00Z"})
wizard = self._upload_wizard(self.ff_ful, fname="lcr.txt")
with self._fake_client(FakeEbicsClient(order_id="A00Z")) as client:
ebics_file = wizard._ebics_upload()
self.assertEqual(ebics_file.ebics_order_number, "A00Z")
self.assertEqual(client.uploads[0][0], "FUL")
self.assertEqual(client.uploads[0][2], {"country": "FR"})
self.assertEqual(self.ebics_config.order_number, "A010")
def test_upload_h003_failure_still_increments(self):
"""Pinned behaviour: the order number moves on even if the upload failed."""
self.ebics_config.write({"ebics_version": "H003", "order_number": "B000"})
wizard = self._upload_wizard(self.ff_ful, fname="lcr.txt")
error = EbicsFunctionalError("091112", "EBICS_INVALID_ORDER_PARAMS")
with self._fake_client(FakeEbicsClient(error=error)):
ebics_file = wizard._ebics_upload()
self.assertFalse(ebics_file)
self.assertEqual(self.ebics_config.order_number, "B001")
self.assertIn("EBICS Functional Error", wizard.note)
self.assertIn("EBICS_INVALID_ORDER_PARAMS (code: 091112)", wizard.note)
def test_upload_errors(self):
cases = [
(EbicsTechnicalError("061001", "EBICS_AUTHENTICATION_FAILED"), "Technical"),
(EbicsVerificationError(), "Verification"),
(RuntimeError("socket closed"), "Unknown Error"),
]
for error, expected in cases:
with self.subTest(error=type(error).__name__):
wizard = self._upload_wizard(self.ff_btu)
with self._fake_client(FakeEbicsClient(error=error)):
self.assertFalse(wizard._ebics_upload())
self.assertIn(expected, wizard.note)
def test_upload_onchange_selects_format(self):
"""A single upload format on the config is selected automatically."""
self.ebics_config.ebics_file_format_ids = self.ff_btu
wizard = self.env["ebics.xfer"].new(
{"ebics_config_id": self.ebics_config.id, "upload_fname": "pay.xml"}
)
wizard._onchange_ebics_config_id()
self.assertEqual(wizard.format_id, self.ff_btu)
self.assertEqual(wizard.ebics_userid_id, self.ebics_userid)
@@ -0,0 +1,115 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from unittest.mock import patch
from odoo.exceptions import UserError
from odoo.tests import tagged
from odoo.tools.binary import BinaryBytes
from odoo.addons.account_ebics.wizards import ebics_xfer as ebics_xfer_module
from .test_ebics_userid import EbicsKeysCommon
# Throwaway passphrase for keys created in a temporary directory.
WRONG_PHRASE = "wrong-passphrase"
def capturing_client(captured, init_error=None):
"""Stand-in for fintech's EbicsClient that records the real EbicsBank and
EbicsUser built by ebics.xfer._setup_client."""
class CapturingClient:
def __init__(self, bank, user, version=None):
if init_error:
raise init_error
captured.update(bank=bank, user=user, version=version)
self.bank = bank
def FUL(self, filetype, data, **kwargs):
# As fintech does on H003: the OrderID comes from the bank object.
return self.bank._next_order_id(captured["user"].partnerid)
return CapturingClient
@tagged("post_install", "-at_install")
class TestSetupClient(EbicsKeysCommon):
"""ebics.xfer._setup_client with real keys; only the transport is faked."""
def setUp(self):
super().setUp()
self.userid = self._new_userid()
self._init_1(self.userid)
self.userid.state = "active_keys"
self.ff_ful = self.env.ref("account_ebics.ebics_ff_LCR")
def _wizard(self, file_format=None, **vals):
return self.env["ebics.xfer"].create(
{
"ebics_config_id": self.ebics_config.id,
"ebics_userid_id": self.userid.id,
"format_id": (file_format or self.ff_ful).id,
"upload_data": BinaryBytes(b"LCR DATA"),
"upload_fname": "lcr.txt",
"note": "",
**vals,
}
)
def _setup(self, wizard, init_error=None):
captured = {}
client_class = capturing_client(captured, init_error=init_error)
with patch.object(ebics_xfer_module, "EbicsClient", client_class):
client = wizard._setup_client()
return client, captured
def test_client_from_config_and_keys(self):
client, captured = self._setup(self._wizard())
self.assertTrue(client)
self.assertEqual(captured["version"], "H004")
self.assertEqual(captured["bank"].hostid, "TESTHOST")
self.assertEqual(captured["bank"].url, "https://ebics.example.invalid/ebics")
self.assertEqual(captured["user"].partnerid, "PARTNER1")
self.assertEqual(captured["user"].userid, self.userid.name)
def test_signature_class(self):
cases = [
# (userid default, file format override, expected transport_only)
("T", False, True),
("E", False, False),
("T", "E", False),
("E", "T", True),
]
for user_class, format_class, expected in cases:
with self.subTest(user=user_class, file_format=format_class):
self.userid.signature_class = user_class
self.ff_ful.signature_class = format_class
_client, captured = self._setup(self._wizard())
self.assertEqual(captured["user"].transport_only, expected)
def test_h003_order_number_is_given_to_the_bank(self):
self.ebics_config.write({"ebics_version": "H003", "order_number": "B00Z"})
wizard = self._wizard()
captured = {}
with patch.object(ebics_xfer_module, "EbicsClient", capturing_client(captured)):
ebics_file = wizard._ebics_upload()
self.assertEqual(ebics_file.ebics_order_number, "B00Z")
self.assertEqual(self.ebics_config.order_number, "B010")
def test_wrong_passphrase(self):
wizard = self._wizard(ebics_passphrase=WRONG_PHRASE)
with self.assertRaisesRegex(UserError, "Error while accessing the EBICS Keys"):
self._setup(wizard)
def test_missing_keys_directory(self):
self.ebics_config.ebics_keys = "/nonexistent/ebics_keys"
with self.assertRaisesRegex(UserError, "is not available"):
self._setup(self._wizard())
def test_client_creation_error(self):
wizard = self._wizard()
client, _captured = self._setup(wizard, init_error=RuntimeError("bad url"))
self.assertFalse(client)
self.assertIn("Unknown Error", wizard.note)
self.assertIn("bad url", wizard.note)
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ebics_config_view_list" model="ir.ui.view">
<field name="name">ebics.config.list</field>
<field name="model">ebics.config</field>
<field name="arch" type="xml">
<list decoration-muted="state == 'draft'">
<field name="name" />
<field name="ebics_host" />
<field name="state" />
<field name="active" />
</list>
</field>
</record>
<record id="ebics_config_view_form" model="ir.ui.view">
<field name="name">ebics.config.form</field>
<field name="model">ebics.config</field>
<field name="arch" type="xml">
<form string="EBICS Configuration">
<header>
<button
name="set_to_draft"
invisible="state != 'confirm'"
string="Set to Draft"
type="object"
groups="account_ebics.group_ebics_manager"
help="Set to Draft in order to change the EBICS configuration parameters."
/>
<button
name="set_to_confirm"
invisible="state != 'draft'"
string="Confirm"
type="object"
class="oe_highlight"
groups="account_ebics.group_ebics_manager"
help="The EBICS configuration must be confirmed before it can used for bank transactions."
/>
<field name="state" widget="statusbar" />
</header>
<widget
name="web_ribbon"
text="Archived"
bg_color="bg-danger"
invisible="active"
/>
<group name="main">
<group name="main-left">
<field name="name" readonly="state != 'draft'" colspan="2" />
<field name="ebics_host" readonly="state != 'draft'" />
<field name="ebics_url" readonly="state != 'draft'" />
<field name="ebics_partner" readonly="state != 'draft'" />
<field name="ebics_keys" readonly="state != 'draft'" />
</group>
<group name="main-right">
<field
name="journal_ids"
readonly="state != 'draft'"
widget="many2many_tags"
options="{'no_create': True}"
/>
<field name="ebics_version" readonly="state != 'draft'" />
<field name="ebics_key_version" readonly="state != 'draft'" />
<field name="ebics_key_bitlength" readonly="state != 'draft'" />
<field
name="order_number"
invisible="ebics_version != 'H003'"
readonly="state != 'draft'"
/>
</group>
</group>
<notebook>
<page
string="EBICS Users"
groups="account_ebics.group_ebics_manager"
>
<field name="ebics_userid_ids" readonly="state != 'draft'" />
</page>
<page
string="File Formats"
groups="account_ebics.group_ebics_manager"
>
<field
name="ebics_file_format_ids"
readonly="state != 'draft'"
/>
</page>
</notebook>
</form>
</field>
</record>
<record id="ebics_config_action" model="ir.actions.act_window">
<field name="name">EBICS Configuration</field>
<field name="res_model">ebics.config</field>
<field name="view_mode">list,form</field>
<field name="context">{'active_test': False}</field>
</record>
</odoo>
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ebics_file_format_view_search" model="ir.ui.view">
<field name="name">ebics.file.format.search</field>
<field name="model">ebics.file.format</field>
<field name="arch" type="xml">
<search string="EBICS File Format">
<filter
string="EBICS version 2"
name="ebics_v2"
domain="[('ebics_version', '=', '2')]"
/>
<filter
string="EBICS version 3"
name="ebics_v3"
domain="[('ebics_version', '=', '3')]"
/>
</search>
</field>
</record>
<record id="ebics_file_format_view_list" model="ir.ui.view">
<field name="name">ebics.file.format.list</field>
<field name="model">ebics.file.format</field>
<field name="arch" type="xml">
<list>
<field name="ebics_version" />
<field name="type" />
<field name="order_type" />
<field name="signature_class" />
<field name="name" />
<field name="description" />
</list>
</field>
</record>
<record id="ebics_file_format_view_form" model="ir.ui.view">
<field name="name">ebics.file.format.form</field>
<field name="model">ebics.file.format</field>
<field name="arch" type="xml">
<form string="EBICS File Format">
<group name="main">
<group name="main-left">
<field name="ebics_version" />
<field name="type" />
<field name="suffix" />
<field
name="download_process_method"
invisible="type == 'up'"
force_save="1"
/>
<field name="signature_class" />
</group>
<group name="main-right">
<field name="order_type" />
<field
name="name"
required="ebics_version == '2'"
invisible="ebics_version == '3'"
/>
<field
name="btf_service"
required="ebics_version == '3'"
invisible="ebics_version == '2'"
/>
<field
name="btf_message"
required="ebics_version == '3'"
invisible="ebics_version == '2'"
/>
<field name="btf_variant" invisible="ebics_version == '2'" />
<field name="btf_version" invisible="ebics_version == '2'" />
<field name="btf_scope" invisible="ebics_version == '2'" />
<field name="btf_option" invisible="ebics_version == '2'" />
<field name="btf_container" invisible="ebics_version == '2'" />
<field name="btf_format" invisible="ebics_version == '2'" />
</group>
</group>
<group name="description">
<field name="description" />
</group>
</form>
</field>
</record>
<record id="ebics_file_format_action" model="ir.actions.act_window">
<field name="name">EBICS File Formats</field>
<field name="res_model">ebics.file.format</field>
<field name="view_mode">list,form</field>
</record>
</odoo>
+222
View File
@@ -0,0 +1,222 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ebics_file_view_search" model="ir.ui.view">
<field name="name">ebics.file.search</field>
<field name="model">ebics.file</field>
<field name="arch" type="xml">
<search>
<field name="date_from" />
<field name="date_to" />
<field name="name" />
<field name="format_id" />
<field name="user_id" />
<field
name="company_ids"
widget="selection"
groups="base.group_multi_company"
/>
<filter
string="Draft"
name="draft"
domain="[('state', '=', 'draft')]"
/>
<filter string="Done" name="done" domain="[('state', '=', 'done')]" />
<group>
<filter
string="File Format"
name="file_format"
context="{'group_by':'format_id'}"
/>
<filter
string="State"
name="state"
context="{'group_by':'state'}"
/>
<filter
string="User"
name="user"
context="{'group_by':'user_id'}"
/>
</group>
</search>
</field>
</record>
<record id="ebics_file_view_list" model="ir.ui.view">
<field name="name">ebics.file.list</field>
<field name="model">ebics.file</field>
<field name="arch" type="xml">
<list decoration-muted="state=='draft'" create="false">
<field
name="date"
string="Download Date"
column_invisible="context.get('ebics_mode') != 'down'"
/>
<field
name="date"
string="Upload Date"
column_invisible="context.get('ebics_mode') == 'down'"
/>
<field name="name" />
<field
name="date_from"
column_invisible="context.get('ebics_mode') != 'down'"
/>
<field
name="date_to"
column_invisible="context.get('ebics_mode') != 'down'"
/>
<field name="user_id" />
<field name="state" />
<field name="format_id" />
<field
name="company_ids"
widget="many2many_tags"
groups="base.group_multi_company"
/>
</list>
</field>
</record>
<record id="ebics_file_view_form" model="ir.ui.view">
<field name="name">ebics.file.form</field>
<field name="model">ebics.file</field>
<field name="priority" eval="1" />
<field name="arch" type="xml">
<form create="false">
<header>
<button
name="set_to_draft"
string="Set to Draft"
type="object"
groups="account.group_account_manager"
invisible="(context.get('ebics_mode') == 'down' and (not download_process_method or state != 'done')) or (context.get('ebics_mode') == 'up' and state != 'done')"
/>
<button
name="process"
class="oe_highlight"
string="Process"
type="object"
groups="account.group_account_invoice"
help="Process the EBICS File"
invisible="(context.get('ebics_mode') == 'down' and (not download_process_method or state != 'draft')) or (context.get('ebics_mode') == 'up')"
/>
<button
name="set_to_done"
string="Set to Done"
type="object"
groups="account.group_account_manager"
invisible="(context.get('ebics_mode') == 'down' and (not download_process_method or state != 'draft')) or (context.get('ebics_mode') == 'up' and state != 'draft')"
/>
<field
name="state"
widget="statusbar"
invisible="context.get('ebics_mode') == 'down' and not download_process_method"
/>
</header>
<sheet>
<group name="main">
<group name="main-full-screen" colspan="2" col="2">
<field name="name" />
<field name="data" filename="name" />
<field name="format_id" />
</group>
<group name="main-left">
<field
name="date"
string="Download Date"
invisible="context.get('ebics_mode') != 'down'"
/>
<field
name="date"
string="Upload Date"
invisible="context.get('ebics_mode') == 'down'"
/>
<field
name="ebics_order_number"
invisible="context.get('ebics_mode') != 'up'"
/>
<field name="user_id" />
<field name="ebics_userid_id" />
</group>
<group name="main-right">
<field
name="date_from"
invisible="context.get('ebics_mode') != 'down'"
/>
<field
name="date_to"
invisible="context.get('ebics_mode') != 'down'"
/>
<field
name="company_ids"
widget="many2many_tags"
groups="base.group_multi_company"
/>
</group>
</group>
<notebook>
<page string="Additional Information">
<field name="note" nolabel="1" />
</page>
<page
string="Bank Statements"
invisible="not bank_statement_ids"
>
<field name="bank_statement_ids" nolabel="1" />
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="ebics_file_view_form_result" model="ir.ui.view">
<field name="name">ebics.file.process.result</field>
<field name="model">ebics.file</field>
<field name="priority" eval="100" />
<field name="arch" type="xml">
<form string="Process EBICS File">
<separator colspan="4" string="Results :" />
<field
name="note_process"
colspan="4"
nolabel="1"
width="850"
height="400"
/>
<footer>
<button
name="action_open_bank_statements"
string="View Bank Statement(s)"
type="object"
class="oe_highlight"
invisible="not context.get('statement_ids')"
/>
<button name="button_close" type="object" string="Close" />
</footer>
</form>
</field>
</record>
<record id="ebics_file_action_download" model="ir.actions.act_window">
<field name="name">EBICS Download Files</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ebics.file</field>
<field name="view_mode">list,form</field>
<field name="domain">[('type', '=', 'down')]</field>
<field name="context">{'ebics_mode': 'down'}</field>
</record>
<record id="ebics_file_action_upload" model="ir.actions.act_window">
<field name="name">EBICS Upload Files</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ebics.file</field>
<field name="view_mode">list,form</field>
<field name="domain">[('type', '=', 'up')]</field>
<field name="context">{'ebics_mode': 'up'}</field>
</record>
</odoo>
+182
View File
@@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ebics_userid_view_list" model="ir.ui.view">
<field name="name">ebics.userid.list</field>
<field name="model">ebics.userid</field>
<field name="arch" type="xml">
<list decoration-muted="state != 'active_keys'">
<field name="name" />
<field name="signature_class" />
<field name="state" />
<field name="active" />
</list>
</field>
</record>
<record id="ebics_userid_view_form" model="ir.ui.view">
<field name="name">ebics.userid.form</field>
<field name="model">ebics.userid</field>
<field name="arch" type="xml">
<form string="EBICS UserID">
<header>
<button
name="ebics_init_1"
invisible="state != 'draft'"
string="EBICS Initialisation"
type="object"
class="oe_highlight"
help="Initialise EBICS Bank Keys"
/>
<button
name="ebics_init_2"
invisible="state != 'init'"
string="Account activated"
type="object"
class="oe_highlight"
help="EBICS Initialisation - Push this button when the account has been activated by the bank."
/>
<button
name="ebics_init_3"
invisible="state != 'get_bank_keys'"
string="Get Bank Keys"
type="object"
class="oe_highlight"
help="EBICS Initialisation - After the account has been activated the public bank keys must be downloaded and checked for consistency."
/>
<button
name="ebics_init_4"
invisible="state != 'to_verify'"
string="Bank Keys Verified"
type="object"
class="oe_highlight"
help="EBICS Initialisation - Push this button when the public have been checked for consistency."
/>
<button
name="change_passphrase"
string="Change Passphrase"
type="object"
class="oe_highlight"
invisible="not ebics_keys_found or state != 'active_keys'"
/>
<button
name="set_to_draft"
invisible="state != 'active_keys'"
string="Set to Draft"
type="object"
help="Set to Draft in order to reinitialize your bank connection."
/>
<button
name="set_to_get_bank_keys"
invisible="state != 'active_keys'"
string="Renew Bank Keys"
type="object"
help="Use this button to update the EBICS certificates of your bank."
/>
<button
name="set_to_active_keys"
invisible="state != 'draft'"
string="Force Active Keys"
type="object"
help="Use this button to bypass the EBICS initialization (e.g. in case you have manually transferred active EBICS keys from another system."
/>
<field name="state" widget="statusbar" />
</header>
<group name="main" readonly="state != 'draft'">
<group name="main-left">
<field name="name" readonly="state != 'draft'" />
<field
name="ebics_passphrase"
password="True"
required="ebics_passphrase_required"
invisible="ebics_passphrase_invisible"
/>
<field
name="ebics_passphrase_store"
readonly="ebics_passphrase_store_readonly"
/>
<field
name="ebics_sig_passphrase"
password="True"
invisible="ebics_sig_passphrase_invisible"
/>
<field name="transaction_rights" />
<field name="active" />
</group>
<group name="main-right">
<field name="signature_class" readonly="state != 'draft'" />
<field
name="user_ids"
widget="many2many_tags"
options="{'no_create': True}"
/>
<!-- TODO: restore these fields after implementation of SWIFT SConnect
<field
name="swift_3skey"
invisible="signature_class == 'T'"
/>
<field name="swift_3skey_certificate_fn" invisible="1" />
<field
name="swift_3skey_certificate"
filename="swift_3skey_certificate_fn"
invisible="not swift_3skey"
required="swift_3skey"
/>
-->
<field name="ebics_key_x509" readonly="state != 'draft'" />
</group>
</group>
<group
name="dn"
invisible="not ebics_key_x509"
readonly="state != 'draft'"
>
<div colspan="2" col="1">
<strong
>Distinguished Name attributes used to create self-signed X.509 certificates:</strong>
</div>
<group name="dn_l">
<field
name="ebics_key_x509_dn_cn"
readonly="state != 'draft'"
/>
<field name="ebics_key_x509_dn_o" readonly="state != 'draft'" />
<field name="ebics_key_x509_dn_l" readonly="state != 'draft'" />
<field name="ebics_key_x509_dn_c" readonly="state != 'draft'" />
</group>
<group name="dn_r">
<field name="ebics_key_x509_dn_e" readonly="state != 'draft'" />
<field
name="ebics_key_x509_dn_ou"
readonly="state != 'draft'"
/>
<field
name="ebics_key_x509_dn_st"
readonly="state != 'draft'"
/>
</group>
</group>
<group name="files">
<group
colspan="2"
name="ebics_ini_letter"
invisible="not ebics_ini_letter"
>
<field name="ebics_ini_letter_fn" invisible="1" />
<field name="ebics_ini_letter" filename="ebics_ini_letter_fn" />
</group>
<group
colspan="2"
name="ebics_public_bank_keys"
invisible="not ebics_public_bank_keys"
>
<field name="ebics_public_bank_keys_fn" invisible="1" />
<field
name="ebics_public_bank_keys"
filename="ebics_public_bank_keys_fn"
/>
</group>
</group>
</form>
</field>
</record>
</odoo>
+92
View File
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<menuitem
id="ebics_processing_menu"
name="EBICS Processing"
parent="account.menu_finance"
sequence="4"
/>
<menuitem
id="ebics_file_menu"
name="EBICS Files"
parent="ebics_processing_menu"
sequence="10"
/>
<menuitem
id="ebics_file_menu_download"
name="Download"
parent="ebics_file_menu"
action="ebics_file_action_download"
sequence="10"
/>
<menuitem
id="ebics_file_menu_upload"
name="Upload"
parent="ebics_file_menu"
action="ebics_file_action_upload"
sequence="20"
/>
<menuitem
id="ebics_xfer_menu_download"
name="EBICS Download"
parent="ebics_processing_menu"
action="ebics_xfer_action_download"
sequence="20"
/>
<menuitem
id="ebics_xfer_menu_upload"
name="EBICS Upload"
parent="ebics_processing_menu"
action="ebics_xfer_action_upload"
sequence="30"
/>
<menuitem
id="ebics_menu"
name="EBICS"
parent='account.menu_finance_configuration'
groups="account_ebics.group_ebics_manager"
sequence="100"
/>
<menuitem
id="ebics_config_menu"
name="EBICS Configuration"
parent="ebics_menu"
action="ebics_config_action"
groups="account_ebics.group_ebics_manager"
sequence="10"
/>
<menuitem
id="ebics_file_format_menu"
name="EBICS File Formats"
parent="ebics_menu"
action="ebics_file_format_action"
groups="account_ebics.group_ebics_manager"
sequence="20"
/>
<menuitem
id="ebics_admin_order_menu"
name="EBICS Administrative Orders"
parent="ebics_menu"
action="ebics_admin_order_action"
groups="account_ebics.group_ebics_manager"
sequence="30"
/>
<menuitem
id="ebics_xfer_menu_mark_as_downloaded"
name="Mark files as Downloaded"
parent="ebics_menu"
action="account_ebics.ebics_xfer_action_mark_as_downloaded"
groups="account_ebics.group_ebics_manager"
sequence="40"
/>
</odoo>
+3
View File
@@ -0,0 +1,3 @@
from . import ebics_change_passphrase
from . import ebics_xfer
from . import ebics_admin_order
@@ -0,0 +1,77 @@
# Copyright 2024 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import logging
import pprint
from odoo import api, fields, models
_logger = logging.getLogger(__name__)
try:
from fintech.ebics import EbicsFunctionalError, EbicsTechnicalError
except ImportError:
_logger.warning("Failed to import fintech")
class EbicsAdminOrder(models.TransientModel):
_inherit = "ebics.xfer"
_name = "ebics.admin.order"
_description = "EBICS Administrative Order"
admin_order_type = fields.Selection(
selection=lambda self: self._selection_admin_order_type(),
string="Order",
)
@api.model
def _selection_admin_order_type(self):
return [
("HAA", "HAA - Business transaction formats BTF"),
("HPD", "HPD - Bank parameters"),
("HKD", "HKD - Subscriber information"),
("HTD", "HTD - Customer properties and settings"),
]
def ebics_admin_order(self):
self.ensure_one()
self.note = ""
client = self._setup_client()
if not client:
self.note += self.env._(
"EBICS client setup failed for connection '%s'",
self.ebics_config_id.name,
)
else:
try:
data = getattr(client, self.admin_order_type)(parsed=True)
pp = pprint.PrettyPrinter()
self.note = pp.pformat(data)
except EbicsFunctionalError as e:
self.note = "\n"
self.note += self.env._(
"EBICS Functional Error during execution of order %(order_type)s:",
order_type=self.admin_order_type,
)
self.note += "\n"
self.note += f"{e.message} (code: {e.code})"
except EbicsTechnicalError as e:
self.note = "\n"
self.note += self.env._(
"EBICS Technical Error during execution of order %(order_type)s:",
order_type=self.admin_order_type,
)
self.note += "\n"
self.note += f"{e.message} (code: {e.code})"
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref(f"{module}.ebics_admin_order_view_form_result")
return {
"name": self.env._("EBICS Administrative Order result"),
"res_id": self.id,
"view_mode": "form",
"res_model": "ebics.admin.order",
"view_id": result_view.id,
"target": "new",
"context": self.env.context,
"type": "ir.actions.act_window",
}
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ebics_admin_order_view_form" model="ir.ui.view">
<field name="name">EBICS Administrative Order</field>
<field name="model">ebics.admin.order</field>
<field name="inherit_id" ref="ebics_xfer_view_form_download" />
<field name="priority" eval="1" />
<field name="arch" type="xml">
<field name="date_from" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="date_to" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="format_id" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="order_type" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="order_type" position="after">
<field name="admin_order_type" />
</field>
<button name="ebics_download" position="attributes">
<attribute name="name">ebics_admin_order</attribute>
<attribute name="string">Execute</attribute>
</button>
</field>
</record>
<record id="ebics_admin_order_view_form_result" model="ir.ui.view">
<field name="name">EBICS Administrative Order result</field>
<field name="model">ebics.admin.order</field>
<field name="priority" eval="2" />
<field name="arch" type="xml">
<form string="EBICS Administrative Order result">
<separator colspan="4" string="Results :" />
<field name="note" colspan="4" nolabel="1" width="850" height="400" />
<footer>
<button
string="Close"
class="btn-secondary"
special="cancel"
data-hotkey="z"
/>
</footer>
</form>
</field>
</record>
<record id="ebics_admin_order_action" model="ir.actions.act_window">
<field name="name">EBICS Administrative Order</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ebics.admin.order</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="ebics_admin_order_view_form" />
</record>
</odoo>
@@ -0,0 +1,118 @@
# Copyright 2009-2024 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import logging
from odoo import fields, models
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
try:
import fintech
from fintech.ebics import EbicsKeyRing
fintech.cryptolib = "cryptography"
except ImportError:
_logger.warning("Failed to import fintech")
class EbicsChangePassphrase(models.TransientModel):
_name = "ebics.change.passphrase"
_description = "Change EBICS keys passphrase"
ebics_userid_id = fields.Many2one(
comodel_name="ebics.userid", string="EBICS UserID", readonly=True
)
old_pass = fields.Char(string="Old Passphrase")
new_pass = fields.Char(string="New Passphrase")
new_pass_check = fields.Char(string="New Passphrase (verification)")
old_sig_pass = fields.Char(string="Old Signature Passphrase")
new_sig_pass = fields.Char(string="New Signature Passphrase")
new_sig_pass_check = fields.Char(string="New Signature Passphrase (verification)")
ebics_sig_passphrase_invisible = fields.Boolean(
compute="_compute_ebics_sig_passphrase_invisible"
)
note = fields.Text(string="Notes", readonly=True)
def _compute_ebics_sig_passphrase_invisible(self):
for rec in self:
if fintech.__version_info__ < (7, 3, 1):
rec.ebics_sig_passphrase_invisible = True
else:
rec.ebics_sig_passphrase_invisible = False
def change_passphrase(self):
self.ensure_one()
self.note = ""
if (
self.ebics_userid_id.ebics_passphrase_store
and self.old_pass
and self.old_pass != self.ebics_userid_id.ebics_passphrase
):
raise UserError(self.env._("Incorrect old passphrase."))
if self.new_pass != self.new_pass_check:
raise UserError(self.env._("New passphrase verification error."))
if self.new_pass and self.new_pass == self.ebics_userid_id.ebics_passphrase:
raise UserError(self.env._("New passphrase equal to old passphrase."))
if (
self.new_sig_pass
and self.old_sig_pass
and self.new_sig_pass == self.old_sig_pass
):
raise UserError(
self.env._(
"New signature passphrase equal to old signature passphrase."
)
)
if self.new_sig_pass != self.new_sig_pass_check:
raise UserError(self.env._("New signature passphrase verification error."))
passphrase = (
self.ebics_userid_id.ebics_passphrase_store
and self.ebics_userid_id.ebics_passphrase
) or self.old_pass
try:
keyring_params = {
"keys": self.ebics_userid_id.ebics_keys_fn,
"passphrase": passphrase,
}
if self.new_sig_pass:
keyring_params["sig_passphrase"] = self.old_sig_pass or None
keyring = EbicsKeyRing(**keyring_params)
change_params = {}
if self.new_pass:
change_params["passphrase"] = self.new_pass
if self.new_sig_pass:
change_params["sig_passphrase"] = self.new_sig_pass
if change_params:
keyring.change_passphrase(**change_params)
except (ValueError, RuntimeError) as err:
raise UserError(str(err)) from err
if self.new_pass:
self.ebics_userid_id.ebics_passphrase = (
self.ebics_userid_id.ebics_passphrase_store and self.new_pass
)
self.note += "The EBICS Passphrase has been changed."
if self.new_sig_pass:
# removing ebics_sig_passphrase from db should not be required
# but we do it for double safety
if self.ebics_userid_id.ebics_sig_passphrase:
self.ebics_userid_id.ebics_sig_passphrase = False
self.note += "The EBICS Signature Passphrase has been changed."
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref(f"{module}.ebics_change_passphrase_view_form_result")
return {
"name": self.env._("EBICS Keys Change Passphrase"),
"res_id": self.id,
"view_mode": "form",
"res_model": "ebics.change.passphrase",
"view_id": result_view.id,
"target": "new",
"type": "ir.actions.act_window",
}
def button_close(self):
self.ensure_one()
return {"type": "ir.actions.act_window_close"}
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ebics_change_passphrase_view_form" model="ir.ui.view">
<field name="name">EBICS Keys Change Passphrase</field>
<field name="model">ebics.change.passphrase</field>
<field name="priority" eval="1" />
<field name="arch" type="xml">
<form string="EBICS Keys Change Passphrase">
<group>
<group name="pass">
<field name="old_pass" password="True" />
<field name="new_pass" password="True" />
<field name="new_pass_check" password="True" />
</group>
<group name="sig_pass" invisible="ebics_sig_passphrase_invisible">
<field name="old_sig_pass" password="True" />
<field name="new_sig_pass" password="True" />
<field name="new_sig_pass_check" password="True" />
</group>
</group>
<footer>
<button
name="change_passphrase"
string="Change Passphrase"
type="object"
class="btn-primary"
data-hotkey="q"
/>
<button
string="Cancel"
class="btn-secondary"
special="cancel"
data-hotkey="z"
/>
</footer>
</form>
</field>
</record>
<record id="ebics_change_passphrase_view_form_result" model="ir.ui.view">
<field name="name">EBICS Keys Change Passphrase</field>
<field name="model">ebics.change.passphrase</field>
<field name="priority" eval="2" />
<field name="arch" type="xml">
<form string="EBICS Keys Change Passphrase">
<separator colspan="4" string="Results :" />
<field name="note" colspan="4" nolabel="1" width="850" height="400" />
<footer>
<button
name="button_close"
type="object"
string="Close"
data-hotkey="z"
/>
</footer>
</form>
</field>
</record>
</odoo>
+686
View File
@@ -0,0 +1,686 @@
# Copyright 2009-2025 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import logging
import os
from sys import exc_info
from traceback import format_exception
from odoo import SUPERUSER_ID, api, fields, models
from odoo.exceptions import UserError
from odoo.tools.binary import BinaryBytes
_logger = logging.getLogger(__name__)
try:
import fintech
from fintech.ebics import (
BusinessTransactionFormat,
EbicsBank,
EbicsClient,
EbicsFunctionalError,
EbicsKeyRing,
EbicsTechnicalError,
EbicsUser,
EbicsVerificationError,
)
fintech.cryptolib = "cryptography"
except ImportError:
EbicsBank = object
_logger.warning("Failed to import fintech")
class EbicsBank(EbicsBank):
def _next_order_id(self, partnerid):
"""
EBICS protocol version H003 requires generation of the OrderID.
The OrderID must be a string between 'A000' and 'ZZZZ' and
unique for each partner id.
"""
return (hasattr(self, "_order_number") and self._order_number) or "A000"
class EbicsXfer(models.TransientModel):
_name = "ebics.xfer"
_description = "EBICS file transfer"
ebics_config_id = fields.Many2one(
comodel_name="ebics.config",
string="EBICS Configuration",
domain=[("state", "=", "confirm")],
default=lambda self: self._default_ebics_config_id(),
)
ebics_userid_id = fields.Many2one(
comodel_name="ebics.userid", string="EBICS UserID"
)
ebics_passphrase = fields.Char(string="EBICS Passphrase")
ebics_passphrase_stored = fields.Char(
string="EBICS Stored Passphrase", related="ebics_userid_id.ebics_passphrase"
)
ebics_passphrase_store = fields.Boolean(
related="ebics_userid_id.ebics_passphrase_store"
)
ebics_sig_passphrase = fields.Char(
string="EBICS Signature Passphrase",
)
ebics_sig_passphrase_invisible = fields.Boolean(
compute="_compute_ebics_sig_passphrase_invisible"
)
date_from = fields.Date()
date_to = fields.Date()
upload_data = fields.Binary(string="File to Upload")
upload_fname = fields.Char(string="Upload Filename", default="")
upload_fname_dummy = fields.Char(
related="upload_fname", string="Dummy Upload Filename", readonly=True
)
format_id = fields.Many2one(
comodel_name="ebics.file.format",
string="EBICS File Format",
help="Select EBICS File Format to upload/download."
"\nLeave blank to download all available files.",
)
upload_format_ids = fields.Many2many(
comodel_name="ebics.file.format", compute="_compute_upload_format_ids"
)
allowed_format_ids = fields.Many2many(
related="ebics_config_id.ebics_file_format_ids",
string="Allowed EBICS File Formats",
)
order_type = fields.Char(
related="format_id.order_type",
string="Order Type",
)
test_mode = fields.Boolean(
help="Select this option to test if the syntax of "
"the upload file is correct."
"\nThis option is only available for "
"Order Type 'FUL'.",
)
note = fields.Text(string="EBICS file transfer Log", readonly=True)
@api.model
def _default_ebics_config_id(self):
cfg_mod = self.env["ebics.config"]
cfg = cfg_mod.search(
[
("company_ids", "in", self.env.user.company_ids.ids),
("state", "=", "confirm"),
]
)
if cfg and len(cfg) == 1:
return cfg
return cfg_mod
def _compute_ebics_sig_passphrase_invisible(self):
for rec in self:
rec.ebics_sig_passphrase_invisible = True
if fintech.__version_info__ < (7, 3, 1):
rec.ebics_sig_passphrase_invisible = True
else:
rec.ebics_sig_passphrase_invisible = False
@api.depends("ebics_config_id")
def _compute_upload_format_ids(self):
for rec in self:
rec.upload_format_ids = False
if not self.env.context.get("ebics_download"):
rec.upload_format_ids = (
rec.ebics_config_id.ebics_file_format_ids.filtered(
lambda r: r.type == "up"
)
)
@api.onchange("ebics_config_id")
def _onchange_ebics_config_id(self):
if self.env.uid == SUPERUSER_ID:
avail_userids = self.ebics_config_id.ebics_userid_ids
else:
avail_userids = self.ebics_config_id.ebics_userid_ids.filtered(
lambda r: self.env.user.id in r.user_ids.ids
)
if self.env.context.get("ebics_download"): # Download Form
avail_formats = self.ebics_config_id.ebics_file_format_ids.filtered(
lambda r: r.type == "down"
)
if avail_formats and len(avail_formats) == 1:
self.format_id = avail_formats
else:
self.format_id = False
avail_userids = avail_userids.filtered(
lambda r: r.transaction_rights in ["both", "down"]
)
else: # Upload Form
if not self.env.context.get("active_model") == "account.payment.order":
avail_formats = self.ebics_config_id.ebics_file_format_ids.filtered(
lambda r: r.type == "up"
)
if avail_formats and len(avail_formats) == 1:
self.format_id = avail_formats
else:
self.format_id = False
avail_userids = avail_userids.filtered(
lambda r: r.transaction_rights in ["both", "up"]
)
if avail_userids:
if len(avail_userids) == 1:
self.ebics_userid_id = avail_userids
else:
with_passphrase_userids = avail_userids.filtered(
lambda r: r.ebics_passphrase_store
)
if len(with_passphrase_userids) == 1:
self.ebics_userid_id = with_passphrase_userids
else:
self.ebics_userid_id = False
@api.onchange("upload_data")
def _onchange_upload_data(self):
if self.env.context.get("active_model") == "account.payment.order":
return
self.upload_fname_dummy = self.upload_fname
self.format_id = False
self._detect_upload_format()
if not self.format_id:
upload_formats = (
self.format_id
or self.ebics_config_id.ebics_file_format_ids.filtered(
lambda r: r.type == "up"
)
)
if len(upload_formats) > 1:
upload_formats = upload_formats.filtered(
lambda r: self.upload_fname.endswith(r.suffix or "")
)
if len(upload_formats) == 1:
self.format_id = upload_formats
def ebics_upload(self):
self.ensure_one()
ctx = self.env.context.copy()
ebics_file = self._ebics_upload()
if ebics_file:
ctx["ebics_file_id"] = ebics_file.id
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref(f"{module}.ebics_xfer_view_form_result")
return {
"name": self.env._("EBICS file transfer result"),
"res_id": self.id,
"view_mode": "form",
"res_model": "ebics.xfer",
"view_id": result_view.id,
"target": "new",
"context": ctx,
"type": "ir.actions.act_window",
}
def ebics_download(self):
self.ensure_one()
ctx = self.env.context.copy()
self.note = ""
err_cnt = 0
client = self._setup_client()
if not client:
err_cnt += 1
self.note += self.env._(
"EBICS client setup failed for connection '%s'",
self.ebics_config_id.name,
)
else:
download_formats = (
self.format_id
or self.ebics_config_id.ebics_file_format_ids.filtered(
lambda r: r.type == "down"
)
)
ebics_files = self.env["ebics.file"]
date_from = (self.date_from and self.date_from.isoformat()) or None
date_to = (self.date_to and self.date_to.isoformat()) or None
for df in download_formats:
success = False
try:
if df.order_type == "BTD":
btf = BusinessTransactionFormat(
df.btf_service,
df.btf_message,
scope=df.btf_scope or None,
option=df.btf_option or None,
container=df.btf_container or None,
version=df.btf_version or None,
variant=df.btf_variant or None,
format=df.btf_format or None,
)
data = client.BTD(btf, start=date_from, end=date_to)
elif df.order_type == "FDL":
data = client.FDL(df.name, date_from, date_to)
else:
params = None
if date_from and date_to:
params = {
"DateRange": {
"Start": date_from,
"End": date_to,
}
}
data = client.download(df.order_type, params=params)
if not self.env.context.get("ebics_mark_as_downloaded"):
ebics_files += self._handle_download_data(data, df)
success = True
except EbicsFunctionalError:
err_cnt += 1
e = exc_info()
self.note += "\n"
self.note += self.env._(
"EBICS Functional Error during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
order_type=df.order_type,
)
self.note += "\n"
self.note += f"{e[1].message} (code: {e[1].code})"
except EbicsTechnicalError:
err_cnt += 1
e = exc_info()
self.note += "\n"
self.note += self.env._(
"EBICS Technical Error during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
order_type=df.order_type,
)
self.note += "\n"
self.note += f"{e[1].message} (code: {e[1].code})"
except EbicsVerificationError:
err_cnt += 1
self.note += "\n"
self.note += self.env._(
"EBICS Verification Error during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
order_type=df.order_type,
)
self.note += "\n"
self.note += self.env._("The EBICS response could not be verified.")
except UserError as e:
err_cnt += 1
self.note += "\n"
self.note += self.env._(
"Error detected during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
order_type=df.order_type,
)
self.note += "\n"
self.note += " ".join(e.args)
# Reported to the user in the note
except Exception: # noqa: BLE001
err_cnt += 1
self.note += "\n"
self.note += self.env._(
"Unknown Error during download of "
"File Format %(name)s (%(order_type)s):",
name=df.name or df.description,
order_type=df.order_type,
)
tb = "".join(format_exception(*exc_info()))
self.note += f"\n{tb}"
finally:
# mark received data so that it is not included in further
# downloads
trans_id = client.last_trans_id
client.confirm_download(trans_id=trans_id, success=success)
ctx["ebics_file_ids"] = ebics_files.ids
if ebics_files:
self.note += "\n"
for f in ebics_files:
self.note += self.env._(
"EBICS File '%s' is available for further processing.", f.name
)
self.note += "\n"
ctx["err_cnt"] = err_cnt
module = __name__.split("addons.")[1].split(".")[0]
result_view = self.env.ref(f"{module}.ebics_xfer_view_form_result")
return {
"name": self.env._("EBICS file transfer result"),
"res_id": self.id,
"view_mode": "form",
"res_model": "ebics.xfer",
"view_id": result_view.id,
"target": "new",
"context": ctx,
"type": "ir.actions.act_window",
}
def view_ebics_file(self):
self.ensure_one()
module = __name__.split("addons.")[1].split(".")[0]
act = self.env["ir.actions.act_window"]._for_xml_id(
f"{module}.ebics_file_action_download"
)
act["domain"] = [("id", "in", self.env.context["ebics_file_ids"])]
return act
def _ebics_upload(self):
self.ensure_one()
ebics_file = self.env["ebics.file"]
self.note = ""
client = self._setup_client()
if client:
upload_data = bytes(self.upload_data)
ef_format = self.format_id
OrderID = False
try:
order_type = self.order_type
if order_type == "BTU":
btf = BusinessTransactionFormat(
ef_format.btf_service,
ef_format.btf_message,
scope=ef_format.btf_scope or None,
option=ef_format.btf_option or None,
container=ef_format.btf_container or None,
version=ef_format.btf_version or None,
variant=ef_format.btf_variant or None,
format=ef_format.btf_format or None,
)
kwargs = {}
if self.test_mode:
kwargs["TEST"] = "TRUE"
OrderID = client.BTU(btf, upload_data, **kwargs)
elif order_type == "FUL":
kwargs = {}
bank = self.ebics_config_id.journal_ids[0].bank_account_id
cc = bank.country_id.code
if cc:
kwargs["country"] = cc
if self.test_mode:
kwargs["TEST"] = "TRUE"
OrderID = client.FUL(ef_format.name, upload_data, **kwargs)
else:
OrderID = client.upload(order_type, upload_data)
if OrderID:
self.note += "\n"
self.note += self.env._(
"EBICS File has been uploaded (OrderID %s).", OrderID
)
ef_note = ""
if self.env.context.get("origin"):
ef_note = self.env._("Origin: %s", self.env.context["origin"])
suffix = self.format_id.suffix
fn = self.upload_fname
if suffix and not fn.endswith(suffix):
fn = f"{fn}.{suffix}"
ef_vals = {
"name": self.upload_fname,
"data": self.upload_data,
"date": fields.Datetime.now(),
"format_id": self.format_id.id,
"state": "done",
"user_id": self.env.uid,
"ebics_userid_id": self.ebics_userid_id.id,
"note": ef_note,
"company_ids": [
self.env.context.get("force_company", self.env.company.id)
],
}
self._update_ef_vals(ef_vals)
ebics_file = self.env["ebics.file"].create(ef_vals)
ebics_file.write(
{"ebics_order_number": OrderID, "pain_state": "uploaded"}
)
except EbicsFunctionalError:
e = exc_info()
self.note += "\n"
self.note += self.env._("EBICS Functional Error:")
self.note += "\n"
self.note += f"{e[1].message} (code: {e[1].code})"
except EbicsTechnicalError:
e = exc_info()
self.note += "\n"
self.note += self.env._("EBICS Technical Error:")
self.note += "\n"
self.note += f"{e[1].message} (code: {e[1].code})"
except EbicsVerificationError:
self.note += "\n"
self.note += self.env._("EBICS Verification Error:")
self.note += "\n"
self.note += self.env._("The EBICS response could not be verified.")
# Reported to the user in the note, with the traceback
except Exception: # noqa: BLE001
self.note += "\n"
self.note += self.env._("Unknown Error")
tb = "".join(format_exception(*exc_info()))
self.note += f"\n{tb}"
if self.ebics_config_id.ebics_version == "H003":
OrderID = self.ebics_config_id._get_order_number()
self.ebics_config_id.sudo()._update_order_number(OrderID)
ebics_file and self._payment_upload_postprocess(ebics_file)
return ebics_file
def _payment_upload_postprocess(self, ebics_file):
ctx = self.env.context
active_model = ctx.get("model")
active_id = ctx.get("id")
payment_doc = None
if active_model == "account.payment.order":
payment_doc = self.env["account.payment.order"].browse(active_id)
payment_doc.generated2uploaded()
elif active_model == "account.batch.payment":
payment_doc = self.env["account.batch.payment"].browse(active_id)
if payment_doc:
payment_doc.ebics_file_id = ebics_file
self._payment_upload_chatter_message(payment_doc, ebics_file)
def _payment_upload_chatter_message(self, payment_doc, ebics_file):
payment_doc.message_post(
body=self.env._(
"'%(filename)s' has been uploaded via EBICS"
" (OrderID: %(order_number)s).",
filename=ebics_file.name,
order_number=ebics_file.ebics_order_number,
)
)
def _setup_client(self):
self.ebics_config_id._check_ebics_keys()
passphrase = self._get_passphrase()
keyring_params = {
"keys": self.ebics_userid_id.ebics_keys_fn,
"passphrase": passphrase,
}
if self.ebics_sig_passphrase:
keyring_params["sig_passphrase"] = self.ebics_sig_passphrase
try:
keyring = EbicsKeyRing(**keyring_params)
except (RuntimeError, ValueError) as err:
error = self.env._("Error while accessing the EBICS Keys:")
error += "\n"
error += err.args[0]
raise UserError(error) from err
bank = EbicsBank(
keyring=keyring,
hostid=self.ebics_config_id.ebics_host,
url=self.ebics_config_id.ebics_url,
)
if self.ebics_config_id.ebics_version == "H003":
bank._order_number = self.ebics_config_id._get_order_number()
signature_class = (
self.format_id.signature_class or self.ebics_userid_id.signature_class
)
user_params = {
"keyring": keyring,
"partnerid": self.ebics_config_id.ebics_partner,
"userid": self.ebics_userid_id.name,
}
# manual_approval replaced by transport_only class param in fintech 7.4
fintech74 = hasattr(EbicsUser, "transport_only")
if fintech74:
user_params["transport_only"] = (signature_class == "T" and True) or False
try:
user = EbicsUser(**user_params)
except ValueError as err:
error = self.env._("Error while accessing the EBICS UserID:")
error += "\n"
err_str = err.args[0]
error += err.args[0]
if err_str == "unknown key format":
error += "\n"
error += self.env._(
"Doublecheck your EBICS Passphrase and UserID settings."
)
raise UserError(error) from err
# manual_approval replaced by transport_only class param in fintech 7.4
if not fintech74 and signature_class == "T":
user.manual_approval = True
try:
client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version)
# Reported to the user in the note, with the traceback
except Exception: # noqa: BLE001
self.note += "\n"
self.note += self.env._("Unknown Error")
tb = "".join(format_exception(*exc_info()))
self.note += f"\n{tb}"
client = False
return client
def _get_passphrase(self):
return self.ebics_passphrase or self.ebics_passphrase_stored
def _file_format_methods(self):
"""
Extend this dictionary in order to add support
for extra file formats.
"""
res = {
"camt.xxx.cfonb120.stm": self._handle_cfonb120,
"camt.xxx.cfonb120.stm.rfi": self._handle_cfonb120,
"camt.052.001.02.stm": self._handle_camt052,
"camt.053.001.02.stm": self._handle_camt053,
}
return res
def _update_ef_vals(self, ef_vals):
"""
Adapt this method to customize the EBICS File values.
"""
if self.format_id and self.format_id.type == "up":
fn = ef_vals["name"]
dups = self._check_duplicate_ebics_file(fn, self.format_id)
if dups:
# pay.xml -> pay_1.xml, pay_2.xml, ...
base, ext = os.path.splitext(fn)
n = 1
fn = f"{base}_{n}{ext}"
while self._check_duplicate_ebics_file(fn, self.format_id):
n += 1
fn = f"{base}_{n}{ext}"
ef_vals["name"] = fn
def _handle_download_data(self, data, file_format):
ebics_files = self.env["ebics.file"]
if isinstance(data, dict):
for doc in data:
ebics_files += self._create_ebics_file(
data[doc], file_format, docname=doc
)
else:
ebics_files += self._create_ebics_file(data, file_format)
return ebics_files
def _create_ebics_file(self, data, file_format, docname=None):
fn_parts = [self.ebics_config_id.ebics_host, self.ebics_config_id.ebics_partner]
if docname:
fn_parts.append(docname)
else:
fn_date = self.date_to or fields.Date.today()
fn_parts.append(fn_date.isoformat())
fn = "_".join(fn_parts)
ff_methods = self._file_format_methods()
if file_format.name in ff_methods:
data = ff_methods[file_format.name](data)
suffix = file_format.suffix
if suffix and not fn.endswith(suffix):
fn = f"{fn}.{suffix}"
dups = self._check_duplicate_ebics_file(fn, file_format)
if dups:
raise UserError(
self.env._(
"EBICS File with name '%s' has already been downloaded."
"\nPlease check this file and rename in case there is "
"no risk on duplicate transactions.",
fn,
)
)
ef_vals = {
"name": fn,
"data": BinaryBytes(data),
"date": fields.Datetime.now(),
"date_from": self.date_from,
"date_to": self.date_to,
"format_id": file_format.id,
"state": (file_format.download_process_method and "draft") or "done",
"user_id": self.env.uid,
"ebics_userid_id": self.ebics_userid_id.id,
"company_ids": self.ebics_config_id.company_ids.ids,
}
self._update_ef_vals(ef_vals)
ebics_file = self.env["ebics.file"].create(ef_vals)
return ebics_file
def _check_duplicate_ebics_file(self, fn, file_format):
dups = self.env["ebics.file"].search(
[("name", "=", fn), ("format_id", "=", file_format.id)]
)
return dups
def _detect_upload_format(self):
"""
Use this method in order to automatically detect and set the
EBICS upload file format.
"""
def _insert_line_terminator(self, data_in, line_len):
data_in = data_in.replace(b"\n", b"").replace(b"\r", b"")
data_out = b""
max_len = len(data_in)
i = 0
while i + line_len <= max_len:
data_out += data_in[i : i + line_len] + b"\n"
i += line_len
return data_out
def _handle_cfonb120(self, data_in):
return self._insert_line_terminator(data_in, 120)
def _handle_cfonb240(self, data_in):
return self._insert_line_terminator(data_in, 240)
def _handle_camt052(self, data_in):
"""
Use this method if you need to fix camt files received
from your bank before passing them to the
Odoo Community CAMT parser.
Remark: Odoo Enterprise doesn't support camt.052.
"""
return data_in
def _handle_camt053(self, data_in):
"""
Use this method if you need to fix camt files received
from your bank before passing them to the
Odoo Enterprise or Community CAMT parser.
"""
return data_in
+236
View File
@@ -0,0 +1,236 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ebics_xfer_view_form_download" model="ir.ui.view">
<field name="name">EBICS File Download</field>
<field name="model">ebics.xfer</field>
<field name="priority" eval="1" />
<field name="arch" type="xml">
<form string="EBICS File Download">
<group>
<separator string="Select your bank :" colspan="2" />
<field
name="ebics_config_id"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field
name="ebics_userid_id"
domain="[('ebics_config_id', '=', ebics_config_id), ('user_ids.id', '=', uid), ('transaction_rights', 'in', ['both', 'down'])]"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field
name="ebics_passphrase"
password="True"
invisible="ebics_passphrase_store"
required="not ebics_passphrase_store"
/>
<field name="date_from" />
<field name="date_to" />
<field
name="format_id"
domain="[('type', '=', 'down'), ('id', 'in', allowed_format_ids)]"
/>
<field name="order_type" />
</group>
<footer>
<button
name="ebics_download"
string="Download Files"
type="object"
class="btn-primary"
data-hotkey="q"
/>
<button
string="Cancel"
class="btn-secondary"
special="cancel"
data-hotkey="z"
/>
</footer>
</form>
</field>
</record>
<record id="ebics_xfer_view_form_upload" model="ir.ui.view">
<field name="name">EBICS File Upload</field>
<field name="model">ebics.xfer</field>
<field name="priority" eval="1" />
<field name="arch" type="xml">
<form string="EBICS File Upload">
<group>
<separator string="Select your bank :" colspan="2" />
<field
name="ebics_config_id"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field
name="ebics_userid_id"
domain="[('ebics_config_id', '=', ebics_config_id), ('user_ids.id', '=', uid), ('transaction_rights', 'in', ['both', 'up'])]"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field
name="ebics_passphrase"
password="True"
invisible="ebics_passphrase_store"
required="not ebics_passphrase_store"
/>
<field
name="ebics_sig_passphrase"
password="True"
invisible="ebics_sig_passphrase_invisible"
/>
<separator string="Select your file :" colspan="2" />
<field name="upload_data" filename="upload_fname" required="1" />
<field name="upload_fname" invisible="1" />
<field name="upload_fname_dummy" string="Upload Filename" />
<field
name="format_id"
required="1"
domain="[('type', '=', 'up'), ('id', 'in', allowed_format_ids)]"
readonly="context.get('active_model') == 'account.payment.order'"
/>
<field name="order_type" />
<field
name="test_mode"
invisible="order_type not in ('FUL', 'BTU')"
/>
</group>
<footer>
<button
name="ebics_upload"
string="Upload File"
type="object"
class="btn-primary"
data-hotkey="q"
/>
<button
string="Cancel"
class="btn-secondary"
special="cancel"
data-hotkey="z"
/>
</footer>
</form>
</field>
</record>
<record id="ebics_xfer_view_form_result" model="ir.ui.view">
<field name="name">EBICS File Transfer</field>
<field name="model">ebics.xfer</field>
<field name="priority" eval="2" />
<field name="arch" type="xml">
<form string="EBICS File Transfer">
<separator colspan="4" string="Results :" />
<field name="note" colspan="4" nolabel="1" width="850" height="400" />
<footer>
<button
name="view_ebics_file"
type="object"
string="View EBICS File(s)"
class="btn-primary"
invisible="not context.get('ebics_file_ids')"
data-hotkey="q"
/>
<button
string="Close"
class="btn-secondary"
special="cancel"
data-hotkey="z"
/>
</footer>
</form>
</field>
</record>
<record id="ebics_xfer_action_download" model="ir.actions.act_window">
<field name="name">EBICS File Transfer - Download</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ebics.xfer</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'ebics_download': 1}</field>
<field name="view_id" ref="ebics_xfer_view_form_download" />
</record>
<record id="ebics_xfer_action_upload" model="ir.actions.act_window">
<field name="name">EBICS File Transfer - Upload</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ebics.xfer</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'ebics_upload': 1}</field>
<field name="view_id" ref="ebics_xfer_view_form_upload" />
</record>
<record id="ebics_xfer_view_form_mark_as_downloaded" model="ir.ui.view">
<field name="name">Mark EBICS files as Downloaded</field>
<field name="model">ebics.xfer</field>
<field name="priority" eval="100" />
<field name="arch" type="xml">
<form string="EBICS Mark as Downloaded">
<div class="alert alert-warning" role="alert">
The EBICS Files (Bank Statements) selected via this screen will not become available in Odoo as EBICS files but will be marked by your bank as downloaded.
<br />
As a consequence, these Bank Statements will not be retrieved by the next 'EBICS Batch Import' scheduled action.
</div>
<group>
<separator string="Select your bank :" colspan="2" />
<field
name="ebics_config_id"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field
name="ebics_userid_id"
domain="[('ebics_config_id', '=', ebics_config_id), ('user_ids.id', '=', uid), ('transaction_rights', 'in', ['both', 'down'])]"
required="1"
options="{'no_create': True, 'no_open': True}"
/>
<field
name="ebics_passphrase"
password="True"
invisible="ebics_passphrase_store"
required="not ebics_passphrase_store"
/>
<field name="date_from" required="1" />
<field name="date_to" required="1" />
<field
name="format_id"
required="1"
domain="[('type', '=', 'down'), ('id', 'in', allowed_format_ids)]"
/>
</group>
<footer>
<button
name="ebics_download"
string="Mark as Downloaded"
type="object"
class="btn-primary"
data-hotkey="q"
/>
<button
string="Cancel"
class="btn-secondary"
special="cancel"
data-hotkey="z"
/>
</footer>
</form>
</field>
</record>
<record id="ebics_xfer_action_mark_as_downloaded" model="ir.actions.act_window">
<field name="name">Mark files as Downloaded</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ebics.xfer</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field
name="context"
>{'ebics_download': 1, 'ebics_mark_as_downloaded': 1}</field>
<field name="view_id" ref="ebics_xfer_view_form_mark_as_downloaded" />
</record>
</odoo>
+32
View File
@@ -0,0 +1,32 @@
===================================
EBICS - Odoo Enterprise Integration
===================================
**Glue module. Install it and forget it.**
On Odoo Enterprise, this module places the **EBICS Processing** menu in the top bar of
the Accounting application.
It is installed automatically when both of these modules are installed:
- ``account_ebics``;
- ``accountant`` (the Odoo Enterprise Accounting application).
There is nothing to configure.
Part of the EBICS suite
=======================
This module extends **EBICS Banking Protocol** (``account_ebics``), the EBICS implementation
for Odoo developed and maintained by Noviat. Install it first:
https://github.com/Noviat/account_ebics
What EBICS is and what it changes, in plain language, with screen recordings of the flow:
https://www.noviat.com/ebics
Credits
=======
Developed and maintained by `Noviat <https://www.noviat.com>`_, Odoo integrator in Belgium,
specialised in accounting and finance since 2009. We configure the connection with your banks
and support you through the first cycles.
View File
Whitespace-only changes.
+19
View File
@@ -0,0 +1,19 @@
# Copyright 2019 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "EBICS - Odoo Enterprise Integration",
"summary": "Place the EBICS menus in the Odoo Enterprise accounting application",
"version": "20.0.1.0.0",
"author": "Noviat",
"website": "https://www.noviat.com/",
"category": "Hidden",
"license": "LGPL-3",
"depends": [
"account_ebics",
"accountant",
],
"data": ["views/account_ebics_menu.xml"],
"auto_install": True,
"images": ["static/description/banner.png"],
}
@@ -0,0 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_ebics_oe
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 20.0+e\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: account_ebics_oe
#: model:ir.module.module,description:base.module_account_ebics_oe
msgid ""
"===================================\n"
"EBICS - Odoo Enterprise Integration\n"
"===================================\n"
"\n"
"**Glue module. Install it and forget it.**\n"
"\n"
"On Odoo Enterprise, this module places the **EBICS Processing** menu in the top bar of\n"
"the Accounting application.\n"
"\n"
"It is installed automatically when both of these modules are installed:\n"
"\n"
"- ``account_ebics``;\n"
"- ``accountant`` (the Odoo Enterprise Accounting application).\n"
"\n"
"There is nothing to configure.\n"
"\n"
"Part of the EBICS suite\n"
"=======================\n"
"\n"
"This module extends **EBICS Banking Protocol** (``account_ebics``), the EBICS implementation\n"
"for Odoo developed and maintained by Noviat. Install it first:\n"
"https://github.com/Noviat/account_ebics\n"
"\n"
"What EBICS is and what it changes, in plain language, with screen recordings of the flow:\n"
"https://www.noviat.com/ebics\n"
"\n"
"Credits\n"
"=======\n"
"\n"
"Developed and maintained by `Noviat <https://www.noviat.com>`_, Odoo integrator in Belgium,\n"
"specialised in accounting and finance since 2009. We configure the connection with your banks\n"
"and support you through the first cycles.\n"
msgstr ""
#. module: account_ebics_oe
#: model:ir.module.module,shortdesc:base.module_account_ebics_oe
msgid "EBICS - Odoo Enterprise Integration"
msgstr ""
#. module: account_ebics_oe
#: model:ir.module.module,summary:base.module_account_ebics_oe
msgid "Place the EBICS menus in the Odoo Enterprise accounting application"
msgstr ""
+3
View File
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@@ -0,0 +1,27 @@
<!-- Generated from README.rst: edit the README, not this file. -->
<div class="section" id="ebics-odoo-enterprise-integration">
<h1>EBICS - Odoo Enterprise Integration</h1>
<p><strong>Glue module. Install it and forget it.</strong></p>
<p>On Odoo Enterprise, this module places the <strong>EBICS Processing</strong> menu in the top bar of
the Accounting application.</p>
<p>It is installed automatically when both of these modules are installed:</p>
<ul class="simple">
<li><tt class="docutils literal">account_ebics</tt>;</li>
<li><tt class="docutils literal">accountant</tt> (the Odoo Enterprise Accounting application).</li>
</ul>
<p>There is nothing to configure.</p>
<div class="section" id="part-of-the-ebics-suite">
<h2>Part of the EBICS suite</h2>
<p>This module extends <strong>EBICS Banking Protocol</strong> (<tt class="docutils literal">account_ebics</tt>), the EBICS implementation
for Odoo developed and maintained by Noviat. Install it first:
<a class="reference external" href="https://github.com/Noviat/account_ebics">https://github.com/Noviat/account_ebics</a></p>
<p>What EBICS is and what it changes, in plain language, with screen recordings of the flow:
<a class="reference external" href="https://www.noviat.com/ebics">https://www.noviat.com/ebics</a></p>
</div>
<div class="section" id="credits">
<h2>Credits</h2>
<p>Developed and maintained by <a class="reference external" href="https://www.noviat.com">Noviat</a>, Odoo integrator in Belgium,
specialised in accounting and finance since 2009. We configure the connection with your banks
and support you through the first cycles.</p>
</div>
</div>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="account_ebics.ebics_processing_menu" model="ir.ui.menu">
<field name="parent_id" eval="ref('accountant.menu_accounting')" />
</record>
</odoo>
+2
View File
@@ -1 +1,3 @@
# generated from manifests external_dependencies
cryptography
fintech