[FIX] account_statement_import_online: further improvements.

This commit is contained in:
Ronald Portier
2021-07-14 11:40:50 +02:00
committed by Carolina Fernandez
parent bbdb843171
commit fe7adc1bdf
12 changed files with 164 additions and 101 deletions

View File

@@ -16,12 +16,16 @@ class AccountJournal(models.Model):
selection=lambda self: self.env[
"account.journal"
]._selection_online_bank_statement_provider(),
help="Select the type of service provider (a model)",
)
online_bank_statement_provider_id = fields.Many2one(
string="Statement Provider",
comodel_name="online.bank.statement.provider",
ondelete="restrict",
copy=False,
help="Select the actual instance of a configured provider (a record).\n"
"Selecting a type of provider will automatically create a provider"
" record linked to this journal.",
)
def __get_bank_statements_available_sources(self):
@@ -37,12 +41,14 @@ class AccountJournal(models.Model):
@api.model
def values_online_bank_statement_provider(self):
"""Return values for provider type selection in the form view."""
res = self.env["online.bank.statement.provider"]._get_available_services()
if self.user_has_groups("base.group_no_one"):
res += [("dummy", "Dummy")]
return res
def _update_online_bank_statement_provider_id(self):
"""Keep provider synchronized with journal."""
OnlineBankStatementProvider = self.env["online.bank.statement.provider"]
for journal in self.filtered("id"):
provider_id = journal.online_bank_statement_provider_id