diff --git a/account_statement_import/wizard/account_statement_import.py b/account_statement_import/wizard/account_statement_import.py
index 604b91ca..d33d5a17 100644
--- a/account_statement_import/wizard/account_statement_import.py
+++ b/account_statement_import/wizard/account_statement_import.py
@@ -24,9 +24,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": [],
@@ -44,34 +42,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
diff --git a/account_statement_import_file_reconciliation_widget/README.rst b/account_statement_import_file_reconciliation_widget/README.rst
new file mode 100644
index 00000000..2627cab2
--- /dev/null
+++ b/account_statement_import_file_reconciliation_widget/README.rst
@@ -0,0 +1 @@
+Will be auto-generated from the readme subdir
diff --git a/account_statement_import_file_reconciliation_widget/__init__.py b/account_statement_import_file_reconciliation_widget/__init__.py
new file mode 100644
index 00000000..5cb1c491
--- /dev/null
+++ b/account_statement_import_file_reconciliation_widget/__init__.py
@@ -0,0 +1 @@
+from . import wizards
diff --git a/account_statement_import_file_reconciliation_widget/__manifest__.py b/account_statement_import_file_reconciliation_widget/__manifest__.py
new file mode 100644
index 00000000..e236c0cf
--- /dev/null
+++ b/account_statement_import_file_reconciliation_widget/__manifest__.py
@@ -0,0 +1,19 @@
+# Copyright 2022 Akretion France (http://www.akretion.com/)
+# @author: Alexis de Lattre
+# Licence AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).
+
+{
+ "name": "Import Statement Files and Go Direct to Reconciliation",
+ "category": "Accounting",
+ "version": "14.0.1.0.0",
+ "license": "AGPL-3",
+ "depends": ["account_statement_import", "account_reconciliation_widget"],
+ "author": "Akretion, Odoo Community Association (OCA)",
+ "maintainers": ["alexis-via"],
+ "website": "https://github.com/OCA/bank-statement-import",
+ "data": [
+ "wizards/account_statement_import_view.xml",
+ ],
+ "installable": True,
+ "auto_install": True,
+}
diff --git a/account_statement_import_file_reconciliation_widget/readme/CONTRIBUTORS.rst b/account_statement_import_file_reconciliation_widget/readme/CONTRIBUTORS.rst
new file mode 100644
index 00000000..ff65d68c
--- /dev/null
+++ b/account_statement_import_file_reconciliation_widget/readme/CONTRIBUTORS.rst
@@ -0,0 +1 @@
+* Alexis de Lattre
diff --git a/account_statement_import_file_reconciliation_widget/readme/DESCRIPTION.rst b/account_statement_import_file_reconciliation_widget/readme/DESCRIPTION.rst
new file mode 100644
index 00000000..47a81a79
--- /dev/null
+++ b/account_statement_import_file_reconciliation_widget/readme/DESCRIPTION.rst
@@ -0,0 +1,9 @@
+This module is a glue module between 2 modules:
+
+* **account_statement_import** from `OCA/bank-statement-import `_
+* **account_reconciliation_widget** from `OCA/account-reconcile `_
+
+This module adds a button **Import and Start to Reconcile** on the bank statement file import wizard. When you click on this button, Odoo will import the bank statement file and jump directly to the special reconciliation interface.
+
+.. figure:: ../static/description/bank_statement_import_start_reconcile.png
+ :alt: Bank statement import wizard screenshot
diff --git a/account_statement_import_file_reconciliation_widget/readme/INSTALL.rst b/account_statement_import_file_reconciliation_widget/readme/INSTALL.rst
new file mode 100644
index 00000000..f9b5bb0d
--- /dev/null
+++ b/account_statement_import_file_reconciliation_widget/readme/INSTALL.rst
@@ -0,0 +1 @@
+This module will be installed automatically by Odoo if the modules **account_statement_import** and **account_reconciliation_widget** are installed.
diff --git a/account_statement_import_file_reconciliation_widget/static/description/bank_statement_import_start_reconcile.png b/account_statement_import_file_reconciliation_widget/static/description/bank_statement_import_start_reconcile.png
new file mode 100644
index 00000000..292d12e6
Binary files /dev/null and b/account_statement_import_file_reconciliation_widget/static/description/bank_statement_import_start_reconcile.png differ
diff --git a/account_statement_import_file_reconciliation_widget/wizards/__init__.py b/account_statement_import_file_reconciliation_widget/wizards/__init__.py
new file mode 100644
index 00000000..ae69bca2
--- /dev/null
+++ b/account_statement_import_file_reconciliation_widget/wizards/__init__.py
@@ -0,0 +1 @@
+from . import account_statement_import
diff --git a/account_statement_import_file_reconciliation_widget/wizards/account_statement_import.py b/account_statement_import_file_reconciliation_widget/wizards/account_statement_import.py
new file mode 100644
index 00000000..415a9b96
--- /dev/null
+++ b/account_statement_import_file_reconciliation_widget/wizards/account_statement_import.py
@@ -0,0 +1,26 @@
+# Copyright 2022 Akretion France (http://www.akretion.com/)
+# @author: Alexis de Lattre
+# Licence AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).
+
+from odoo import models
+
+
+class AccountStatementImport(models.TransientModel):
+ _inherit = "account.statement.import"
+
+ def import_file_and_reconcile_button(self):
+ """Process the file chosen in the wizard, create bank statement(s)
+ and jump directly to the reconcilition widget"""
+ result = self._import_file()
+ statements = self.env["account.bank.statement"].browse(result["statement_ids"])
+ statements.button_post()
+ action = {
+ "type": "ir.actions.client",
+ "tag": "bank_statement_reconciliation_view",
+ "context": {
+ "statement_line_ids": statements.line_ids.ids,
+ "company_ids": statements.company_id.ids,
+ "notifications": result["notifications"],
+ },
+ }
+ return action
diff --git a/account_statement_import_file_reconciliation_widget/wizards/account_statement_import_view.xml b/account_statement_import_file_reconciliation_widget/wizards/account_statement_import_view.xml
new file mode 100644
index 00000000..477cdb71
--- /dev/null
+++ b/account_statement_import_file_reconciliation_widget/wizards/account_statement_import_view.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+ account.statement.import
+
+
+
+
+
+
+
diff --git a/setup/account_statement_import_file_reconciliation_widget/odoo/addons/account_statement_import_file_reconciliation_widget b/setup/account_statement_import_file_reconciliation_widget/odoo/addons/account_statement_import_file_reconciliation_widget
new file mode 120000
index 00000000..c288a19a
--- /dev/null
+++ b/setup/account_statement_import_file_reconciliation_widget/odoo/addons/account_statement_import_file_reconciliation_widget
@@ -0,0 +1 @@
+../../../../account_statement_import_file_reconciliation_widget
\ No newline at end of file
diff --git a/setup/account_statement_import_file_reconciliation_widget/setup.py b/setup/account_statement_import_file_reconciliation_widget/setup.py
new file mode 100644
index 00000000..28c57bb6
--- /dev/null
+++ b/setup/account_statement_import_file_reconciliation_widget/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+ setup_requires=['setuptools-odoo'],
+ odoo_addon=True,
+)