From 54a39ac1b1ef5ebe7071afccdf3a25e097f70833 Mon Sep 17 00:00:00 2001 From: "dle@openerp.com" <> Date: Mon, 10 Dec 2012 13:55:17 +0100 Subject: [PATCH] [ADD]Missing py bzr revid: dle@openerp.com-20121210125517-z4ehmco5dkmdxhmf --- addons/l10n_be_coda/l10n_be_coda.py | 42 +++++++++++++++++++ .../wizard/account_coda_import.py | 16 ++++++- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 addons/l10n_be_coda/l10n_be_coda.py diff --git a/addons/l10n_be_coda/l10n_be_coda.py b/addons/l10n_be_coda/l10n_be_coda.py new file mode 100644 index 00000000000..13b67e76bfd --- /dev/null +++ b/addons/l10n_be_coda/l10n_be_coda.py @@ -0,0 +1,42 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# +# Copyright (c) 2011 Noviat nv/sa (www.noviat.be). All rights reserved. +# +# 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 osv import osv, fields + + +class account_bank_statement(osv.osv): + _inherit = 'account.bank.statement' + _columns = { + 'coda_note': fields.text('CODA Notes'), + } + + +class res_bank(osv.osv): + _inherit = 'res.partner.bank' + _columns = { + 'balance_start_enforce': fields.boolean('Prevent invalid Opening Balances', + help="Do not process Statements with an Opening Balance that doesn't match the previous Closing Balance."), + } + +account_bank_statement() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_be_coda/wizard/account_coda_import.py b/addons/l10n_be_coda/wizard/account_coda_import.py index d27b28c315c..671a0a93335 100644 --- a/addons/l10n_be_coda/wizard/account_coda_import.py +++ b/addons/l10n_be_coda/wizard/account_coda_import.py @@ -94,9 +94,12 @@ class account_coda_import(osv.osv_memory): if bank_ids and len(bank_ids) > 0: bank_accs = self.pool.get('res.partner.bank').browse(cr, uid, bank_ids) for bank_acc in bank_accs: - statement['journal_id'] = bank_acc.journal_id - if (statement['journal_id'].currency and statement['journal_id'].currency.name != statement['currency']) and (not statement['journal_id'].currency and statement['journal_id'].company_id.currency_id.name != statement['currency']): + if (bank_acc.journal_id.currency and bank_acc.journal_id.currency.name != statement['currency']) and (not bank_acc.journal_id.currency and bank_acc.journal_id.company_id.currency_id.name != statement['currency']): raise not_found_except + else: + statement['journal_id'] = bank_acc.journal_id + statement['bank_account'] = bank_acc + break else: raise not_found_except statement['description'] = rmspaces(line[90:125]) @@ -225,6 +228,15 @@ class account_coda_import(osv.osv_memory): if not statement['balance_end_real']: statement['balance_end_real'] = statement['balance_start'] + statement['balancePlus'] - statement['balanceMin'] for i, statement in enumerate(statements): + balance_start_check_date = (len(statement['lines']) > 0 and statement['lines'][0]['entryDate']) or statement['date'] + cr.execute('SELECT balance_end_real \ + FROM account_bank_statement \ + WHERE journal_id = %s and date <= %s \ + ORDER BY date DESC,id DESC LIMIT 1', (statement['journal_id'].id, balance_start_check_date)) + print statement['bank_account'].balance_start_enforce + res = cr.fetchone() + balance_start_check = res and res[0] + print balance_start_check statement['coda_note'] = '' data = { 'name': '[' + statement['date'] + ']' + statement['description'],