From 87e4c84c7a59fa39ba90c296fbb98a6a2efe292a Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Wed, 8 Jan 2025 09:27:21 +0100 Subject: [PATCH] [IMP] account_statement_import_online_gocardless: Allow to select other countries --- .../models/online_bank_statement_provider.py | 18 +++++++++++++++--- .../view/online_bank_statement_provider.xml | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/account_statement_import_online_gocardless/models/online_bank_statement_provider.py b/account_statement_import_online_gocardless/models/online_bank_statement_provider.py index 11875253..ee5f6605 100644 --- a/account_statement_import_online_gocardless/models/online_bank_statement_provider.py +++ b/account_statement_import_online_gocardless/models/online_bank_statement_provider.py @@ -29,6 +29,20 @@ class OnlineBankStatementProvider(models.Model): gocardless_requisition_expiration = fields.Datetime(readonly=True) gocardless_institution_id = fields.Char() gocardless_account_id = fields.Char() + gocardless_country_id = fields.Many2one( + "res.country", + compute="_compute_gocardless_country_id", + store=True, + readonly=False, + ) + + @api.depends("journal_id", "company_id") + def _compute_gocardless_country_id(self): + for provider in self: + provider.gocardless_country_id = ( + provider.journal_id.bank_account_id.company_id + or provider.journal_id.company_id + ).country_id def gocardless_reset_requisition(self): self.write( @@ -147,9 +161,7 @@ class OnlineBankStatementProvider(models.Model): def _gocardless_select_bank_institution(self): """Ask for the GoCardless bank instituion and continue full linkage.""" - country = ( - self.journal_id.bank_account_id.company_id or self.journal_id.company_id - ).country_id + country = self.gocardless_country_id response, data = self._gocardless_request( "institutions", params={"country": country.code} ) diff --git a/account_statement_import_online_gocardless/view/online_bank_statement_provider.xml b/account_statement_import_online_gocardless/view/online_bank_statement_provider.xml index 07b200ef..602bfade 100644 --- a/account_statement_import_online_gocardless/view/online_bank_statement_provider.xml +++ b/account_statement_import_online_gocardless/view/online_bank_statement_provider.xml @@ -16,6 +16,10 @@ > +