From 4880cda696b91c6ebc5b4ae9c47b8ad58618740c Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 23 Mar 2017 11:05:47 +0100 Subject: [PATCH] [ADD] allow turning off automatic reconciliation during an import --- .../README.rst | 1 - .../__openerp__.py | 1 + .../models/account_bank_statement_import.py | 10 +++++++++- .../views/account_bank_statement_import.xml | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 account_bank_statement_import_auto_reconcile/views/account_bank_statement_import.xml diff --git a/account_bank_statement_import_auto_reconcile/README.rst b/account_bank_statement_import_auto_reconcile/README.rst index 33f9098..5317550 100644 --- a/account_bank_statement_import_auto_reconcile/README.rst +++ b/account_bank_statement_import_auto_reconcile/README.rst @@ -39,7 +39,6 @@ Known issues / Roadmap * AmountTransposedDigits (reconcile if only two digits are swapped. Dangerous and a special case of AmountDiffuse) * whatever else we can think of * add some helpers/examples for using the options field -* allow to turn off automatic reconciliations during a specific import * allow to fiddle with the parameters of configured rules during a specific import Bug Tracker diff --git a/account_bank_statement_import_auto_reconcile/__openerp__.py b/account_bank_statement_import_auto_reconcile/__openerp__.py index f7ffc31..e3ceef2 100644 --- a/account_bank_statement_import_auto_reconcile/__openerp__.py +++ b/account_bank_statement_import_auto_reconcile/__openerp__.py @@ -14,6 +14,7 @@ 'web_widget_one2many_tags', ], "data": [ + "views/account_bank_statement_import.xml", "views/account_journal.xml", "views/account_bank_statement_import_auto_reconcile_rule.xml", 'security/ir.model.access.csv', diff --git a/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py b/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py index 740774a..ad990ed 100644 --- a/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py +++ b/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- # © 2017 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import _, api, models +from openerp import _, api, fields, models class AccountBankStatementImport(models.TransientModel): _inherit = 'account.bank.statement.import' + auto_reconcile = fields.Boolean('Auto reconcile', default=True) + @api.model def _create_bank_statement(self, stmt_vals): statement_id, notifications = super( @@ -15,6 +17,12 @@ class AccountBankStatementImport(models.TransientModel): if not statement_id: return statement_id, notifications statement = self.env['account.bank.statement'].browse(statement_id) + if ( + not statement.journal_id + .statement_import_auto_reconcile_rule_ids or + not self.auto_reconcile + ): + return statement_id, notifications reconcile_rules = statement.journal_id\ .statement_import_auto_reconcile_rule_ids.mapped( lambda x: self.env[x.rule_type].new({ diff --git a/account_bank_statement_import_auto_reconcile/views/account_bank_statement_import.xml b/account_bank_statement_import_auto_reconcile/views/account_bank_statement_import.xml new file mode 100644 index 0000000..290956e --- /dev/null +++ b/account_bank_statement_import_auto_reconcile/views/account_bank_statement_import.xml @@ -0,0 +1,15 @@ + + + + + account.bank.statement.import + + + + + + + + +