[IMP] Backport from master at 04daefd2d101d90daf5782173b95f31f3bd9e1b6

This commit is contained in:
Laurent Mignon
2015-03-20 11:48:55 +01:00
committed by Alexis de Lattre
parent a2bfc4bb6a
commit 3a2a0839ce
4 changed files with 10 additions and 11 deletions

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
from . import account_bank_statement_import_ofx
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: import account_bank_statement_import_ofx

View File

@@ -25,9 +25,10 @@ base account_bank_statement_import module has been imported, or manually
create periods for the year 2013. create periods for the year 2013.
""", """,
'data' : [], 'data' : [],
'depends': ['account_bank_statement_import'],
'demo': [ 'demo': [
'demo/demo_data.xml', 'demo/demo_data.xml',
], ],
'auto_install': False, 'auto_install': True,
'installable': True, 'installable': True,
} }

View File

@@ -14,8 +14,7 @@ _logger = logging.getLogger(__name__)
try: try:
from ofxparse import OfxParser as ofxparser from ofxparse import OfxParser as ofxparser
except ImportError: except ImportError:
_logger.error("OFX parser unavailable because the `ofxparse` Python library cannot be found." _logger.warn("ofxparse not found, OFX parsing disabled.")
"It can be downloaded and installed from `https://pypi.python.org/pypi/ofxparse`.")
ofxparser = None ofxparser = None
class account_bank_statement_import(osv.TransientModel): class account_bank_statement_import(osv.TransientModel):
@@ -63,7 +62,7 @@ class account_bank_statement_import(osv.TransientModel):
vals_bank_statement = { vals_bank_statement = {
'name': ofx.account.routing_number, 'name': ofx.account.routing_number,
'transactions': transactions, 'transactions': transactions,
'balance_start': float(ofx.account.statement.balance) - total_amt, 'balance_start': ofx.account.statement.balance,
'balance_end_real': float(ofx.account.statement.balance), 'balance_end_real': float(ofx.account.statement.balance) + total_amt,
} }
return ofx.account.statement.currency, ofx.account.number, [vals_bank_statement] return ofx.account.statement.currency, ofx.account.number, [vals_bank_statement]

View File

@@ -25,8 +25,8 @@ class TestOfxFile(TransactionCase):
bank_statement_id = self.statement_import_model.create(cr, uid, dict( bank_statement_id = self.statement_import_model.create(cr, uid, dict(
data_file=ofx_file, data_file=ofx_file,
)) ))
self.statement_import_model.import_file(cr, uid, [bank_statement_id], {'allow_auto_create_journal': True}) self.statement_import_model.import_file(cr, uid, [bank_statement_id])
statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0] statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0]
bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id)
self.assertEquals(bank_st_record.balance_start, 2516.56) self.assertEquals(bank_st_record.balance_start, 2156.56)
self.assertEquals(bank_st_record.balance_end_real, 2156.56) self.assertEquals(bank_st_record.balance_end_real, 1796.56)