From d923cd57ffa626bb060213524001ead764203562 Mon Sep 17 00:00:00 2001 From: Carolina Fernandez Date: Mon, 8 Apr 2024 16:11:35 +0200 Subject: [PATCH] [MIG] account_bank_statement_import_online_qonto: Migration to 16.0 --- .../README.rst | 14 +++--- .../__manifest__.py | 4 +- ...unt_bank_statement_import_online_qonto.pot | 36 +++++++------- .../online_bank_statement_provider_qonto.py | 34 ++++++++++---- .../readme/CONTRIBUTORS.rst | 2 + .../static/description/index.html | 9 ++-- .../tests/__init__.py | 2 +- ..._account_statement_import_online_qonto.py} | 47 ++++++++++--------- .../view/online_bank_statement_provider.xml | 4 +- ...account_bank_statement_import_online_qonto | 1 - .../account_statement_import_online_qonto | 1 + .../setup.py | 0 12 files changed, 90 insertions(+), 64 deletions(-) rename account_statement_import_online_qonto/tests/{test_account_bank_statement_import_online_qonto.py => test_account_statement_import_online_qonto.py} (77%) delete mode 120000 setup/account_bank_statement_import_online_qonto/odoo/addons/account_bank_statement_import_online_qonto create mode 120000 setup/account_statement_import_online_qonto/odoo/addons/account_statement_import_online_qonto rename setup/{account_bank_statement_import_online_qonto => account_statement_import_online_qonto}/setup.py (100%) diff --git a/account_statement_import_online_qonto/README.rst b/account_statement_import_online_qonto/README.rst index 4175d853..9b9e81bc 100644 --- a/account_statement_import_online_qonto/README.rst +++ b/account_statement_import_online_qonto/README.rst @@ -7,7 +7,7 @@ Online Bank Statements: Qonto !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:4ee67601b7ef05d8901653197e548977046329fd4bfadb5e12d3077a89bcc3fd + !! source digest: sha256:fbd21876df6cece1a8704d347f4fce2e43ccfcc6caa2cbe75492e053487703ac !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -17,13 +17,13 @@ Online Bank Statements: Qonto :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_online_qonto + :target: https://github.com/OCA/bank-statement-import/tree/16.0/account_statement_import_online_qonto :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_online_qonto + :target: https://translation.odoo-community.org/projects/bank-statement-import-16-0/bank-statement-import-16-0-account_statement_import_online_qonto :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| @@ -81,7 +81,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -100,6 +100,8 @@ Contributors * `Tecnativa `__: * Pedro M. Baeza + * Caolina Fernandez + Maintainers ~~~~~~~~~~~ @@ -114,6 +116,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 `_ project on GitHub. +This module is part of the `OCA/bank-statement-import `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_statement_import_online_qonto/__manifest__.py b/account_statement_import_online_qonto/__manifest__.py index 6f474194..bb455376 100644 --- a/account_statement_import_online_qonto/__manifest__.py +++ b/account_statement_import_online_qonto/__manifest__.py @@ -1,12 +1,12 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Online Bank Statements: Qonto", - "version": "13.0.1.0.1", + "version": "16.0.1.0.0", "category": "Account", "website": "https://github.com/OCA/bank-statement-import", "author": "Florent de Labarre, Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, - "depends": ["account_bank_statement_import_online"], + "depends": ["account_statement_import_online"], "data": ["view/online_bank_statement_provider.xml"], } diff --git a/account_statement_import_online_qonto/i18n/account_bank_statement_import_online_qonto.pot b/account_statement_import_online_qonto/i18n/account_bank_statement_import_online_qonto.pot index b42490a9..f53ecbff 100644 --- a/account_statement_import_online_qonto/i18n/account_bank_statement_import_online_qonto.pot +++ b/account_statement_import_online_qonto/i18n/account_bank_statement_import_online_qonto.pot @@ -1,6 +1,6 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_online_qonto +# * account_statement_import_online_qonto # msgid "" msgstr "" @@ -13,9 +13,9 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" -#. module: account_bank_statement_import_online_qonto -#: code:addons/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 -#: code:addons/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 +#. module: account_statement_import_online_qonto +#: code:addons/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 +#: code:addons/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 #, python-format msgid "" "%s \n" @@ -23,41 +23,41 @@ msgid "" " %s" msgstr "" -#. module: account_bank_statement_import_online_qonto -#: code:addons/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 +#. module: account_statement_import_online_qonto +#: code:addons/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 #, python-format msgid "Currency %s used in transaction ID %s doesn't exist in Odoo." msgstr "" -#. module: account_bank_statement_import_online_qonto -#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_online_qonto.online_bank_statement_provider_form +#. module: account_statement_import_online_qonto +#: model_terms:ir.ui.view,arch_db:account_statement_import_online_qonto.online_bank_statement_provider_form msgid "Key" msgstr "" -#. module: account_bank_statement_import_online_qonto -#: model_terms:ir.ui.view,arch_db:account_bank_statement_import_online_qonto.online_bank_statement_provider_form +#. module: account_statement_import_online_qonto +#: model_terms:ir.ui.view,arch_db:account_statement_import_online_qonto.online_bank_statement_provider_form msgid "Login" msgstr "" -#. module: account_bank_statement_import_online_qonto -#: model:ir.model,name:account_bank_statement_import_online_qonto.model_online_bank_statement_provider +#. module: account_statement_import_online_qonto +#: model:ir.model,name:account_statement_import_online_qonto.model_online_bank_statement_provider msgid "Online Bank Statement Provider" msgstr "" -#. module: account_bank_statement_import_online_qonto -#: code:addons/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 +#. module: account_statement_import_online_qonto +#: code:addons/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 #, python-format msgid "Please fill login and key" msgstr "" -#. module: account_bank_statement_import_online_qonto -#: code:addons/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 +#. module: account_statement_import_online_qonto +#: code:addons/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 #, python-format msgid "Qonto : wrong configuration, unknow account %s" msgstr "" -#. module: account_bank_statement_import_online_qonto -#: code:addons/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 +#. module: account_statement_import_online_qonto +#: code:addons/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py:0 #, python-format msgid "Transaction ID %s has not local_currency. This should never happen." msgstr "" diff --git a/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py b/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py index e3b4d465..262217ef 100644 --- a/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py +++ b/account_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py @@ -54,7 +54,9 @@ class OnlineBankStatementProviderQonto(models.Model): def _qonto_get_slug(self): self.ensure_one() url = QONTO_ENDPOINT + "/organizations/%7Bid%7D" - response = requests.get(url, verify=False, headers=self._qonto_header()) + response = requests.get( + url, verify=False, headers=self._qonto_header(), timeout=10 + ) if response.status_code == 200: data = json.loads(response.text) res = {} @@ -62,7 +64,10 @@ class OnlineBankStatementProviderQonto(models.Model): iban = sanitize_account_number(account.get("iban", "")) res[iban] = account.get("slug") return res - raise UserError(_("%s \n\n %s") % (response.status_code, response.text)) + raise UserError( + _("%(status_code)s \n\n %(response_text)s") + % {"status_code": response.status_code, "response_text": response.text} + ) def _qonto_obtain_transactions(self, slug, date_since, date_until): self.ensure_one() @@ -95,11 +100,18 @@ class OnlineBankStatementProviderQonto(models.Model): def _qonto_get_transactions(self, url, params): response = requests.get( - url, verify=False, params=params, headers=self._qonto_header() + url, + verify=False, + params=params, + headers=self._qonto_header(), + timeout=10, ) if response.status_code == 200: return json.loads(response.text) - raise UserError(_("%s \n\n %s") % (response.status_code, response.text)) + raise UserError( + _("%(status_code)s \n\n %(response_text)s") + % {"status_code": response.status_code, "response_text": response.text} + ) def _qonto_prepare_statement_line( self, transaction, sequence, journal_currency, currencies_code2id @@ -121,15 +133,21 @@ class OnlineBankStatementProviderQonto(models.Model): if not transaction["local_currency"]: raise UserError( _( - "Transaction ID %s has not local_currency. " + "Transaction ID %(transaction_id)s has no local currency. " "This should never happen." ) - % transaction["transaction_id"] + % {"transaction_id": transaction["transaction_id"]} ) if transaction["local_currency"] not in currencies_code2id: raise UserError( - _("Currency %s used in transaction ID %s doesn't exist in Odoo.") - % (transaction["local_currency"], transaction["transaction_id"]) + _( + "Currency %(currency)s used in transaction ID " + "%(transaction_id)s doesn't exist in Odoo." + ) + % { + "currency": transaction["local_currency"], + "transaction_id": transaction["transaction_id"], + } ) line_currency_id = currencies_code2id[transaction["local_currency"]] if journal_currency.id != line_currency_id: diff --git a/account_statement_import_online_qonto/readme/CONTRIBUTORS.rst b/account_statement_import_online_qonto/readme/CONTRIBUTORS.rst index 077a3ecf..1b7de741 100644 --- a/account_statement_import_online_qonto/readme/CONTRIBUTORS.rst +++ b/account_statement_import_online_qonto/readme/CONTRIBUTORS.rst @@ -2,3 +2,5 @@ * `Tecnativa `__: * Pedro M. Baeza + * Caolina Fernandez + diff --git a/account_statement_import_online_qonto/static/description/index.html b/account_statement_import_online_qonto/static/description/index.html index e700f0c2..ebb9557b 100644 --- a/account_statement_import_online_qonto/static/description/index.html +++ b/account_statement_import_online_qonto/static/description/index.html @@ -367,9 +367,9 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:4ee67601b7ef05d8901653197e548977046329fd4bfadb5e12d3077a89bcc3fd +!! source digest: sha256:fbd21876df6cece1a8704d347f4fce2e43ccfcc6caa2cbe75492e053487703ac !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/bank-statement-import Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/bank-statement-import Translate me on Weblate Try me on Runboat

