From 48c2625d9026c5b3e6587ae660415cbaa64500e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 5 Dec 2022 12:14:37 +0100 Subject: [PATCH] [FIX] account_bank_statement_import_online_qonto: Avoid errors if year is different TT40742 --- .../models/online_bank_statement_provider_qonto.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py b/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py index 10c2587..1d06a81 100644 --- a/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py +++ b/account_bank_statement_import_online_qonto/models/online_bank_statement_provider_qonto.py @@ -5,7 +5,7 @@ import json from datetime import datetime import pytz -from odoo import api, models, _ +from odoo import _, api, fields, models from odoo.exceptions import UserError from odoo.addons.base.models.res_bank import sanitize_account_number @@ -66,7 +66,12 @@ class OnlineBankStatementProviderQonto(models.Model): self.ensure_one() url = QONTO_ENDPOINT + "/transactions" params = {"slug": slug, "iban": self.account_number} - + # settled_at_to param isn't well formatted (ISO 8601) or year is out of range". + # We set the last day of the year in such case. + if date_since and date_until and date_since.year != date_until.year: + date_until = fields.Datetime.from_string( + "%s-12-31 23:59:59" % date_since.year + ) if date_since: params["settled_at_from"] = ( date_since.replace(microsecond=0).isoformat() + "Z"