[MIG] account_bank_statement_import_qif: Migration to 16.0 and rename to account_statement_import_qif

TT46557
This commit is contained in:
Víctor Martínez
2024-04-04 09:00:51 +02:00
parent cc87171aad
commit 8866dd4b60
10 changed files with 50 additions and 44 deletions

View File

@@ -7,7 +7,7 @@ Import QIF Bank Statements
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:926bb5e821cd71d9a5bdaee546ce3b8f25a00825ff69c291da88820e8e53ae62
!! source digest: sha256:46da85f209ed418623ef45de4757c7ceb32bedf65df4d336d7f8a8473da6c1d0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Import QIF Bank Statements
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github
:target: https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_qif
:target: https://github.com/OCA/bank-statement-import/tree/16.0/account_statement_import_qif
:alt: OCA/bank-statement-import
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/bank-statement-import-13-0/bank-statement-import-13-0-account_bank_statement_import_qif
:target: https://translation.odoo-community.org/projects/bank-statement-import-16-0/bank-statement-import-16-0-account_statement_import_qif
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=13.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -64,7 +64,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-statement-import/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_bank_statement_import_qif%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_qif%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -107,6 +107,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_qif>`_ project on GitHub.
This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/16.0/account_statement_import_qif>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -7,11 +7,11 @@
{
"name": "Import QIF Bank Statements",
"category": "Accounting",
"version": "13.0.1.0.0",
"version": "16.0.1.0.0",
"author": "OpenERP SA," "Tecnativa," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/bank-statement-import",
"depends": ["account_bank_statement_import"],
"data": ["wizards/account_bank_statement_import_qif_view.xml"],
"depends": ["account_statement_import_file"],
"data": ["wizards/account_statement_import_qif_view.xml"],
"installable": True,
"license": "AGPL-3",
}

View File

@@ -367,9 +367,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:926bb5e821cd71d9a5bdaee546ce3b8f25a00825ff69c291da88820e8e53ae62
!! source digest: sha256:46da85f209ed418623ef45de4757c7ceb32bedf65df4d336d7f8a8473da6c1d0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/13.0/account_bank_statement_import_qif"><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-13-0/bank-statement-import-13-0-account_bank_statement_import_qif"><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=13.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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/16.0/account_statement_import_qif"><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-16-0/bank-statement-import-16-0-account_statement_import_qif"><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=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to import the machine readable QIF Files in Odoo: they
are parsed and stored in human readable format in
Accounting Bank and Cash Bank Statements.</p>
@@ -405,7 +405,7 @@ original AGPL code.</p>
<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
<a class="reference external" href="https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_bank_statement_import_qif%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_qif%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -448,7 +448,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<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>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_qif">OCA/bank-statement-import</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/16.0/account_statement_import_qif">OCA/bank-statement-import</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -2,6 +2,7 @@
# Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu>
# Copyright 2015 Ronald Portier <rportier@therp.nl>
# Copyright 2016-2017 Tecnativa - Pedro M. Baeza
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import base64
@@ -15,14 +16,20 @@ class TestQifFile(TransactionCase):
(account.bank.statement.import)
"""
def setUp(self):
super().setUp()
self.statement_import_model = self.env["account.bank.statement.import"]
self.statement_line_model = self.env["account.bank.statement.line"]
self.journal = self.env["account.journal"].create(
{"name": "Test bank journal", "code": "TEST", "type": "bank"}
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.statement_import_model = cls.env["account.statement.import"]
cls.statement_line_model = cls.env["account.bank.statement.line"]
cls.journal = cls.env["account.journal"].create(
{
"name": "Test bank journal",
"code": "TEST",
"type": "bank",
"currency_id": cls.env.company.currency_id.id,
}
)
self.partner = self.env["res.partner"].create(
cls.partner = cls.env["res.partner"].create(
{
# Different case for trying insensitive case search
"name": "EPIC Technologies",
@@ -31,22 +38,22 @@ class TestQifFile(TransactionCase):
def test_qif_file_import(self):
qif_file_path = get_module_resource(
"account_bank_statement_import_qif",
"account_statement_import_qif",
"tests",
"test_qif.qif",
)
qif_file = base64.b64encode(open(qif_file_path, "rb").read())
wizard = self.statement_import_model.with_context(
journal_id=self.journal.id
).create({"attachment_ids": [(0, 0, {"name": "test file", "datas": qif_file})]})
wizard.import_file()
).create({"statement_file": qif_file, "statement_filename": "test_qif.qif"})
wizard.import_file_button()
statement = self.statement_line_model.search(
[("name", "=", "YOUR LOCAL SUPERMARKET")],
[("payment_ref", "=", "YOUR LOCAL SUPERMARKET")],
limit=1,
)[0].statement_id
).statement_id
self.assertAlmostEqual(statement.balance_end_real, -1896.09, 2)
line = self.statement_line_model.search(
[("name", "=", "Epic Technologies")],
[("payment_ref", "=", "Epic Technologies")],
limit=1,
)
self.assertEqual(line.partner_id, self.partner)

View File

@@ -1,3 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_bank_statement_import_qif
from . import account_statement_import_qif

View File

@@ -13,8 +13,8 @@ from odoo.exceptions import UserError
from odoo.tools.translate import _
class AccountBankStatementImport(models.TransientModel):
_inherit = "account.bank.statement.import"
class AccountStatementImport(models.TransientModel):
_inherit = "account.statement.import"
@api.model
def _check_qif(self, data_file):
@@ -31,8 +31,8 @@ class AccountBankStatementImport(models.TransientModel):
data_list = file_data.split("\n")
header = data_list[0].strip()
header = header.split(":")[1]
except Exception:
raise UserError(_("Could not decipher the QIF file."))
except Exception as e:
raise UserError(_("Could not decipher the QIF file.")) from e
transactions = []
vals_line = {}
total = 0
@@ -52,13 +52,13 @@ class AccountBankStatementImport(models.TransientModel):
elif line[0] == "N": # Check number
vals_line["ref"] = line[1:]
elif line[0] == "P": # Payee
vals_line["name"] = (
vals_line["payment_ref"] = (
"name" in vals_line
and line[1:] + ": " + vals_line["name"]
or line[1:]
)
elif line[0] == "M": # Memo
vals_line["name"] = (
vals_line["payment_ref"] = (
"name" in vals_line
and vals_line["name"] + ": " + line[1:]
or line[1:]
@@ -80,7 +80,8 @@ class AccountBankStatementImport(models.TransientModel):
vals_bank_statement.update(
{"balance_end_real": total, "transactions": transactions}
)
return None, None, [vals_bank_statement]
journal = self.env["account.journal"].browse(self.env.context.get("journal_id"))
return journal.currency_id.name, None, [vals_bank_statement]
def _complete_stmts_vals(self, stmt_vals, journal_id, account_number):
"""Match partner_id if hasn't been deducted yet."""
@@ -88,16 +89,16 @@ class AccountBankStatementImport(models.TransientModel):
# Since QIF doesn't provide account numbers (normal behaviour is to
# provide 'account_number', which the generic module uses to find
# the partner), we have to find res.partner through the name
if not self.attachment_ids or not self._check_qif(
base64.b64decode(self.attachment_ids[0].datas)
if not self.statement_file or not self._check_qif(
base64.b64decode(self.statement_file)
):
return res
partner_obj = self.env["res.partner"]
for statement in res:
for line_vals in statement["transactions"]:
if not line_vals.get("partner_id") and line_vals.get("name"):
if not line_vals.get("partner_id") and line_vals.get("payment_ref"):
partner = partner_obj.search(
[("name", "ilike", line_vals["name"])],
[("name", "ilike", line_vals["payment_ref"])],
limit=1,
)
line_vals["partner_id"] = partner.id

View File

@@ -1,11 +1,10 @@
<?xml version="1.0" ?>
<odoo>
<record id="account_bank_statement_import_view" model="ir.ui.view">
<field name="model">account.bank.statement.import</field>
<record id="account_statement_import_form" model="ir.ui.view">
<field name="model">account.statement.import</field>
<field
name="inherit_id"
ref="account_bank_statement_import.account_bank_statement_import_view"
ref="account_statement_import_file.account_statement_import_form"
/>
<field name="arch" type="xml">
<xpath expr="//ul[@id='statement_format']" position="inside">
@@ -13,5 +12,4 @@
</xpath>
</field>
</record>
</odoo>

View File

@@ -1 +0,0 @@
../../../../account_bank_statement_import_qif

View File

@@ -0,0 +1 @@
../../../../account_statement_import_qif