From bf8bf2eb9c2bd97a238babce052f51079ad48c74 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 10 Aug 2022 00:01:53 +0200 Subject: [PATCH] [ADD] module account_statement_import_file_reconciliation_widget account_statement_import_file_reconciliation_widget is a glue auto-install module between account_statement_import (will be renamed account_statement_import_file in v16) and account_reconciliation_widget. --- .../wizard/account_statement_import.py | 47 +++++++------------ .../wizard/account_statement_import_view.xml | 6 +-- .../views/account_bank_statement_line.xml | 10 ---- 3 files changed, 21 insertions(+), 42 deletions(-) diff --git a/account_statement_import/wizard/account_statement_import.py b/account_statement_import/wizard/account_statement_import.py index 03f19722..de91ab2e 100644 --- a/account_statement_import/wizard/account_statement_import.py +++ b/account_statement_import/wizard/account_statement_import.py @@ -23,9 +23,7 @@ class AccountStatementImport(models.TransientModel): ) statement_filename = fields.Char() - def import_file_button(self): - """Process the file chosen in the wizard, create bank statement(s) - and return an action.""" + def _import_file(self): self.ensure_one() result = { "statement_ids": [], @@ -43,34 +41,25 @@ class AccountStatementImport(models.TransientModel): ) ) self.env["ir.attachment"].create(self._prepare_create_attachment(result)) - if self.env.context.get("return_regular_interface_action"): - action = ( - self.env.ref("account.action_bank_statement_tree").sudo().read([])[0] + return result + + def import_file_button(self): + """Process the file chosen in the wizard, create bank statement(s) + and return an action.""" + result = self._import_file() + action = self.env["ir.actions.actions"]._for_xml_id( + "account.action_bank_statement_tree" + ) + if len(result["statement_ids"]) == 1: + action.update( + { + "view_mode": "form,tree", + "views": False, + "res_id": result["statement_ids"][0], + } ) - if len(result["statement_ids"]) == 1: - action.update( - { - "view_mode": "form,tree", - "views": False, - "res_id": result["statement_ids"][0], - } - ) - else: - action["domain"] = [("id", "in", result["statement_ids"])] else: - # dispatch to reconciliation interface - lines = self.env["account.bank.statement.line"].search( - [("statement_id", "in", result["statement_ids"])] - ) - action = { - "type": "ir.actions.client", - "tag": "bank_statement_reconciliation_view", - "context": { - "statement_line_ids": lines.ids, - "company_ids": self.env.user.company_ids.ids, - "notifications": result["notifications"], - }, - } + action["domain"] = [("id", "in", result["statement_ids"])] return action def _prepare_create_attachment(self, result): diff --git a/account_statement_import/wizard/account_statement_import_view.xml b/account_statement_import/wizard/account_statement_import_view.xml index a5cdcb25..e1a273fd 100644 --- a/account_statement_import/wizard/account_statement_import_view.xml +++ b/account_statement_import/wizard/account_statement_import_view.xml @@ -21,11 +21,11 @@ diff --git a/account_statement_import_base/views/account_bank_statement_line.xml b/account_statement_import_base/views/account_bank_statement_line.xml index f2067d07..090816e9 100644 --- a/account_statement_import_base/views/account_bank_statement_line.xml +++ b/account_statement_import_base/views/account_bank_statement_line.xml @@ -21,16 +21,6 @@ 1 - - - 1 - 1