+
-
-
-
-
-
-
-
+
-
-
-
-
+
+
@@ -102,5 +88,19 @@
+
+
+
+ Online Bank Statement Providers
+ online.bank.statement.provider
+ tree,form
+
+
+
diff --git a/account_statement_import_online/wizards/online_bank_statement_pull_wizard.py b/account_statement_import_online/wizards/online_bank_statement_pull_wizard.py
index 52225668..c9721cd7 100644
--- a/account_statement_import_online/wizards/online_bank_statement_pull_wizard.py
+++ b/account_statement_import_online/wizards/online_bank_statement_pull_wizard.py
@@ -2,7 +2,7 @@
# Copyright 2019-2020 Dataplug (https://dataplug.io)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-from odoo import fields, models
+from odoo import api, fields, models
class OnlineBankStatementPullWizard(models.TransientModel):
@@ -10,12 +10,12 @@ class OnlineBankStatementPullWizard(models.TransientModel):
_description = "Online Bank Statement Pull Wizard"
date_since = fields.Datetime(
- string="Since",
+ string="From",
required=True,
default=fields.Datetime.now,
)
date_until = fields.Datetime(
- string="Until",
+ string="To",
required=True,
default=fields.Datetime.now,
)
@@ -27,9 +27,34 @@ class OnlineBankStatementPullWizard(models.TransientModel):
relation="online_bank_statement_provider_pull_wizard_rel",
)
+ @api.model
+ def default_get(self, fields_list):
+ res = super().default_get(fields_list)
+ if self.env.context.get("active_model") == "account.journal":
+ if self.env.context.get("active_ids"):
+ journals = self.env["account.journal"].browse(
+ self.env.context["active_ids"]
+ )
+ res["provider_ids"] = journals.online_bank_statement_provider_id.ids
+ elif self.env.context.get("active_id"):
+ journal = self.env["account.journal"].browse(
+ self.env.context["active_id"]
+ )
+ res["provider_ids"] = [journal.online_bank_statement_provider_id.id]
+ return res
+
def action_pull(self):
self.ensure_one()
self.with_context(
active_test=False,
).provider_ids._pull(self.date_since, self.date_until)
- return {"type": "ir.actions.act_window_close"}
+ action = self.env.ref("account.action_bank_statement_tree").sudo().read([])[0]
+ if len(self.provider_ids) == 1:
+ action["context"] = {
+ "search_default_journal_id": self.provider_ids[0].journal_id.id
+ }
+ else:
+ action["domain"] = [
+ ("journal_id", "in", [o.journal_id.id for o in self.provider_ids])
+ ]
+ return action
diff --git a/account_statement_import_online/wizards/online_bank_statement_pull_wizard.xml b/account_statement_import_online/wizards/online_bank_statement_pull_wizard.xml
index 8e2bd625..a376900d 100644
--- a/account_statement_import_online/wizards/online_bank_statement_pull_wizard.xml
+++ b/account_statement_import_online/wizards/online_bank_statement_pull_wizard.xml
@@ -10,16 +10,10 @@
online.bank.statement.pull.wizard
+
+
+ Pull Online Bank Statement
+ online.bank.statement.pull.wizard
+ form
+ new
+
+