[MIG] account_statement_import_camt: Migration to 17.0

This commit is contained in:
Holger Brunn
2024-04-22 14:11:50 +02:00
parent 7a62a01080
commit b4c2426486
10 changed files with 38 additions and 84 deletions

View File

@@ -7,7 +7,7 @@ CAMT Format Bank Statements Import
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6af9753752cdfa39f3d971e084ed946578dc75aafbbc9a600aeb0b8b06b4427b
!! source digest: sha256:a1b71f36ee91c7d89b3cf754ba711cd5d8e50cfb7f9742a9153ca74ce043d458
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -56,7 +56,7 @@ Authors
Contributors
------------
- Holger Brunn <hbrunn@therp.nl>
- Holger Brunn <mail@hunki-enterprises.com>
- Stefan Rijnhart <stefan.rijnhart@opener.amsterdam>

View File

@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "CAMT Format Bank Statements Import",
"version": "16.0.1.0.1",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Therp BV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/bank-statement-import",

View File

@@ -1,5 +1,3 @@
from . import parser
from . import account_bank_statement_line
from . import account_statement_import
from . import account_journal
from . import bank_statement
from . import account_statement_import_camt_parser
from . import account_statement_import

View File

@@ -1,26 +0,0 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"
def write(self, vals):
"""
Purpose of this hook is catch updates for records with name == '/'
In reconciliation_widget_preprocess, there is attempt to assign
partner into statement line, this assignment relies on name,
during import name setup to '/' for records without it
and this makes search results wrong and partner assignment randomly
"""
if (
self.env.context.get("no_reassign_empty_name")
and len(self) == 1
and len(vals.keys()) == 1
and "partner_id" in vals
and self.name == "/"
):
return True
return super().write(vals)

View File

@@ -9,7 +9,7 @@ from odoo import models
_logger = logging.getLogger(__name__)
class AccountBankStatementImport(models.TransientModel):
class AccountStatementImport(models.TransientModel):
_inherit = "account.statement.import"
def _parse_file(self, data_file):

View File

@@ -9,7 +9,7 @@ from lxml import etree
from odoo import _, models
class CamtParser(models.AbstractModel):
class AccountStatementImportCamtParser(models.AbstractModel):
_name = "account.statement.import.camt.parser"
_description = "Account Bank Statement Import CAMT parser"
@@ -193,9 +193,8 @@ class CamtParser(models.AbstractModel):
)
if party_node:
name_node = node.xpath(
"./ns:RltdPties/ns:{pt}/ns:Nm | ./ns:RltdPties/ns:{pt}/ns:Pty/ns:Nm".format(
pt=party_type
),
f"./ns:RltdPties/ns:{party_type}/ns:Nm |"
f"./ns:RltdPties/ns:{party_type}/ns:Pty/ns:Nm",
namespaces={"ns": ns},
)
if name_node:

View File

@@ -1,12 +0,0 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class AccountBankStatement(models.Model):
_inherit = "account.bank.statement"
def reconciliation_widget_preprocess(self):
return super(
AccountBankStatement, self.with_context(no_reassign_empty_name=True)
).reconciliation_widget_preprocess()

View File

@@ -1,4 +1,4 @@
- Holger Brunn \<<hbrunn@therp.nl>\>
- Holger Brunn \<<mail@hunki-enterprises.com>\>
- Stefan Rijnhart \<<stefan.rijnhart@opener.amsterdam>\>

View File

@@ -1,21 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>CAMT Format Bank Statements Import</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
@@ -276,7 +274,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -302,7 +300,7 @@ span.option {
span.pre {
white-space: pre }
span.problematic, pre.problematic {
span.problematic {
color: red }
span.section-subtitle {
@@ -368,25 +366,25 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6af9753752cdfa39f3d971e084ed946578dc75aafbbc9a600aeb0b8b06b4427b
!! source digest: sha256:a1b71f36ee91c7d89b3cf754ba711cd5d8e50cfb7f9742a9153ca74ce043d458
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-statement-import/tree/17.0/account_statement_import_camt"><img alt="OCA/bank-statement-import" src="https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-statement-import-17-0/bank-statement-import-17-0-account_statement_import_camt"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Module to import SEPA CAMT.053 and CAMT.054 Format bank statement files.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-5">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="id5">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-statement-import/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
@@ -394,17 +392,17 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
<ul class="simple">
<li>Therp BV</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<ul>
<li><p class="first">Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</p>
<li><p class="first">Holger Brunn &lt;<a class="reference external" href="mailto:mail&#64;hunki-enterprises.com">mail&#64;hunki-enterprises.com</a>&gt;</p>
</li>
<li><p class="first">Stefan Rijnhart &lt;<a class="reference external" href="mailto:stefan.rijnhart&#64;opener.amsterdam">stefan.rijnhart&#64;opener.amsterdam</a>&gt;</p>
</li>
@@ -426,16 +424,14 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
<h2><a class="toc-backref" href="#id5">Other credits</a></h2>
<p>The migration of this module from 15.0 to 16.0 was financially supported
by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>

View File

@@ -9,8 +9,8 @@ import tempfile
from datetime import date
from pathlib import Path
from odoo.modules.module import get_module_resource
from odoo.tests.common import TransactionCase
from odoo.tools.misc import file_path
class TestParserCommon(TransactionCase):
@@ -45,15 +45,16 @@ class TestParserCommon(TransactionCase):
:param inputfile_path: path for file to import and test
:type inputfile_path: Path
:param goldenfile_path: path for file to use for comparison (the expected values)
:param goldenfile_path: path for file to use for comparison
(the expected values)
:type goldenfile_path: Path
"""
# Read the input file, store the actual imported values
with open(get_module_resource(*inputfile_path.parts), "rb") as inputf:
with open(file_path(inputfile_path), "rb") as inputf:
res = self.parser.parse(inputf.read())
# Read the output file, store the expected imported values
with open(get_module_resource(*goldenfile_path.parts)) as goldf:
with open(file_path(goldenfile_path)) as goldf:
gold_name, gold_lines = goldf.name, goldf.readlines()
# Save the imported values in a tmp file to compare them w/ the expected values
with tempfile.NamedTemporaryFile(mode="w+", suffix=".pydata") as tempf:
@@ -158,9 +159,7 @@ class TestImport(TransactionCase):
def test_statement_import(self):
"""Test correct creation of single statement."""
testfile = get_module_resource(
"account_statement_import_camt", "test_files", "test-camt053"
)
testfile = file_path("account_statement_import_camt/test_files/test-camt053")
with open(testfile, "rb") as datafile:
camt_file = base64.b64encode(datafile.read())
@@ -190,8 +189,8 @@ class TestImport(TransactionCase):
def test_zip_import(self):
"""Test import of multiple statements from zip file."""
testfile = get_module_resource(
"account_statement_import_camt", "test_files", "test-camt053.zip"
testfile = file_path(
"account_statement_import_camt/test_files/test-camt053.zip"
)
with open(testfile, "rb") as datafile:
camt_file = base64.b64encode(datafile.read())