[MIG] account_bank_statement_import_online_qonto: Migration to 16.0

This commit is contained in:
Carolina Fernandez
2024-04-08 16:11:35 +02:00
parent 74c14c920e
commit d923cd57ff
12 changed files with 90 additions and 64 deletions

View File

@@ -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 <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_online_qonto%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_online_qonto%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.
@@ -100,6 +100,8 @@ Contributors
* `Tecnativa <https://www.tecnativa.com>`__:
* 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 <https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_online_qonto>`_ 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_online_qonto>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -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"],
}

View File

@@ -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 ""

View File

@@ -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:

View File

@@ -2,3 +2,5 @@
* `Tecnativa <https://www.tecnativa.com>`__:
* Pedro M. Baeza
* Caolina Fernandez

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:4ee67601b7ef05d8901653197e548977046329fd4bfadb5e12d3077a89bcc3fd
!! source digest: sha256:fbd21876df6cece1a8704d347f4fce2e43ccfcc6caa2cbe75492e053487703ac
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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_online_qonto"><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_online_qonto"><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_online_qonto"><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_online_qonto"><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 provides online bank statements from Qonto Bank.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@@ -430,7 +430,7 @@ ul.auto-toc {
<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_online_qonto%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_online_qonto%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">
@@ -447,6 +447,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Florent de Labarre</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Pedro M. Baeza</li>
<li>Caolina Fernandez</li>
</ul>
</li>
</ul>
@@ -458,7 +459,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_online_qonto">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_online_qonto">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

@@ -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

View File

@@ -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": [

View File

@@ -5,10 +5,10 @@
<field name="model">online.bank.statement.provider</field>
<field
name="inherit_id"
ref="account_bank_statement_import_online.online_bank_statement_provider_form"
ref="account_statement_import_online.online_bank_statement_provider_form"
/>
<field name="arch" type="xml">
<xpath expr="//page[@name='configuration']" position="inside">
<xpath expr="//group[@name='main']" position="inside">
<group name="qonto" attrs="{'invisible':[('service','!=','qonto')]}">
<field name="username" string="Login" />
<field name="password" string="Key" />

View File

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

View File

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