diff --git a/account_bank_statement_import_usability/__init__.py b/account_bank_statement_import_usability/__init__.py new file mode 100644 index 0000000..f8b18f0 --- /dev/null +++ b/account_bank_statement_import_usability/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import account_bank_statement_import diff --git a/account_bank_statement_import_usability/__openerp__.py b/account_bank_statement_import_usability/__openerp__.py new file mode 100644 index 0000000..c37e7e3 --- /dev/null +++ b/account_bank_statement_import_usability/__openerp__.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Account Bank Statement Import Usability module for Odoo +# Copyright (C) 2015 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'Account Bank Statement Import Usability', + 'version': '0.1', + 'category': 'Accounting & Finance', + 'license': 'AGPL-3', + 'summary': 'Small usability enhancements in account_bank_statement_import module', + 'description': """ +Account Bank Statement Import Usability +======================================= + +Blocks the *Automagically create bank account*, because it's too dangerous : it creates new bank accounts and new account journal... and the user doesn't even realize that ! + +This module has been written by Alexis de Lattre from Akretion . + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['account_bank_statement_import'], + 'installable': True, +} diff --git a/account_bank_statement_import_usability/account_bank_statement_import.py b/account_bank_statement_import_usability/account_bank_statement_import.py new file mode 100644 index 0000000..871bf99 --- /dev/null +++ b/account_bank_statement_import_usability/account_bank_statement_import.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Account Bank Statement Import Usability module for Odoo +# Copyright (C) 2015 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, api, _ +from openerp.exceptions import Warning as UserError + + +class AccountBankStatementImport(models.TransientModel): + """Extend model account.bank.statement.""" + _inherit = 'account.bank.statement.import' + + @api.model + @api.returns('res.partner.bank') + def _create_bank_account( + self, account_number, company_id=False, currency_id=False): + raise UserError(_( + "The bank account corresponding to this file " + "is not one of the company's bank accounts in Odoo")) + + @api.model + def _find_bank_account_id(self, account_number): + """ Get res.partner.bank ID """ + bank_account_id = None + if account_number and len(account_number) > 4: + self._cr.execute("select id from res_partner_bank where replace(replace(acc_number,' ',''),'-','') like %s and journal_id is not null", ('%' + account_number + '%',)) + bank_account_ids = [id[0] for id in self._cr.fetchall()] + if bank_account_ids: + bank_account_id = bank_account_ids[0] + return bank_account_id