[ADD]Missing py

bzr revid: dle@openerp.com-20121210125517-z4ehmco5dkmdxhmf
This commit is contained in:
dle@openerp.com 2012-12-10 13:55:17 +01:00
parent 07527e1503
commit 54a39ac1b1
2 changed files with 56 additions and 2 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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:

View File

@ -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'],