diff --git a/account_bank_statement_import_bypass_check/README.rst b/account_bank_statement_import_bypass_check/README.rst new file mode 100644 index 0000000..678d469 --- /dev/null +++ b/account_bank_statement_import_bypass_check/README.rst @@ -0,0 +1,86 @@ +================================== +Bypass check Bank statement import +================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github + :target: https://github.com/OCA/bank-statement-import/tree/12.0/account_bank_statement_import_bypass_check + :alt: OCA/bank-statement-import +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/bank-statement-import-12-0/bank-statement-import-12-0-account_bank_statement_import_bypass_check + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/174/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a check button to bypass the check if account of this statement is not the same as the journal. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to Accounting > Dashboard. +#. On one bank click button "Import". +#. Upload on statement file. +#. Click button "Import". +#. If account of this statement is not the same as the journal in your file: +#. You have error message printed in the wizard + the possibility do force the import. +#. You can check the boolean field and retry the import if you want. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* `Camptoamp `_: + + * Thomas Nowicki + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/bank-statement-import `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_bank_statement_import_bypass_check/__init__.py b/account_bank_statement_import_bypass_check/__init__.py new file mode 100644 index 0000000..4027237 --- /dev/null +++ b/account_bank_statement_import_bypass_check/__init__.py @@ -0,0 +1 @@ +from . import wizard diff --git a/account_bank_statement_import_bypass_check/__manifest__.py b/account_bank_statement_import_bypass_check/__manifest__.py new file mode 100644 index 0000000..20dfab9 --- /dev/null +++ b/account_bank_statement_import_bypass_check/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Bypass check Bank statement import', + 'version': '12.0.1.0.0', + 'category': 'Accounting', + 'summary': 'Allow possibility to bypass check in Bank statement import', + 'author': 'Camptocamp, ' + 'Odoo Community Association (OCA)', + 'maintainer': 'Camptocamp', + 'website': 'https://github.com/OCA/bank-statement-import', + 'depends': [ + 'account_bank_statement_import', + ], + 'data': [ + 'wizard/account_bank_statement_import_view.xml', + ], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, +} diff --git a/account_bank_statement_import_bypass_check/i18n/fr.po b/account_bank_statement_import_bypass_check/i18n/fr.po new file mode 100644 index 0000000..d40ce2c --- /dev/null +++ b/account_bank_statement_import_bypass_check/i18n/fr.po @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_bypass_check +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-12 10:54+0000\n" +"PO-Revision-Date: 2019-12-12 10:54+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_bank_statement_import_bypass_check +#: model:ir.model.fields,field_description:account_bank_statement_import_bypass_check.field_account_bank_statement_import__force_journal +msgid "Do you want to force this import ?" +msgstr "Voulez-vous forcer cet import ?" + +#. module: account_bank_statement_import_bypass_check +#: model:ir.model,name:account_bank_statement_import_bypass_check.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Import d'un relevé bancaire" diff --git a/account_bank_statement_import_bypass_check/readme/CONTRIBUTORS.rst b/account_bank_statement_import_bypass_check/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..257b6f3 --- /dev/null +++ b/account_bank_statement_import_bypass_check/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Camptoamp `_: + + * Thomas Nowicki diff --git a/account_bank_statement_import_bypass_check/readme/DESCRIPTION.rst b/account_bank_statement_import_bypass_check/readme/DESCRIPTION.rst new file mode 100644 index 0000000..246e036 --- /dev/null +++ b/account_bank_statement_import_bypass_check/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds a check button to bypass the check if account of this statement is not the same as the journal. diff --git a/account_bank_statement_import_bypass_check/readme/USAGE.rst b/account_bank_statement_import_bypass_check/readme/USAGE.rst new file mode 100644 index 0000000..fb365f4 --- /dev/null +++ b/account_bank_statement_import_bypass_check/readme/USAGE.rst @@ -0,0 +1,7 @@ +#. Go to Accounting > Dashboard. +#. On one bank click button "Import". +#. Upload on statement file. +#. Click button "Import". +#. If account of this statement is not the same as the journal in your file: +#. You have error message printed in the wizard + the possibility do force the import. +#. You can check the boolean field and retry the import if you want. diff --git a/account_bank_statement_import_bypass_check/wizard/__init__.py b/account_bank_statement_import_bypass_check/wizard/__init__.py new file mode 100644 index 0000000..7dafcd1 --- /dev/null +++ b/account_bank_statement_import_bypass_check/wizard/__init__.py @@ -0,0 +1 @@ +from . import account_bank_statement_import diff --git a/account_bank_statement_import_bypass_check/wizard/account_bank_statement_import.py b/account_bank_statement_import_bypass_check/wizard/account_bank_statement_import.py new file mode 100644 index 0000000..6a470b0 --- /dev/null +++ b/account_bank_statement_import_bypass_check/wizard/account_bank_statement_import.py @@ -0,0 +1,56 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import base64 +import logging + +from odoo import api, fields, models +from odoo.exceptions import UserError + +_logger = logging.getLogger(__name__) + + +class AccountBankStatementImport(models.TransientModel): + _inherit = "account.bank.statement.import" + + check_journal = fields.Boolean(default=True) + check_message = fields.Char(readonly=True) + force_journal = fields.Boolean( + string="Do you want to force this import ?", default=False + ) + + @api.multi + def import_file(self): + """ Override to make the import in 2 step. + + To provide to user possiblity to bypass the journal check. + """ + self.ensure_one() + currency_code, account_number, stmts_vals = self.with_context( + active_id=self.ids[0] + )._parse_file(base64.b64decode(self.data_file)) + if self.check_journal: + try: + self._find_additional_data(currency_code, account_number) + # _find_additional_data() call _check_journal_bank_account() + # so the self.check_journal value can evolve + except UserError as u_error: + if not self.check_journal: + msg = u_error.args[0] + _logger.info(msg) + self.check_message = str(msg) + action = self.env.ref( + "account_bank_statement_import." + "action_account_bank_statement_import" + ).read([])[0] + action["res_id"] = self.id + return action + return super().import_file() + + def _check_journal_bank_account(self, journal, account_number): + check = super()._check_journal_bank_account(journal, account_number) + if self.check_journal: + self.check_journal = False + if self.force_journal: + return True + return check diff --git a/account_bank_statement_import_bypass_check/wizard/account_bank_statement_import_view.xml b/account_bank_statement_import_bypass_check/wizard/account_bank_statement_import_view.xml new file mode 100644 index 0000000..26da3e6 --- /dev/null +++ b/account_bank_statement_import_bypass_check/wizard/account_bank_statement_import_view.xml @@ -0,0 +1,24 @@ + + + + + account.bank.statement.import.view + account.bank.statement.import + + + + + + + + + + + + + + +