This module provides online bank statements from Qonto Bank.

Table of contents

@@ -430,7 +430,7 @@ ul.auto-toc {

Bugs are tracked on GitHub 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.

+feedback.

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

@@ -447,6 +447,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Florent de Labarre
  • Tecnativa:
    • Pedro M. Baeza
    • +
    • Caolina Fernandez
  • @@ -458,7 +459,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

    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 project on GitHub.

    +

    This module is part of the OCA/bank-statement-import project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/account_statement_import_online_qonto/tests/__init__.py b/account_statement_import_online_qonto/tests/__init__.py index 148eb15d..b5d86a7f 100644 --- a/account_statement_import_online_qonto/tests/__init__.py +++ b/account_statement_import_online_qonto/tests/__init__.py @@ -1,3 +1,3 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from . import test_account_bank_statement_import_online_qonto +from . import test_account_statement_import_online_qonto diff --git a/account_statement_import_online_qonto/tests/test_account_bank_statement_import_online_qonto.py b/account_statement_import_online_qonto/tests/test_account_statement_import_online_qonto.py similarity index 77% rename from account_statement_import_online_qonto/tests/test_account_bank_statement_import_online_qonto.py rename to account_statement_import_online_qonto/tests/test_account_statement_import_online_qonto.py index cb621fb8..d3a5ece4 100644 --- a/account_statement_import_online_qonto/tests/test_account_bank_statement_import_online_qonto.py +++ b/account_statement_import_online_qonto/tests/test_account_statement_import_online_qonto.py @@ -5,9 +5,9 @@ from datetime import datetime from unittest import mock from odoo import fields -from odoo.tests import common +from odoo.tests.common import TransactionCase -_module_ns = "odoo.addons.account_bank_statement_import_online_qonto" +_module_ns = "odoo.addons.account_statement_import_online_qonto" _provider_class = ( _module_ns + ".models.online_bank_statement_provider_qonto" @@ -15,43 +15,46 @@ _provider_class = ( ) -class TestAccountBankAccountStatementImportOnlineQonto(common.TransactionCase): - def setUp(self): - super().setUp() +class TestAccountStatementImportOnlineQonto(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.now = fields.Datetime.now() + cls.currency_eur = cls.env.ref("base.EUR") + cls.currency_usd = cls.env.ref("base.USD") + cls.AccountJournal = cls.env["account.journal"] + cls.ResPartnerBank = cls.env["res.partner.bank"] + cls.OnlineBankStatementProvider = cls.env["online.bank.statement.provider"] + cls.AccountBankStatement = cls.env["account.bank.statement"] + cls.AccountBankStatementLine = cls.env["account.bank.statement.line"] - self.now = fields.Datetime.now() - self.currency_eur = self.env.ref("base.EUR") - self.currency_usd = self.env.ref("base.USD") - self.AccountJournal = self.env["account.journal"] - self.ResPartnerBank = self.env["res.partner.bank"] - self.OnlineBankStatementProvider = self.env["online.bank.statement.provider"] - self.AccountBankStatement = self.env["account.bank.statement"] - self.AccountBankStatementLine = self.env["account.bank.statement.line"] - - self.bank_account = self.ResPartnerBank.create( + cls.bank_account = cls.ResPartnerBank.create( { "acc_number": "FR0214508000302245362775K46", - "partner_id": self.env.user.company_id.partner_id.id, + "partner_id": cls.env.user.company_id.partner_id.id, } ) - self.journal = self.AccountJournal.create( + cls.journal = cls.AccountJournal.create( { "name": "Bank", "type": "bank", "code": "BANK", - "currency_id": self.currency_eur.id, + "currency_id": cls.currency_eur.id, "bank_statements_source": "online", "online_bank_statement_provider": "qonto", - "bank_account_id": self.bank_account.id, + "bank_account_id": cls.bank_account.id, } ) - self.provider = self.journal.online_bank_statement_provider_id + cls.provider = cls.journal.online_bank_statement_provider_id - self.mock_slug = lambda: mock.patch( + def mock_slug(self): + return mock.patch( _provider_class + "._qonto_get_slug", return_value={"FR0214508000302245362775K46": "qonto-1234-bank-account-1"}, ) - self.mock_transaction = lambda: mock.patch( + + def mock_transaction(self): + return mock.patch( _provider_class + "._qonto_get_transactions", return_value={ "transactions": [ diff --git a/account_statement_import_online_qonto/view/online_bank_statement_provider.xml b/account_statement_import_online_qonto/view/online_bank_statement_provider.xml index 0862a5af..9d2924fc 100644 --- a/account_statement_import_online_qonto/view/online_bank_statement_provider.xml +++ b/account_statement_import_online_qonto/view/online_bank_statement_provider.xml @@ -5,10 +5,10 @@ online.bank.statement.provider - + diff --git a/setup/account_bank_statement_import_online_qonto/odoo/addons/account_bank_statement_import_online_qonto b/setup/account_bank_statement_import_online_qonto/odoo/addons/account_bank_statement_import_online_qonto deleted file mode 120000 index 7928bb92..00000000 --- a/setup/account_bank_statement_import_online_qonto/odoo/addons/account_bank_statement_import_online_qonto +++ /dev/null @@ -1 +0,0 @@ -../../../../account_bank_statement_import_online_qonto \ No newline at end of file diff --git a/setup/account_statement_import_online_qonto/odoo/addons/account_statement_import_online_qonto b/setup/account_statement_import_online_qonto/odoo/addons/account_statement_import_online_qonto new file mode 120000 index 00000000..3a6acd1e --- /dev/null +++ b/setup/account_statement_import_online_qonto/odoo/addons/account_statement_import_online_qonto @@ -0,0 +1 @@ +../../../../account_statement_import_online_qonto \ No newline at end of file diff --git a/setup/account_bank_statement_import_online_qonto/setup.py b/setup/account_statement_import_online_qonto/setup.py similarity index 100% rename from setup/account_bank_statement_import_online_qonto/setup.py rename to setup/account_statement_import_online_qonto/setup.py