Merge pull request #127 from Noviat/19.0

Syncing from upstream Noviat/account_ebics (19.0)
This commit is contained in:
braintec authored and GitHub committed 2026-11-10 01:28:10 +01:00
commit a79eabf236
73 files changed
+2273 -294

No files matched your search

+3 -1
View File
@@ -1,7 +1,9 @@
# Do NOT update manually; changes here will be overwritten by Copier # Do NOT update manually; changes here will be overwritten by Copier
_commit: v8.0.2 _commit: v9.2.1
_src_path: git@github.com:Noviat-CI/addons-repo-template.git _src_path: git@github.com:Noviat-CI/addons-repo-template.git
ci_disable_autoinstall_modules: '' ci_disable_autoinstall_modules: ''
ci_postgis: false
community_excluded_modules: account_ebics_batch_payment,account_ebics_oe,account_ebics_oe_statement_import_test
odoo_test_flavor: Both odoo_test_flavor: Both
odoo_version: 19.0 odoo_version: 19.0
org_slug: Noviat org_slug: Noviat
+1 -1
View File
@@ -24,6 +24,6 @@ jobs:
- name: Add Noviat CI Tools to PATH - name: Add Noviat CI Tools to PATH
run: | run: |
git clone https://github.com/Noviat-CI/noviat-ci-tools.git /opt/noviat-ci-tools git clone https://github.com/Noviat-CI/noviat-ci-tools.git /opt/noviat-ci-tools
echo "/opt/noviat-ci-tools" >> $GITHUB_PATH echo "/opt/noviat-ci-tools" >> "$GITHUB_PATH"
- name: Check module version bump - name: Check module version bump
run: check_module_version_bump run: check_module_version_bump
+1 -1
View File
@@ -23,7 +23,7 @@ jobs:
cache: 'pip' cache: 'pip'
cache-dependency-path: '.pre-commit-config.yaml' cache-dependency-path: '.pre-commit-config.yaml'
- name: Get python version - name: Get python version
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV"
- uses: actions/cache@v6 - uses: actions/cache@v6
with: with:
path: ~/.cache/pre-commit path: ~/.cache/pre-commit
+32 -34
View File
@@ -20,11 +20,11 @@ jobs:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- run: | - run: |
for reqfile in requirements.txt test-requirements.txt ; do for reqfile in requirements.txt test-requirements.txt ; do
if [ -f ${reqfile} ] ; then if [ -f "${reqfile}" ] ; then
result=0 result=0
# reject non-comment lines that contain a / (i.e. URLs, relative paths) # reject non-comment lines that contain a / (i.e. URLs, relative paths)
# unless they have a "# SKIP TEST" comment # unless they have a "# SKIP TEST" comment
grep "^[^#].*/" ${reqfile} | grep -v "# SKIP TEST" || result=$? grep "^[^#].*/" "${reqfile}" | grep -v "# SKIP TEST" || result=$?
if [ $result -eq 0 ] ; then if [ $result -eq 0 ] ; then
echo "Unreleased dependencies found in ${reqfile}." echo "Unreleased dependencies found in ${reqfile}."
exit 1 exit 1
@@ -33,7 +33,11 @@ jobs:
done done
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ${{ matrix.container }} container:
image: ${{ matrix.container }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.PRIVATE_TOKEN }}
name: ${{ matrix.name }} name: ${{ matrix.name }}
permissions: permissions:
pull-requests: write pull-requests: write
@@ -42,12 +46,12 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- container: ghcr.io/oca/oca-ci/py3.10-odoo19.0:latest - container: ghcr.io/noviat-ci/odoo-ci:19.0-stable
name: test with Odoo Community name: test with Odoo Community
odoo_enterprise : 0 odoo_enterprise : 0
exclude_modules : "" exclude_modules : ""
exclude: "account_ebics_batch_payment,account_ebics_oe" skip: "account_ebics_batch_payment,account_ebics_oe,account_ebics_oe_statement_import_test"
- container: ghcr.io/oca/oca-ci/py3.10-odoo19.0:latest - container: ghcr.io/noviat-ci/odoo-ci:19.0-stable
name: test with Odoo Enterprise name: test with Odoo Enterprise
odoo_enterprise : 1 odoo_enterprise : 1
exclude_modules : "" exclude_modules : ""
@@ -73,49 +77,43 @@ jobs:
TOKEN: ${{ secrets.PRIVATE_TOKEN }} TOKEN: ${{ secrets.PRIVATE_TOKEN }}
run: | run: |
git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)"
- name: Set pip constraints (pyOpenSSL / cryptography) - name: Show the CI image age
run: | run: |
cat > /tmp/constraints.txt <<'EOF' age=$(( ( $(date -u +%s) - $(date -u -d "$NOVIAT_CI_IMAGE_BUILD_DATE" +%s) ) / 86400 ))
pyOpenSSL == 22.1.0 echo "Image $NOVIAT_CI_ODOO_VERSION built $NOVIAT_CI_IMAGE_BUILD_DATE ($age days old)" | tee -a "$GITHUB_STEP_SUMMARY"
cryptography == 38.0.4
EOF
echo "PIP_CONSTRAINT=/tmp/constraints.txt" >> $GITHUB_ENV
- name: Upgrade pip in container
run: python -m pip install --upgrade pip
- name: Install Odoo upgrade util
run: python -m pip install git+https://github.com/odoo/upgrade-util@master
- name: Add Noviat CI Tools to PATH
run: |
git clone https://github.com/Noviat-CI/noviat-ci-tools.git /opt/noviat-ci-tools
echo "/opt/noviat-ci-tools" >> $GITHUB_PATH
- name: Clone Odoo Enterprise
if: ${{ matrix.odoo_enterprise == 1 }}
run : |
git clone https://github.com/odoo/enterprise.git --depth 1 -b 19.0 /opt/enterprise
- name: Clone Noviat Dependencies - name: Clone Noviat Dependencies
run: clone_oca_dependencies_by_noviat run: clone_oca_dependencies_by_noviat
- name: Create addons path - name: Create addons path
run: | run: |
mkdir -p ${{ env.INSTALL_ADDONS_DIR }}/setup mkdir -p "$INSTALL_ADDONS_DIR/setup"
find $(realpath $ADDONS_DIR) $(realpath ${{ env.ADDITIONAL_ADDONS_DIR }}) -name __manifest__.py -exec sh -c 'ln -s "$(dirname "$0")" "${{ env.INSTALL_ADDONS_DIR }}"' {} \; find "$(realpath "$ADDONS_DIR")" "$(realpath "$ADDITIONAL_ADDONS_DIR")" -name __manifest__.py -exec sh -c 'ln -s "$(dirname "$0")" "$1"' {} "$INSTALL_ADDONS_DIR" \;
find $(realpath $ADDONS_DIR) $(realpath ${{ env.ADDITIONAL_ADDONS_DIR }}) -iwholename '*/setup/*/setup.py' -exec sh -c 'ln -s "$(dirname "$0")" "${{ env.INSTALL_ADDONS_DIR }}/setup"' {} \; find "$(realpath "$ADDONS_DIR")" "$(realpath "$ADDITIONAL_ADDONS_DIR")" -iwholename '*/setup/*/setup.py' -exec sh -c 'ln -s "$(dirname "$0")" "$1/setup"' {} "$INSTALL_ADDONS_DIR" \;
if [ -n ${{ matrix.exclude}} ] # EXCLUDE (from matrix.exclude) only exists with rebel module groups
if [ -n "${EXCLUDE:-}" ]
then then
remove_excluded_modules ${{ env.INSTALL_ADDONS_DIR }} ${{ matrix.exclude }} remove_excluded_modules "$INSTALL_ADDONS_DIR" "$EXCLUDE"
fi fi
- name: Skip addons
if: ${{ matrix.skip }}
env:
SKIPPED: ${{ matrix.skip }}
run: |
remove_excluded_modules "$INSTALL_ADDONS_DIR" "$SKIPPED"
echo "EXCLUDE=${EXCLUDE:+$EXCLUDE,}$SKIPPED" >> "$GITHUB_ENV"
echo "Not installed nor tested with Odoo Community: $SKIPPED" | tee -a "$GITHUB_STEP_SUMMARY"
- name: Update addons path with enterprise - name: Update addons path with enterprise
if: ${{ matrix.odoo_enterprise == 1 }} if: ${{ matrix.odoo_enterprise == 1 }}
run: | run: |
echo "ADDONS_PATH=/opt/odoo/addons,/opt/enterprise,${{ env.INSTALL_ADDONS_DIR }}" >> $GITHUB_ENV echo "ADDONS_PATH=/opt/odoo/addons,/opt/enterprise,${{ env.INSTALL_ADDONS_DIR }}" >> "$GITHUB_ENV"
- name: Update addons path without enterprise - name: Update addons path without enterprise
if: ${{ matrix.odoo_enterprise == 0 }} if: ${{ matrix.odoo_enterprise == 0 }}
run: | run: |
echo "ADDONS_PATH=/opt/odoo/addons,${{ env.INSTALL_ADDONS_DIR }}" >> $GITHUB_ENV echo "ADDONS_PATH=/opt/odoo/addons,${{ env.INSTALL_ADDONS_DIR }}" >> "$GITHUB_ENV"
- name: Add addons to EXCLUDE PATH - name: Add addons to EXCLUDE PATH
if: ${{ matrix.EXCLUDE_MODULES }} if: ${{ matrix.EXCLUDE_MODULES }}
run: | run: |
echo "server_wide_modules = web,module_change_auto_install" >> ${ODOO_RC} echo "server_wide_modules = web,module_change_auto_install" >> "${ODOO_RC}"
echo "ODOO_MODULES_AUTO_INSTALL_DISABLED=${{ matrix.EXCLUDE_MODULES }}" >> $GITHUB_ENV echo "ODOO_MODULES_AUTO_INSTALL_DISABLED=${{ matrix.EXCLUDE_MODULES }}" >> "$GITHUB_ENV"
- name: Install addons and dependencies - name: Install addons and dependencies
run: | run: |
(ADDONS_PATH=${ADDONS_PATH} ADDONS_DIR=${INSTALL_ADDONS_DIR} oca_install_addons) (ADDONS_PATH=${ADDONS_PATH} ADDONS_DIR=${INSTALL_ADDONS_DIR} oca_install_addons)
@@ -149,7 +147,7 @@ jobs:
hide_complexity: true hide_complexity: true
- name: Write to Job Summary - name: Write to Job Summary
if: steps.coverage.outputs.report == 'true' if: steps.coverage.outputs.report == 'true'
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY run: cat code-coverage-results.md >> "$GITHUB_STEP_SUMMARY"
- name: Update .pot files - name: Update .pot files
run: noviat_export_and_push_pot https://github.com/${{ github.repository }} run: noviat_export_and_push_pot https://github.com/${{ github.repository }}
if: ${{ matrix.makepot == 'true' && github.event_name == 'push' }} if: ${{ matrix.makepot == 'true' && github.event_name == 'push' }}
+4 -12
View File
@@ -6,12 +6,14 @@ exclude: |
^setup/|/static/description/index\.html$| ^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files # We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs| .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
# Maybe reactivate this when all README files include prettier ignore tags? # README.md holds the generated addons table
^README\.md$| ^README\.md$|
# Library files can have extraneous formatting (even minimized) # Library files can have extraneous formatting (even minimized)
/static/(src/)?lib/| /static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying # Repos using Sphinx to generate docs don't need prettying
^docs/_templates/.*\.html$| ^docs/_templates/.*\.html$|
# Sphinx translation catalogs are not Odoo translations
^docs/.*\.pot?$|
# Don't bother non-technical authors with formatting issues in docs # Don't bother non-technical authors with formatting issues in docs
readme/.*\.(rst|md)$| readme/.*\.(rst|md)$|
# Ignore build and dist directories in addons # Ignore build and dist directories in addons
@@ -121,10 +123,6 @@ repos:
- id: check-xml - id: check-xml
- id: mixed-line-ending - id: mixed-line-ending
args: ["--fix=lf"] args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.9 rev: v0.16.9
hooks: hooks:
@@ -137,13 +135,7 @@ repos:
rev: v10.0.11 rev: v10.0.11
hooks: hooks:
- id: pylint_odoo - id: pylint_odoo
name: pylint (optional, core only) name: pylint-odoo
args:
- --rcfile=.pylintrc
- --exit-zero
verbose: true
- id: pylint_odoo
name: pylint-odoo (mandatory, blocking)
args: args:
- --disable=missing-readme - --disable=missing-readme
- --rcfile=.pylintrc-mandatory - --rcfile=.pylintrc-mandatory
-118
View File
@@ -1,118 +0,0 @@
[MASTER]
ignore-patterns=["^.*/TODO/.*$"]
load-plugins=pylint_odoo
score=n
[IMPORTS]
deprecated-modules=pdb,pudb,ipdb,bs4
[ODOOLINT]
#readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest-required-authors=Noviat
manifest-required-keys=license
manifest-deprecated-keys=description,active
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid-odoo-versions=19.0
[MESSAGES CONTROL]
disable=all
# This .pylintrc contains optional AND mandatory checks and is meant to be
# loaded in an IDE to have it check everything, in the hope this will make
# optional checks more visible to contributors who otherwise never look at a
# green travis to see optional checks that failed.
# .pylintrc-mandatory containing only mandatory checks is used the pre-commit
# config as a blocking check.
enable =
anomalous-backslash-in-string,
assignment-from-none,
attribute-deprecated,
dangerous-default-value,
deprecated-module,
development-status-allowed,
duplicate-key,
eval-used,
license-allowed,
manifest-author-string,
manifest-deprecated-key,
# manifest-required-author,
manifest-required-key,
manifest-version-format,
method-compute,
method-inverse,
method-required-super,
method-search,
pointless-statement,
pointless-string-statement,
print-used,
redundant-keyword-arg,
reimported,
return-in-init,
sql-injection,
too-few-format-args,
translation-field,
translation-required,
unreachable,
use-vim-comment,
# >= 15
attribute-string-redundant,
consider-merging-classes-inherited,
context-overridden,
except-pass,
invalid-commit,
manifest-external-assets,
manifest-maintainers-list,
missing-readme,
missing-return,
odoo-addons-relative-import,
odoo-exception-warning,
renamed-field-parameter,
resource-not-exist,
test-folder-imported,
translation-contains-variable,
translation-positional-used,
website-manifest-key-not-valid-uri,
# >= 16
external-request-timeout,
# >= 19
bad-builtin-groupby,
category-allowed,
deprecated-name-get,
deprecated-odoo-model-method,
deprecated-self-cr,
inheritable-method-lambda,
inheritable-method-string,
invalid-email,
manifest-behind-migrations,
manifest-data-duplicated,
missing-odoo-file,
no-raise-unlink,
no-search-all,
no-wizard-in-models,
prohibited-method-override,
prefer-env-translation,
translation-format-interpolation,
translation-format-truncated,
translation-injection,
translation-fstring-interpolation,
translation-not-lazy,
translation-too-few-args,
translation-too-many-args,
translation-unsupported-format,
no-write-in-compute,
odoolint,
# >= 20
manifest-summary-multiline,
# messages that do not cause the lint step to fail
consider-merging-classes-inherited,
invalid-commit,
missing-readme,
odoo-addons-relative-import,
redefined-builtin
[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no
+1 -2
View File
@@ -11,12 +11,11 @@ deprecated-modules=pdb,pudb,ipdb,bs4
manifest-required-authors=Noviat manifest-required-authors=Noviat
manifest-required-keys=license manifest-required-keys=license
manifest-deprecated-keys=description,active manifest-deprecated-keys=description,active
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 license-allowed=AGPL-3,LGPL-3,Other proprietary
valid-odoo-versions=19.0 valid-odoo-versions=19.0
[MESSAGES CONTROL] [MESSAGES CONTROL]
disable=all disable=all
enable = enable =
anomalous-backslash-in-string, anomalous-backslash-in-string,
assignment-from-none, assignment-from-none,
+34
View File
@@ -16,6 +16,40 @@ select = [
"E501", # line too long (default 88) "E501", # line too long (default 88)
"I", # isort "I", # isort
"UP", # pyupgrade "UP", # pyupgrade
# Autofixed
"RET501",
"RET502",
"RET505",
"RET506",
"RET507",
"RET508",
"PLR1711",
"PLR5501",
"RUF019",
"RUF021",
"RUF100",
"SIM114",
"ISC001",
"C4",
"PIE",
"FLY",
"FURB",
# Few and real: logging format, performance, security
"G",
"PERF",
"S102",
"S105",
"S106",
"S107",
"S108",
"S301",
"S603",
"S607",
"S704",
# Commented-out code, blind except, unused unpacked variables
"ERA001",
"BLE001",
"RUF059",
] ]
extend-safe-fixes = ["UP008"] extend-safe-fixes = ["UP008"]
exclude = ["setup/*"] exclude = ["setup/*"]
+6 -4
View File
@@ -15,11 +15,13 @@ Available addons
---------------- ----------------
addon | version | maintainers | summary addon | version | maintainers | summary
--- | --- | --- | --- --- | --- | --- | ---
[account_ebics](account_ebics/) | 19.0.1.3.2 | | Download bank statements and upload payment files directly from Odoo, using the European EBICS standard [account_ebics](account_ebics/) | 19.0.1.3.3 | | Download bank statements and upload payment files directly from Odoo, using the European EBICS standard
[account_ebics_batch](account_ebics_batch/) | 19.0.1.0.1 | | Download and process your EBICS files automatically, on a schedule [account_ebics_batch](account_ebics_batch/) | 19.0.1.0.2 | | Download and process your EBICS files automatically, on a schedule
[account_ebics_batch_payment](account_ebics_batch_payment/) | 19.0.1.3.0 | | Send an Odoo Enterprise batch payment to the bank over EBICS [account_ebics_batch_payment](account_ebics_batch_payment/) | 19.0.1.3.1 | | Send an Odoo Enterprise batch payment to the bank over EBICS
[account_ebics_oe](account_ebics_oe/) | 19.0.1.0.0 | | Place the EBICS menus in the Odoo Enterprise accounting application [account_ebics_oe](account_ebics_oe/) | 19.0.1.0.0 | | Place the EBICS menus in the Odoo Enterprise accounting application
[account_ebics_payment_order](account_ebics_payment_order/) | 19.0.1.1.0 | | Send an OCA payment order to the bank over EBICS [account_ebics_oe_statement_import_test](account_ebics_oe_statement_import_test/) | 19.0.1.0.0 | | Test-only module, do not install: runs the EBICS statement import tests against the Odoo Enterprise CAMT parser
[account_ebics_payment_order](account_ebics_payment_order/) | 19.0.1.1.1 | | Send an OCA payment order to the bank over EBICS
[account_ebics_statement_import_test](account_ebics_statement_import_test/) | 19.0.1.0.0 | | Test-only module, do not install: runs the EBICS statement import tests against the OCA CAMT and CFONB parsers
[//]: # (end addons) [//]: # (end addons)
+1 -1
View File
@@ -8,7 +8,7 @@ _logger = logging.getLogger(__name__)
try: try:
from . import models from . import models
from . import wizards from . import wizards
except Exception: except Exception: # noqa: BLE001 - the module must load without fintech
_logger.warning("Import Error, check if fintech lib has been installed") _logger.warning("Import Error, check if fintech lib has been installed")
+1 -1
View File
@@ -5,7 +5,7 @@
"name": "EBICS Banking Protocol", "name": "EBICS Banking Protocol",
"summary": "Download bank statements and upload payment " "summary": "Download bank statements and upload payment "
"files directly from Odoo, using the European EBICS standard", "files directly from Odoo, using the European EBICS standard",
"version": "19.0.1.3.2", "version": "19.0.1.3.3",
"license": "LGPL-3", "license": "LGPL-3",
"author": "Noviat", "author": "Noviat",
"website": "https://www.noviat.com/", "website": "https://www.noviat.com/",
+6
View File
@@ -542,6 +542,12 @@ msgid ""
"(%(order_type)s):" "(%(order_type)s):"
msgstr "" msgstr ""
#. module: account_ebics
#. odoo-python
#: code:addons/account_ebics/wizards/ebics_admin_order.py:0
msgid "EBICS Functional Error during execution of order %(order_type)s:"
msgstr ""
#. module: account_ebics #. module: account_ebics
#. odoo-python #. odoo-python
#: code:addons/account_ebics/models/ebics_userid.py:0 #: code:addons/account_ebics/models/ebics_userid.py:0
+6
View File
@@ -585,6 +585,12 @@ msgstr ""
"Funktionaler EBICS-Fehler beim Herunterladen des Dateiformats %(name)s " "Funktionaler EBICS-Fehler beim Herunterladen des Dateiformats %(name)s "
"(%(order_type)s):" "(%(order_type)s):"
#. module: account_ebics
#. odoo-python
#: code:addons/account_ebics/wizards/ebics_admin_order.py:0
msgid "EBICS Functional Error during execution of order %(order_type)s:"
msgstr ""
#. module: account_ebics #. module: account_ebics
#. odoo-python #. odoo-python
#: code:addons/account_ebics/models/ebics_userid.py:0 #: code:addons/account_ebics/models/ebics_userid.py:0
+6
View File
@@ -585,6 +585,12 @@ msgstr ""
"Erreur fonctionnelle EBICS lors du téléchargement du format de fichier " "Erreur fonctionnelle EBICS lors du téléchargement du format de fichier "
"%(name)s (%(order_type)s) :" "%(name)s (%(order_type)s) :"
#. module: account_ebics
#. odoo-python
#: code:addons/account_ebics/wizards/ebics_admin_order.py:0
msgid "EBICS Functional Error during execution of order %(order_type)s:"
msgstr ""
#. module: account_ebics #. module: account_ebics
#. odoo-python #. odoo-python
#: code:addons/account_ebics/models/ebics_userid.py:0 #: code:addons/account_ebics/models/ebics_userid.py:0
+6
View File
@@ -583,6 +583,12 @@ msgstr ""
"EBICS functionele fout tijdens het downloaden van bestandsformaat %(name)s " "EBICS functionele fout tijdens het downloaden van bestandsformaat %(name)s "
"(%(order_type)s):" "(%(order_type)s):"
#. module: account_ebics
#. odoo-python
#: code:addons/account_ebics/wizards/ebics_admin_order.py:0
msgid "EBICS Functional Error during execution of order %(order_type)s:"
msgstr ""
#. module: account_ebics #. module: account_ebics
#. odoo-python #. odoo-python
#: code:addons/account_ebics/models/ebics_userid.py:0 #: code:addons/account_ebics/models/ebics_userid.py:0
+4 -5
View File
@@ -127,7 +127,7 @@ class EbicsConfig(models.Model):
@api.model @api.model
def _default_ebics_keys(self): def _default_ebics_keys(self):
return "/".join(["/etc/odoo/ebics_keys", self.env.cr.dbname]) return f"/etc/odoo/ebics_keys/{self.env.cr.dbname}"
@api.constrains("ebics_key_bitlength") @api.constrains("ebics_key_bitlength")
def _check_ebics_key_bitlength(self): def _check_ebics_key_bitlength(self):
@@ -185,11 +185,10 @@ class EbicsConfig(models.Model):
if c == "Z": if c == "Z":
o_list[-i] = "0" o_list[-i] = "0"
continue continue
else: o_list[-i] = chr(ord(c) + 1)
o_list[-i] = chr(ord(c) + 1) break
break
next_order_number = "".join(o_list) next_order_number = "".join(o_list)
if next_order_number == "ZZZZ": if "ZZZZ" in (OrderID, next_order_number):
next_order_number = "A000" next_order_number = "A000"
self.order_number = next_order_number self.order_number = next_order_number
+25 -19
View File
@@ -11,6 +11,7 @@ from lxml import etree
from odoo import api, fields, models from odoo import api, fields, models
from odoo.exceptions import UserError from odoo.exceptions import UserError
from odoo.modules import module as odoo_module
from odoo.addons.base.models.res_bank import sanitize_account_number from odoo.addons.base.models.res_bank import sanitize_account_number
@@ -222,9 +223,8 @@ class EbicsFile(models.Model):
journal_currency = jrnl.currency_id or jrnl.company_id.currency_id journal_currency = jrnl.currency_id or jrnl.company_id.currency_id
if journal_currency != currency: if journal_currency != currency:
continue continue
else: journal = jrnl
journal = jrnl break
break
if not journal: if not journal:
message = self.env._( message = self.env._(
@@ -298,7 +298,7 @@ class EbicsFile(models.Model):
self.note_process += self.env._( self.note_process += self.env._(
"%(st_cnt)s bank statement%(sp)s been imported: ", "%(st_cnt)s bank statement%(sp)s been imported: ",
st_cnt=st_cnt, st_cnt=st_cnt,
sp=st_cnt == 1 and self.env._(" has") or self.env._("s have"), sp=(st_cnt == 1 and self.env._(" has")) or self.env._("s have"),
) )
self.note_process += "\n" self.note_process += "\n"
for statement in statements: for statement in statements:
@@ -389,9 +389,7 @@ class EbicsFile(models.Model):
res["notifications"].append({"type": "error", "message": message}) res["notifications"].append({"type": "error", "message": message})
return datas return datas
lines = [] lines = [file_data[i : i + 120] for i in range(0, len(file_data), 120)]
for i in range(0, len(file_data), 120):
lines.append(file_data[i : i + 120])
st_lines = b"" st_lines = b""
transactions = False transactions = False
@@ -485,11 +483,12 @@ class EbicsFile(models.Model):
try: try:
with self.env.cr.savepoint(): with self.env.cr.savepoint():
self._create_bank_statement_oca(res, st_data) self._create_bank_statement_oca(res, st_data)
except UserError as e: except UserError as e: # noqa: PERF203
res["notifications"].append( res["notifications"].append(
{"type": "error", "message": "".join(e.args)} {"type": "error", "message": "".join(e.args)}
) )
except Exception: # Each statement fails alone; the traceback is reported to the user
except Exception: # noqa: BLE001
tb = "".join(format_exception(*exc_info())) tb = "".join(format_exception(*exc_info()))
res["notifications"].append({"type": "error", "message": tb}) res["notifications"].append({"type": "error", "message": tb})
@@ -506,12 +505,16 @@ class EbicsFile(models.Model):
""" """
We execute a cr.commit() after every statement import since we get a 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()'. '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: for st_data in st_datas:
try: try:
self._create_bank_statement_oe(res, st_data) self._create_bank_statement_oe(res, st_data)
self.env.cr.commit() # pylint: disable=E8102 if not testing:
except UserError as e: self.env.cr.commit() # pylint: disable=E8102
except UserError as e: # noqa: PERF203
msg = "".join(e.args) msg = "".join(e.args)
msg += "\n" msg += "\n"
msg += self.env._( msg += self.env._(
@@ -519,7 +522,8 @@ class EbicsFile(models.Model):
nr=st_data["acc_number"], nr=st_data["acc_number"],
) )
res["notifications"].append({"type": "error", "message": msg}) res["notifications"].append({"type": "error", "message": msg})
except Exception: # Each statement fails alone; the traceback is reported to the user
except Exception: # noqa: BLE001
tb = "".join(format_exception(*exc_info())) tb = "".join(format_exception(*exc_info()))
res["notifications"].append({"type": "error", "message": tb}) res["notifications"].append({"type": "error", "message": tb})
@@ -566,10 +570,14 @@ class EbicsFile(models.Model):
""" """
datas = [] datas = []
file_data = base64.b64decode(self.data) file_data = base64.b64decode(self.data)
root = etree.fromstring(file_data, parser=etree.XMLParser(recover=True)) try:
root = etree.fromstring(file_data, parser=etree.XMLParser(recover=True))
except etree.XMLSyntaxError:
root = None
if root is None: if root is None:
message = self.env._("Invalid XML file.") message = self.env._("Invalid XML file.")
res["notifications"].append({"type": "error", "message": message}) res["notifications"].append({"type": "error", "message": message})
return datas
ns = {k or "ns": v for k, v in root.nsmap.items()} ns = {k or "ns": v for k, v in root.nsmap.items()}
camt_variant = ns["ns"].split("camt.")[1][:3] camt_variant = ns["ns"].split("camt.")[1][:3]
variant_tags = { variant_tags = {
@@ -580,12 +588,11 @@ class EbicsFile(models.Model):
camt_tag = variant_tags[camt_variant] camt_tag = variant_tags[camt_variant]
stmts = root[0].findall(f"ns:{camt_tag}", ns) stmts = root[0].findall(f"ns:{camt_tag}", ns)
for i, stmt in enumerate(stmts): for i, stmt in enumerate(stmts):
acc_number = sanitize_account_number( acc_ids = stmt.xpath(
stmt.xpath( "ns:Acct/ns:Id/ns:IBAN/text() | ns:Acct/ns:Id/ns:Othr/ns:Id/text()",
"ns:Acct/ns:Id/ns:IBAN/text() | ns:Acct/ns:Id/ns:Othr/ns:Id/text()", namespaces=ns,
namespaces=ns,
)[0]
) )
acc_number = acc_ids and sanitize_account_number(acc_ids[0])
if not acc_number: if not acc_number:
message = self.env._("No bank account number found.") message = self.env._("No bank account number found.")
res["notifications"].append({"type": "error", "message": message}) res["notifications"].append({"type": "error", "message": message})
@@ -641,7 +648,6 @@ class EbicsFile(models.Model):
Placeholder for pain.002 specific actions before removing the Placeholder for pain.002 specific actions before removing the
EBICS data file. EBICS data file.
""" """
raise NotImplementedError
def _process_undefined_format(self): def _process_undefined_format(self):
raise UserError( raise UserError(
+1 -1
View File
@@ -113,7 +113,7 @@ class EbicsFileFormat(models.Model):
@api.depends("ebics_version", "name", "btf_message", "description") @api.depends("ebics_version", "name", "btf_message", "description")
def _compute_display_name(self): def _compute_display_name(self):
for rec in self: for rec in self:
name = rec.ebics_version == "2" and rec.name or rec.btf_message name = (rec.ebics_version == "2" and rec.name) or rec.btf_message
if rec.description: if rec.description:
name += " - " + rec.description name += " - " + rec.description
rec.display_name = name rec.display_name = name
+15 -16
View File
@@ -38,7 +38,7 @@ class EbicsBank(EbicsBank):
The OrderID must be a string between 'A000' and 'ZZZZ' and The OrderID must be a string between 'A000' and 'ZZZZ' and
unique for each partner id. unique for each partner id.
""" """
return hasattr(self, "_order_number") and self._order_number or "A000" return (hasattr(self, "_order_number") and self._order_number) or "A000"
class EbicsUserID(models.Model): class EbicsUserID(models.Model):
@@ -216,7 +216,9 @@ class EbicsUserID(models.Model):
rec.ebics_passphrase_store_readonly = True rec.ebics_passphrase_store_readonly = True
if rec.state == "draft": if rec.state == "draft":
rec.ebics_passphrase_required = True rec.ebics_passphrase_required = True
rec.ebics_passphrase_invisible = rec.ebics_keys_found and True or False rec.ebics_passphrase_invisible = (
rec.ebics_keys_found and True
) or False
rec.ebics_passphrase_store_readonly = False rec.ebics_passphrase_store_readonly = False
elif rec.state == "init": elif rec.state == "init":
rec.ebics_passphrase_required = False rec.ebics_passphrase_required = False
@@ -279,19 +281,20 @@ class EbicsUserID(models.Model):
"keys": self.ebics_keys_fn, "keys": self.ebics_keys_fn,
"passphrase": self.ebics_passphrase, "passphrase": self.ebics_passphrase,
} }
keyring = EbicsKeyRing(**keyring_params)
try: try:
keyring = EbicsKeyRing(**keyring_params)
# fintech <= 7.4.3 does not have a call to check if a # fintech <= 7.4.3 does not have a call to check if a
# passphrase matches with the value stored in the keyfile. # passphrase matches with the value stored in the keyfile.
# We get around this limitation as follows: # We get around this limitation as follows:
# Get user keys to check for valid passphrases # Get user keys to check for valid passphrases
# It will raise a ValueError on invalid passphrases # It will raise a ValueError on invalid passphrases,
keyring["#USER"] # or a RuntimeError when the keyring is already open
except ValueError as err: # noqa: F841 # 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 raise UserError(self.env._("Passphrase mismatch.")) # noqa: B904
else: elif self.state != "draft":
if self.state != "draft": self.ebics_passphrase = False
self.ebics_passphrase = False
@api.onchange("swift_3skey") @api.onchange("swift_3skey")
def _onchange_swift_3skey(self): def _onchange_swift_3skey(self):
@@ -412,7 +415,7 @@ class EbicsUserID(models.Model):
raise UserError(error) from err raise UserError(error) from err
# Send the public electronic signature key to the bank. # Send the public electronic signature key to the bank.
ebics_config_bank = self.ebics_config_id.journal_ids[0].bank_id ebics_config_bank = self.ebics_config_id.journal_ids[:1].bank_id
if not ebics_config_bank: if not ebics_config_bank:
raise UserError( raise UserError(
self.env._( self.env._(
@@ -470,7 +473,6 @@ class EbicsUserID(models.Model):
self.ebics_config_id._update_order_number(OrderID) self.ebics_config_id._update_order_number(OrderID)
# Create an INI-letter which must be printed and sent to the bank. # Create an INI-letter which must be printed and sent to the bank.
ebics_config_bank = self.ebics_config_id.journal_ids[0].bank_id
cc = ebics_config_bank.country.code cc = ebics_config_bank.country.code
if cc in ["FR", "DE"]: if cc in ["FR", "DE"]:
lang = cc lang = cc
@@ -479,7 +481,7 @@ class EbicsUserID(models.Model):
lang = lang.lower() lang = lang.lower()
lang = lang if lang in INI_LETTER_LANGS else "en" lang = lang if lang in INI_LETTER_LANGS else "en"
fn_date = fields.Date.today().isoformat() fn_date = fields.Date.today().isoformat()
fn = "_".join([self.ebics_config_id.ebics_host, "ini_letter", fn_date]) + ".pdf" fn = f"{self.ebics_config_id.ebics_host}_ini_letter_{fn_date}" + ".pdf"
letter = user.create_ini_letter(bankname=ebics_config_bank.name, lang=lang) letter = user.create_ini_letter(bankname=ebics_config_bank.name, lang=lang)
vals = { vals = {
"ebics_ini_letter": base64.encodebytes(letter), "ebics_ini_letter": base64.encodebytes(letter),
@@ -548,10 +550,7 @@ class EbicsUserID(models.Model):
public_bank_keys = public_bank_keys.encode() public_bank_keys = public_bank_keys.encode()
fn_date = fields.Date.today().isoformat() fn_date = fields.Date.today().isoformat()
fn = ( fn = f"{self.ebics_config_id.ebics_host}_public_bank_keys_{fn_date}" + ".txt"
"_".join([self.ebics_config_id.ebics_host, "public_bank_keys", fn_date])
+ ".txt"
)
vals = { vals = {
"ebics_public_bank_keys": base64.encodebytes(public_bank_keys), "ebics_public_bank_keys": base64.encodebytes(public_bank_keys),
"ebics_public_bank_keys_fn": fn, "ebics_public_bank_keys_fn": fn,
@@ -24,8 +24,7 @@ try:
fintech_register_users = ( fintech_register_users = (
fintech_register_users fintech_register_users
and [x.strip() for x in fintech_register_users.split(",")] and [x.strip() for x in fintech_register_users.split(",")]
or None ) or None
)
fintech.cryptolib = "cryptography" fintech.cryptolib = "cryptography"
fintech.register( fintech.register(
name=fintech_register_name, name=fintech_register_name,
@@ -38,7 +37,7 @@ except RuntimeError as e:
else: else:
_logger.error(str(e)) _logger.error(str(e))
fintech.register() fintech.register()
except Exception: except Exception: # noqa: BLE001 - logged with the traceback, then retried
msg = "fintech.register error" msg = "fintech.register error"
tb = "".join(format_exception(*exc_info())) tb = "".join(format_exception(*exc_info()))
msg += f"\n{tb}" msg += f"\n{tb}"
+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).
import base64
from contextlib import contextmanager
from unittest.mock import patch
from odoo import Command, fields
from odoo.tools import file_open
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_acc_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": base64.b64encode(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": base64.b64encode(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,232 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import base64
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 base64.b64decode(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(base64.b64decode(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)
+284
View File
@@ -0,0 +1,284 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import base64
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.bank_fr = cls.env["res.bank"].create(
{"name": "Banque Test", "country": cls.env.ref("base.fr").id}
)
cls.journal = cls._create_bank_journal("TKEY", "FR7630004000031234567890143")
cls.journal.bank_account_id.sudo().bank_id = cls.bank_fr
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(base64.b64decode(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(
base64.b64decode(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 = 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
+251
View File
@@ -0,0 +1,251 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import base64
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 = base64.b64decode(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(base64.b64decode(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")
bank = cls.env["res.bank"].create(
{"name": "Test Bank FR", "country": cls.env.ref("base.fr").id}
)
journal = cls._create_bank_journal("TUPL", "FR7630004000031234567890143")
journal.bank_account_id.sudo().bank_id = bank
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).
import base64
from unittest.mock import patch
from odoo.exceptions import UserError
from odoo.tests import tagged
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": base64.b64encode(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)
+10 -1
View File
@@ -9,7 +9,7 @@ from odoo import api, fields, models
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
try: try:
from fintech.ebics import EbicsTechnicalError from fintech.ebics import EbicsFunctionalError, EbicsTechnicalError
except ImportError: except ImportError:
_logger.warning("Failed to import fintech") _logger.warning("Failed to import fintech")
@@ -35,6 +35,7 @@ class EbicsAdminOrder(models.TransientModel):
def ebics_admin_order(self): def ebics_admin_order(self):
self.ensure_one() self.ensure_one()
self.note = ""
client = self._setup_client() client = self._setup_client()
if not client: if not client:
self.note += self.env._( self.note += self.env._(
@@ -46,6 +47,14 @@ class EbicsAdminOrder(models.TransientModel):
data = getattr(client, self.admin_order_type)(parsed=True) data = getattr(client, self.admin_order_type)(parsed=True)
pp = pprint.PrettyPrinter() pp = pprint.PrettyPrinter()
self.note = pp.pformat(data) 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: except EbicsTechnicalError as e:
self.note = "\n" self.note = "\n"
self.note += self.env._( self.note += self.env._(
@@ -70,8 +70,7 @@ class EbicsChangePassphrase(models.TransientModel):
passphrase = ( passphrase = (
self.ebics_userid_id.ebics_passphrase_store self.ebics_userid_id.ebics_passphrase_store
and self.ebics_userid_id.ebics_passphrase and self.ebics_userid_id.ebics_passphrase
or self.old_pass ) or self.old_pass
)
try: try:
keyring_params = { keyring_params = {
"keys": self.ebics_userid_id.ebics_keys_fn, "keys": self.ebics_userid_id.ebics_keys_fn,
+19 -30
View File
@@ -3,6 +3,7 @@
import base64 import base64
import logging import logging
import os
from sys import exc_info from sys import exc_info
from traceback import format_exception from traceback import format_exception
@@ -37,7 +38,7 @@ class EbicsBank(EbicsBank):
The OrderID must be a string between 'A000' and 'ZZZZ' and The OrderID must be a string between 'A000' and 'ZZZZ' and
unique for each partner id. unique for each partner id.
""" """
return hasattr(self, "_order_number") and self._order_number or "A000" return (hasattr(self, "_order_number") and self._order_number) or "A000"
class EbicsXfer(models.TransientModel): class EbicsXfer(models.TransientModel):
@@ -109,8 +110,7 @@ class EbicsXfer(models.TransientModel):
) )
if cfg and len(cfg) == 1: if cfg and len(cfg) == 1:
return cfg return cfg
else: return cfg_mod
return cfg_mod
def _compute_ebics_sig_passphrase_invisible(self): def _compute_ebics_sig_passphrase_invisible(self):
for rec in self: for rec in self:
@@ -236,8 +236,8 @@ class EbicsXfer(models.TransientModel):
) )
) )
ebics_files = self.env["ebics.file"] ebics_files = self.env["ebics.file"]
date_from = self.date_from and self.date_from.isoformat() or None date_from = (self.date_from and self.date_from.isoformat()) or None
date_to = self.date_to and self.date_to.isoformat() or None date_to = (self.date_to and self.date_to.isoformat()) or None
for df in download_formats: for df in download_formats:
success = False success = False
try: try:
@@ -314,7 +314,8 @@ class EbicsXfer(models.TransientModel):
) )
self.note += "\n" self.note += "\n"
self.note += " ".join(e.args) self.note += " ".join(e.args)
except Exception: # Reported to the user in the note
except Exception: # noqa: BLE001
err_cnt += 1 err_cnt += 1
self.note += "\n" self.note += "\n"
self.note += self.env._( self.note += self.env._(
@@ -412,7 +413,7 @@ class EbicsXfer(models.TransientModel):
suffix = self.format_id.suffix suffix = self.format_id.suffix
fn = self.upload_fname fn = self.upload_fname
if suffix and not fn.endswith(suffix): if suffix and not fn.endswith(suffix):
fn = ".".join([fn, suffix]) fn = f"{fn}.{suffix}"
ef_vals = { ef_vals = {
"name": self.upload_fname, "name": self.upload_fname,
"data": self.upload_data, "data": self.upload_data,
@@ -449,7 +450,8 @@ class EbicsXfer(models.TransientModel):
self.note += self.env._("EBICS Verification Error:") self.note += self.env._("EBICS Verification Error:")
self.note += "\n" self.note += "\n"
self.note += self.env._("The EBICS response could not be verified.") self.note += self.env._("The EBICS response could not be verified.")
except Exception: # Reported to the user in the note, with the traceback
except Exception: # noqa: BLE001
self.note += "\n" self.note += "\n"
self.note += self.env._("Unknown Error") self.note += self.env._("Unknown Error")
tb = "".join(format_exception(*exc_info())) tb = "".join(format_exception(*exc_info()))
@@ -523,7 +525,7 @@ class EbicsXfer(models.TransientModel):
# manual_approval replaced by transport_only class param in fintech 7.4 # manual_approval replaced by transport_only class param in fintech 7.4
fintech74 = hasattr(EbicsUser, "transport_only") fintech74 = hasattr(EbicsUser, "transport_only")
if fintech74: if fintech74:
user_params["transport_only"] = signature_class == "T" and True or False user_params["transport_only"] = (signature_class == "T" and True) or False
try: try:
user = EbicsUser(**user_params) user = EbicsUser(**user_params)
except ValueError as err: except ValueError as err:
@@ -543,7 +545,8 @@ class EbicsXfer(models.TransientModel):
try: try:
client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version) client = EbicsClient(bank, user, version=self.ebics_config_id.ebics_version)
except Exception: # Reported to the user in the note, with the traceback
except Exception: # noqa: BLE001
self.note += "\n" self.note += "\n"
self.note += self.env._("Unknown Error") self.note += self.env._("Unknown Error")
tb = "".join(format_exception(*exc_info())) tb = "".join(format_exception(*exc_info()))
@@ -576,11 +579,13 @@ class EbicsXfer(models.TransientModel):
fn = ef_vals["name"] fn = ef_vals["name"]
dups = self._check_duplicate_ebics_file(fn, self.format_id) dups = self._check_duplicate_ebics_file(fn, self.format_id)
if dups: if dups:
# pay.xml -> pay_1.xml, pay_2.xml, ...
base, ext = os.path.splitext(fn)
n = 1 n = 1
fn = "_".join([fn, str(n)]) fn = f"{base}_{n}{ext}"
while self._check_duplicate_ebics_file(fn, self.format_id): while self._check_duplicate_ebics_file(fn, self.format_id):
n += 1 n += 1
fn = "_".join([fn, str(n)]) fn = f"{base}_{n}{ext}"
ef_vals["name"] = fn ef_vals["name"] = fn
def _handle_download_data(self, data, file_format): def _handle_download_data(self, data, file_format):
@@ -608,7 +613,7 @@ class EbicsXfer(models.TransientModel):
suffix = file_format.suffix suffix = file_format.suffix
if suffix and not fn.endswith(suffix): if suffix and not fn.endswith(suffix):
fn = ".".join([fn, suffix]) fn = f"{fn}.{suffix}"
dups = self._check_duplicate_ebics_file(fn, file_format) dups = self._check_duplicate_ebics_file(fn, file_format)
if dups: if dups:
raise UserError( raise UserError(
@@ -627,7 +632,7 @@ class EbicsXfer(models.TransientModel):
"date_from": self.date_from, "date_from": self.date_from,
"date_to": self.date_to, "date_to": self.date_to,
"format_id": file_format.id, "format_id": file_format.id,
"state": file_format.download_process_method and "draft" or "done", "state": (file_format.download_process_method and "draft") or "done",
"user_id": self.env.uid, "user_id": self.env.uid,
"ebics_userid_id": self.ebics_userid_id.id, "ebics_userid_id": self.ebics_userid_id.id,
"company_ids": self.ebics_config_id.company_ids.ids, "company_ids": self.ebics_config_id.company_ids.ids,
@@ -648,22 +653,6 @@ class EbicsXfer(models.TransientModel):
EBICS upload file format. EBICS upload file format.
""" """
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":
continue
else:
o_list[-i] = chr(ord(c) + 1)
break
next_nr = "".join(o_list)
if next_nr == "ZZZZ":
next_nr = "A000"
self.ebics_config_id.order_number = next_nr
def _insert_line_terminator(self, data_in, line_len): def _insert_line_terminator(self, data_in, line_len):
data_in = data_in.replace(b"\n", b"").replace(b"\r", b"") data_in = data_in.replace(b"\n", b"").replace(b"\r", b"")
data_out = b"" data_out = b""
+1 -1
View File
@@ -3,7 +3,7 @@
{ {
"name": "EBICS - Scheduled File Import", "name": "EBICS - Scheduled File Import",
"version": "19.0.1.0.1", "version": "19.0.1.0.2",
"license": "LGPL-3", "license": "LGPL-3",
"author": "Noviat", "author": "Noviat",
"website": "https://www.noviat.com/", "website": "https://www.noviat.com/",
@@ -120,7 +120,8 @@ class EbicsBatchLog(models.Model):
) )
except UserError as e: except UserError as e:
import_dict["errors"].append(err_msg + " ".join(e.args)) import_dict["errors"].append(err_msg + " ".join(e.args))
except Exception: # Each configuration fails alone; reported in the batch log
except Exception: # noqa: BLE001
tb = "".join(format_exception(*exc_info())) tb = "".join(format_exception(*exc_info()))
import_dict["errors"].append(err_msg + tb) import_dict["errors"].append(err_msg + tb)
log.file_ids = [(6, 0, ebics_file_ids)] log.file_ids = [(6, 0, ebics_file_ids)]
@@ -128,14 +129,15 @@ class EbicsBatchLog(models.Model):
log._ebics_process(import_dict) log._ebics_process(import_dict)
except UserError as e: except UserError as e:
import_dict["errors"].append(err_msg + " ".join(e.args)) import_dict["errors"].append(err_msg + " ".join(e.args))
except Exception: # Reported in the batch log with the traceback
except Exception: # noqa: BLE001
tb = "".join(format_exception(*exc_info())) tb = "".join(format_exception(*exc_info()))
import_dict["errors"].append(err_msg + tb) import_dict["errors"].append(err_msg + tb)
log._finalise_processing(import_dict) log._finalise_processing(import_dict)
def _finalise_processing(self, import_dict): def _finalise_processing(self, import_dict):
log_item_model = self.env["ebics.batch.log.item"] log_item_model = self.env["ebics.batch.log.item"]
state = self.has_draft_files and "draft" or "done" state = (self.has_draft_files and "draft") or "done"
note = "" note = ""
error_count = 0 error_count = 0
if import_dict["errors"]: if import_dict["errors"]:
@@ -157,7 +159,7 @@ class EbicsBatchLog(models.Model):
lambda r: r.ebics_passphrase_store lambda r: r.ebics_passphrase_store
) )
t_userids = ebics_userids.filtered(lambda r: r.signature_class == "T") t_userids = ebics_userids.filtered(lambda r: r.signature_class == "T")
ebics_userid = t_userids and t_userids[0] or ebics_userids[0] ebics_userid = (t_userids and t_userids[0]) or ebics_userids[0]
xfer_wiz = ( xfer_wiz = (
self.env["ebics.xfer"] self.env["ebics.xfer"]
.with_context(ebics_download=True) .with_context(ebics_download=True)
+1
View File
@@ -0,0 +1 @@
from . import test_ebics_batch_import
@@ -0,0 +1,95 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from unittest.mock import patch
from fintech.ebics import EbicsTechnicalError
from odoo.exceptions import UserError
from odoo.tests import tagged
from odoo.addons.account_ebics.tests.common import (
EbicsTestCommon,
FakeEbicsClient,
read_sample,
)
@tagged("post_install", "-at_install")
class TestEbicsBatchImport(EbicsTestCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
# A format without processing method: files are stored as done.
cls.ff_ptk = cls.env["ebics.file.format"].create(
{"name": "PTK", "type": "down", "order_type": "PTK", "suffix": "txt"}
)
cls.ebics_config.ebics_file_format_ids = cls.ff_ptk
cls.log_model = cls.env["ebics.batch.log"]
def _run(self, client, **kwargs):
with self._fake_client(client):
self.log_model._batch_import(
ebics_config_ids=self.ebics_config.ids, **kwargs
)
return self.log_model.search([], order="id desc", limit=1)
def test_import(self):
client = FakeEbicsClient(downloads={"PTK": read_sample("ptk_protocol.txt")})
log = self._run(client, date_from="2026-10-12", date_to="2026-10-13")
self.assertEqual(log.state, "done")
self.assertEqual(log.ebics_config_ids, self.ebics_config)
self.assertEqual(log.file_count, 1)
self.assertEqual(log.file_ids.name, "TESTHOST_PARTNER1_2026-10-13.txt")
self.assertEqual(log.log_ids.state, "done")
self.assertEqual(log.log_ids.error_count, 0)
def test_import_prefers_transport_signature_user(self):
"""Downloads need no signature right: a class T user is preferred."""
self.ebics_userid.signature_class = "E"
transport_userid = self.ebics_userid.copy(
{"name": "USER2", "signature_class": "T", "state": "active_keys"}
)
client = FakeEbicsClient(downloads={"PTK": read_sample("ptk_protocol.txt")})
log = self._run(client, date_to="2026-10-13")
self.assertEqual(log.file_ids.ebics_userid_id, transport_userid)
def test_import_transfer_error(self):
error = EbicsTechnicalError("061001", "EBICS_AUTHENTICATION_FAILED")
log = self._run(FakeEbicsClient(error=error))
self.assertEqual(log.state, "error")
self.assertFalse(log.file_ids)
self.assertEqual(log.log_ids.error_count, 1)
self.assertIn("EBICS_AUTHENTICATION_FAILED", log.log_ids.note)
def test_import_draft_config(self):
self.ebics_config.set_to_draft()
log = self._run(FakeEbicsClient())
self.assertEqual(log.state, "error")
self.assertIn("Please set state to 'Confirm'", log.log_ids.note)
def test_import_without_stored_passphrase(self):
self.ebics_userid.ebics_passphrase_store = False
log = self._run(FakeEbicsClient())
self.assertEqual(log.state, "error")
self.assertIn("No EBICS UserID with stored passphrase", log.log_ids.note)
def test_draft_files_are_processed_and_reprocessed(self):
ebics_file = self._create_ebics_file("camt053_sparkasse.xml", self.ff_camt053)
log = self.log_model.create({"file_ids": [(6, 0, ebics_file.ids)]})
self.assertTrue(log.has_draft_files)
file_class = type(ebics_file)
with patch.object(file_class, "process", autospec=True) as process:
log.reprocess()
process.assert_called_once_with(ebics_file)
# the file is still draft since processing was mocked
self.assertEqual(log.state, "draft")
def test_unlink_only_draft_logs(self):
log = self.log_model.create({})
log.button_done()
with self.assertRaises(UserError):
log.unlink()
log.button_draft()
log.unlink()
self.assertFalse(log.exists())
+1 -1
View File
@@ -4,7 +4,7 @@
{ {
"name": "EBICS - Batch Payments (Odoo Enterprise)", "name": "EBICS - Batch Payments (Odoo Enterprise)",
"summary": "Send an Odoo Enterprise batch payment to the bank over EBICS", "summary": "Send an Odoo Enterprise batch payment to the bank over EBICS",
"version": "19.0.1.3.0", "version": "19.0.1.3.1",
"license": "LGPL-3", "license": "LGPL-3",
"author": "Noviat", "author": "Noviat",
"website": "https://www.noviat.com/", "website": "https://www.noviat.com/",
@@ -0,0 +1 @@
from . import test_batch_payment_upload
@@ -0,0 +1,77 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import base64
from unittest.mock import patch
from odoo.exceptions import UserError
from odoo.tests import tagged
from odoo.addons.account_ebics.tests.common import EbicsTestCommon, FakeEbicsClient
@tagged("post_install", "-at_install")
class TestBatchPaymentUpload(EbicsTestCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.journal = cls._create_bank_journal("TBP", "FR7630004000031234567890143")
cls.ff_cct = cls.env.ref("account_ebics.ebics_ff_CCT")
cls.method = cls.env.ref("account.account_payment_method_manual_out")
def _batch(self, state="sent"):
batch = self.env["account.batch.payment"].create(
{
"journal_id": self.journal.id,
"batch_type": "outbound",
"payment_method_id": self.method.id,
"export_file": base64.b64encode(b"<Document>pain.001</Document>"),
"export_filename": "batch.xml",
}
)
# Without payments the batch stays in draft: set the state directly.
batch.state = state
return batch
def _generating_files(self):
batch_class = type(self.env["account.batch.payment"])
return patch.object(
batch_class, "_get_methods_generating_files", return_value=["manual"]
)
def test_hide_ebics_upload(self):
with self._generating_files():
self.assertFalse(self._batch().hide_ebics_upload)
self.assertTrue(self._batch(state="draft").hide_ebics_upload)
batch = self._batch()
batch.ebics_file_id = self.env["ebics.file"].create(
{"name": "batch.xml", "date": "2026-10-13", "pain_state": "uploaded"}
)
self.assertTrue(batch.hide_ebics_upload)
# no file generation for this payment method
self.assertTrue(self._batch().hide_ebics_upload)
def test_upload_requires_ebics_config(self):
self.ebics_config.journal_ids = False
with self.assertRaises(UserError):
self._batch().ebics_upload()
def test_upload_format_from_payment_method(self):
self.method.ebics_file_format_id = self.ff_cct
action = self._batch().ebics_upload()
wizard = self.env["ebics.xfer"].browse(action["res_id"])
self.assertEqual(wizard.format_id, self.ff_cct)
self.assertEqual(wizard.upload_fname, "batch.xml")
def test_upload(self):
self.method.ebics_file_format_id = self.ff_cct
batch = self._batch()
action = batch.ebics_upload()
wizard = self.env["ebics.xfer"].browse(action["res_id"])
with self._fake_client(FakeEbicsClient(order_id="N088")) as client:
wizard.with_context(**action["context"]).ebics_upload()
self.assertEqual(client.uploads[0][1], b"<Document>pain.001</Document>")
self.assertEqual(batch.ebics_order_number, "N088")
self.assertEqual(batch.ebics_pain_state, "uploaded")
self.assertIn(f"Batch Payment: {batch.name}", batch.ebics_file_id.note)
self.assertTrue(any("N088" in msg.body for msg in batch.message_ids))
@@ -0,0 +1,15 @@
=========================================
EBICS - Enterprise Statement Import Tests
=========================================
**Test-only module. Do not install it on a production database.**
It carries no code and no data. It exists so that continuous integration
installs the Odoo Enterprise CAMT parser (``account_bank_statement_import_camt``)
next to ``account_ebics`` and runs the statement import tests through the
Enterprise import. It is excluded from the Community test job.
Credits
=======
Developed and maintained by `Noviat <https://www.noviat.com>`_.
Whitespace-only changes.
@@ -0,0 +1,17 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "EBICS - Enterprise Statement Import Tests",
"summary": "Test-only module, do not install: runs the EBICS statement "
"import tests against the Odoo Enterprise CAMT parser",
"version": "19.0.1.0.0",
"license": "LGPL-3",
"author": "Noviat",
"website": "https://www.noviat.com/",
"category": "Hidden",
"depends": [
"account_ebics",
"account_bank_statement_import_camt",
],
}
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@@ -0,0 +1 @@
from . import test_oe_statement_import
@@ -0,0 +1,66 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from unittest.mock import patch
from odoo.tests import tagged
from odoo.addons.account_ebics.tests.common import (
IBAN_HVB,
IBAN_MULTI,
EbicsTestCommon,
)
@tagged("post_install", "-at_install")
class TestOeStatementImport(EbicsTestCommon):
"""End to end through the Odoo Enterprise camt import: EBICS file ->
split per account -> ir.attachment -> journal._import_bank_statement."""
def _enterprise_parser_only(self):
"""Both camt parsers are installed in the Enterprise CI job and
_process_camt053 prefers the OCA one: hide it."""
file_class = type(self.env["ebics.file"])
check_import_module = file_class._check_import_module
def check(record, module, raise_if_not_found=True):
if module == "account_statement_import_camt":
return False
return check_import_module(record, module, raise_if_not_found)
return patch.object(file_class, "_check_import_module", check)
def _process(self, sample, name=None):
ebics_file = self._create_ebics_file(sample, self.ff_camt053, name=name)
with self._enterprise_parser_only():
ebics_file.process()
self.assertEqual(ebics_file.state, "done")
return ebics_file
def test_camt_statement(self):
journal = self._create_bank_journal("THVB", IBAN_HVB)
ebics_file = self._process("camt053_hvb_clav_fx.xml")
statement = ebics_file.bank_statement_ids
self.assertEqual(statement.journal_id, journal)
self.assertEqual(statement.balance_start, 5000.0)
self.assertEqual(statement.balance_end_real, 3992.5)
self.assertEqual(sorted(statement.line_ids.mapped("amount")), [-857.5, -150.0])
self.assertEqual(statement.import_format, "camt053")
self.assertIn("1 bank statement has been imported", ebics_file.note_process)
def test_camt_multi_account(self):
j1 = self._create_bank_journal("TMU1", IBAN_MULTI[0])
j2 = self._create_bank_journal("TMU2", IBAN_MULTI[1])
ebics_file = self._process("camt053_multi_account.xml")
self.assertEqual(ebics_file.bank_statement_ids.journal_id, j1 | j2)
self.assertIn("2 bank statements have been imported", ebics_file.note_process)
def test_reimport_is_reported(self):
self._create_bank_journal("THVB", IBAN_HVB)
sample = "camt053_hvb_clav_fx.xml"
first = self._process(sample, name="first.xml")
self.assertEqual(len(first.bank_statement_ids), 1)
second = self._process(sample, name="second.xml")
self.assertFalse(second.bank_statement_ids)
self.assertIn("has not been processed", second.note_process)
self.assertIn("0010000001", second.note_process)
+1 -1
View File
@@ -4,7 +4,7 @@
{ {
"name": "EBICS - Payment Orders (OCA)", "name": "EBICS - Payment Orders (OCA)",
"summary": "Send an OCA payment order to the bank over EBICS", "summary": "Send an OCA payment order to the bank over EBICS",
"version": "19.0.1.1.0", "version": "19.0.1.1.1",
"license": "LGPL-3", "license": "LGPL-3",
"author": "Noviat", "author": "Noviat",
"website": "https://www.noviat.com/", "website": "https://www.noviat.com/",
@@ -59,7 +59,7 @@ class AccountPaymentOrder(models.Model):
"\nPlease generate first the Payment Order file." "\nPlease generate first the Payment Order file."
) )
) )
elif len(attach) > 1: if len(attach) > 1:
raise UserError( raise UserError(
self.env._( self.env._(
"This payment order contains multiple attachments." "This payment order contains multiple attachments."
@@ -68,39 +68,38 @@ class AccountPaymentOrder(models.Model):
"EBICS Processing > EBICS Upload menu" "EBICS Processing > EBICS Upload menu"
) )
) )
else: origin = self.env._("Payment Order") + ": " + self.name
origin = self.env._("Payment Order") + ": " + self.name if not self.journal_id.ebics_config_id:
if not self.journal_id.ebics_config_id: raise UserError(
raise UserError( self.env._(
self.env._( "No active EBICS configuration available for the selected bank."
"No active EBICS configuration available for the selected bank."
)
) )
ctx.update(
{
"default_ebics_config_id": self.journal_id.ebics_config_id.id,
"default_upload_data": attach.datas,
"default_upload_fname": attach.name,
"origin": origin,
}
) )
ebics_xfer = ( ctx.update(
self.env["ebics.xfer"] {
.with_company(self.company_id) "default_ebics_config_id": self.journal_id.ebics_config_id.id,
.with_context(**ctx) "default_upload_data": attach.datas,
.create({}) "default_upload_fname": attach.name,
) "origin": origin,
ebics_xfer._onchange_ebics_config_id()
ebics_xfer._onchange_upload_data()
view = self.env.ref("account_ebics.ebics_xfer_view_form_upload")
act = {
"name": self.env._("EBICS Upload"),
"view_mode": "form",
"res_model": "ebics.xfer",
"view_id": view.id,
"res_id": ebics_xfer.id,
"type": "ir.actions.act_window",
"target": "new",
"context": ctx,
} }
return act )
ebics_xfer = (
self.env["ebics.xfer"]
.with_company(self.company_id)
.with_context(**ctx)
.create({})
)
ebics_xfer._onchange_ebics_config_id()
ebics_xfer._onchange_upload_data()
view = self.env.ref("account_ebics.ebics_xfer_view_form_upload")
act = {
"name": self.env._("EBICS Upload"),
"view_mode": "form",
"res_model": "ebics.xfer",
"view_id": view.id,
"res_id": ebics_xfer.id,
"type": "ir.actions.act_window",
"target": "new",
"context": ctx,
}
return act
@@ -0,0 +1 @@
from . import test_payment_order_upload
@@ -0,0 +1,95 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
import base64
from odoo.exceptions import UserError
from odoo.tests import tagged
from odoo.addons.account_ebics.tests.common import EbicsTestCommon, FakeEbicsClient
@tagged("post_install", "-at_install")
class TestPaymentOrderUpload(EbicsTestCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env.user.group_ids |= cls.env.ref(
"account_payment_order.group_account_payment"
)
cls.journal = cls._create_bank_journal("TPO", "FR7630004000031234567890143")
cls.ff_cct = cls.env.ref("account_ebics.ebics_ff_CCT")
cls.mode = cls.env["account.payment.mode"].create(
{
"name": "EBICS credit transfer",
"company_id": cls.company.id,
"bank_account_link": "fixed",
"fixed_journal_id": cls.journal.id,
"payment_method_id": cls.env.ref(
"account.account_payment_method_manual_out"
).id,
"ebics_format_id": cls.ff_cct.id,
}
)
def _order(self, state="generated", with_file=True):
order = self.env["account.payment.order"].create(
{
"payment_type": "outbound",
"payment_mode_id": self.mode.id,
"journal_id": self.journal.id,
}
)
order.state = state
if with_file:
self._attach(order, "pain001.xml")
return order
def _attach(self, order, name):
return self.env["ir.attachment"].create(
{
"name": name,
"res_model": order._name,
"res_id": order.id,
"datas": base64.b64encode(b"<Document>pain.001</Document>"),
}
)
def test_hide_ebics_upload(self):
self.assertTrue(self._order(state="draft").hide_ebics_upload)
self.assertFalse(self._order().hide_ebics_upload)
self.ebics_config.journal_ids = False
self.assertTrue(self._order().hide_ebics_upload)
def test_upload_requires_format_on_mode(self):
self.mode.ebics_format_id = False
with self.assertRaisesRegex(UserError, "EBICS File Format"):
self._order().ebics_upload()
def test_upload_requires_one_file(self):
with self.assertRaisesRegex(UserError, "doesn't contains? attachments"):
self._order(with_file=False).ebics_upload()
order = self._order()
self._attach(order, "pain001_old.xml")
with self.assertRaisesRegex(UserError, "multiple attachments"):
order.ebics_upload()
def test_upload(self):
order = self._order()
# the form button passes the active model, as the web client does
action = order.with_context(
active_model=order._name, active_id=order.id
).ebics_upload()
wizard = self.env["ebics.xfer"].browse(action["res_id"])
self.assertEqual(wizard.ebics_config_id, self.ebics_config)
self.assertEqual(wizard.ebics_userid_id, self.ebics_userid)
self.assertEqual(wizard.format_id, self.ff_cct)
self.assertEqual(wizard.upload_fname, "pain001.xml")
with self._fake_client(FakeEbicsClient(order_id="N077")) as client:
wizard.with_context(**action["context"]).ebics_upload()
self.assertEqual(client.uploads[0][1], b"<Document>pain.001</Document>")
self.assertEqual(order.state, "uploaded")
self.assertEqual(order.ebics_order_number, "N077")
self.assertEqual(order.ebics_file_id.pain_state, "uploaded")
self.assertIn(f"Payment Order: {order.name}", order.ebics_file_id.note)
self.assertTrue(any("N077" in msg.body for msg in order.message_ids))
@@ -0,0 +1,16 @@
==============================
EBICS - Statement Import Tests
==============================
**Test-only module. Do not install it on a production database.**
It carries no code and no data. It exists so that continuous integration
installs the OCA statement parsers (``account_statement_import_camt`` and
``account_statement_import_fr_cfonb``) next to ``account_ebics`` and runs the
end-to-end statement import tests: EBICS download, split per account, bank
statement creation.
Credits
=======
Developed and maintained by `Noviat <https://www.noviat.com>`_.
Whitespace-only changes.
@@ -0,0 +1,18 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "EBICS - Statement Import Tests",
"summary": "Test-only module, do not install: runs the EBICS statement "
"import tests against the OCA CAMT and CFONB parsers",
"version": "19.0.1.0.0",
"license": "LGPL-3",
"author": "Noviat",
"website": "https://www.noviat.com/",
"category": "Hidden",
"depends": [
"account_ebics",
"account_statement_import_camt",
"account_statement_import_fr_cfonb",
],
}
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@@ -0,0 +1 @@
from . import test_statement_import
@@ -0,0 +1,115 @@
# Copyright 2026 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from datetime import date
from odoo.tests import tagged
from odoo.addons.account_ebics.tests.common import (
IBAN_CA833,
IBAN_CA879,
IBAN_CIC,
IBAN_CMB,
IBAN_HVB,
IBAN_LCL,
IBAN_MULTI,
EbicsTestCommon,
FakeEbicsClient,
read_sample,
)
@tagged("post_install", "-at_install")
class TestStatementImport(EbicsTestCommon):
"""End to end: EBICS file -> split per account -> OCA parser -> statements."""
def _process(self, sample, file_format, name=None):
ebics_file = self._create_ebics_file(sample, file_format, name=name)
ebics_file.process()
self.assertEqual(ebics_file.state, "done")
return ebics_file
def test_cfonb_multi_account(self):
j1 = self._create_bank_journal("TCA1", IBAN_CA833[0])
j3 = self._create_bank_journal("TCA3", IBAN_CA833[2])
ebics_file = self._process("cfonb120_lf_multi_account_05.dat", self.ff_cfonb120)
statements = ebics_file.bank_statement_ids.sorted("journal_id")
self.assertEqual(statements.journal_id, j1 | j3)
st1 = statements.filtered(lambda s: s.journal_id == j1)
self.assertEqual(st1.balance_start, 8400.0)
self.assertAlmostEqual(st1.balance_end_real, 8907.45)
self.assertEqual(sorted(st1.line_ids.mapped("amount")), [-132.55, 640.0])
self.assertIn("FACT 99812", " ".join(st1.line_ids.mapped("payment_ref")))
self.assertEqual(set(statements.mapped("import_format")), {"cfonb120"})
self.assertIn("2 bank statements have been imported", ebics_file.note_process)
def test_cfonb_minimal_without_complement_lines(self):
journal = self._create_bank_journal("TCA9", IBAN_CA879[3])
ebics_file = self._process("cfonb120_lf_minimal_no_05.dat", self.ff_cfonb120)
statement = ebics_file.bank_statement_ids
self.assertEqual(statement.journal_id, journal)
self.assertEqual(len(statement.line_ids), 2)
self.assertEqual(statement.balance_end_real, 5290.0)
def test_cfonb_no_line_terminator(self):
journals = [
self._create_bank_journal(f"TLC{i}", iban)
for i, iban in enumerate(IBAN_LCL)
]
ebics_file = self._process(
"cfonb120_no_eol_multi_account_mixed.dat", self.ff_cfonb120
)
self.assertEqual(
ebics_file.bank_statement_ids.journal_id, journals[1] | journals[3]
)
def test_cfonb_complement_lines_in_label(self):
self._create_bank_journal("TCIC", IBAN_CIC)
ebics_file = self._process("cfonb120_lf_rich_05.dat", self.ff_cfonb120)
refs = " ".join(ebics_file.bank_statement_ids.line_ids.mapped("payment_ref"))
self.assertIn("FACTURE 7731", refs)
self.assertIn("SALE", refs)
def test_cfonb_missing_journal_is_reported(self):
self._create_bank_journal("TCA1", IBAN_CA833[0])
ebics_file = self._process("cfonb120_lf_multi_account_05.dat", self.ff_cfonb120)
self.assertEqual(len(ebics_file.bank_statement_ids), 1)
self.assertIn("No financial journal found", ebics_file.note_process)
self.assertIn("20000000203", ebics_file.note_process)
def test_cfonb_empty_file(self):
self._create_bank_journal("TCMB", IBAN_CMB)
ebics_file = self._process("cfonb120_no_eol_empty_only.dat", self.ff_cfonb120)
self.assertFalse(ebics_file.bank_statement_ids)
self.assertIn("doesn't contain any transaction", ebics_file.note_process)
def test_camt_fx_entry(self):
journal = self._create_bank_journal("THVB", IBAN_HVB)
ebics_file = self._process("camt053_hvb_clav_fx.xml", self.ff_camt053)
statement = ebics_file.bank_statement_ids
self.assertEqual(statement.journal_id, journal)
self.assertEqual(statement.balance_start, 5000.0)
self.assertEqual(statement.balance_end_real, 3992.5)
self.assertEqual(sorted(statement.line_ids.mapped("amount")), [-857.5, -150.0])
self.assertEqual(statement.import_format, "camt053")
def test_camt_multi_account(self):
j1 = self._create_bank_journal("TMU1", IBAN_MULTI[0])
j2 = self._create_bank_journal("TMU2", IBAN_MULTI[1])
ebics_file = self._process("camt053_multi_account.xml", self.ff_camt053)
self.assertEqual(ebics_file.bank_statement_ids.journal_id, j1 | j2)
def test_download_then_process(self):
journal = self._create_bank_journal("TCMB", IBAN_CMB)
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})):
action = wizard.ebics_download()
ebics_file = self.env["ebics.file"].browse(action["context"]["ebics_file_ids"])
ebics_file.process()
self.assertEqual(ebics_file.bank_statement_ids.journal_id, journal)
self.assertEqual(len(ebics_file.bank_statement_ids.line_ids), 2)
self.assertEqual(
ebics_file.bank_statement_ids.ebics_file_id,
ebics_file,
)
+2 -1
View File
@@ -1,3 +1,4 @@
odoo-addon-module_change_auto_install odoo-addon-module_change_auto_install
openupgradelib openupgradelib
lxml_html_clean odoo-addon-account_statement_import_camt
odoo-addon-account_statement_import_fr_cfonb