You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.7 KiB
33 lines
1.7 KiB
# -*- coding: utf-8 -*-
|
|
# noqa: This is a backport from Odoo. OCA has no control over style here.
|
|
# flake8: noqa
|
|
from openerp.tests.common import TransactionCase
|
|
from openerp.modules.module import get_module_resource
|
|
|
|
class TestQifFile(TransactionCase):
|
|
"""Tests for import bank statement qif file format (account.bank.statement.import)
|
|
"""
|
|
|
|
def setUp(self):
|
|
super(TestQifFile, self).setUp()
|
|
self.statement_import_model = self.registry('account.bank.statement.import')
|
|
self.bank_statement_model = self.registry('account.bank.statement')
|
|
self.bank_statement_line_model = self.registry('account.bank.statement.line')
|
|
|
|
def test_qif_file_import(self):
|
|
from openerp.tools import float_compare
|
|
cr, uid = self.cr, self.uid
|
|
qif_file_path = get_module_resource('account_bank_statement_import_qif', 'test_qif_file', 'test_qif.qif')
|
|
qif_file = open(qif_file_path, 'rb').read().encode('base64')
|
|
bank_statement_id = self.statement_import_model.create(cr, uid, dict(
|
|
data_file=qif_file,
|
|
))
|
|
context = {
|
|
'journal_id': self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'bank_journal')[1],
|
|
'allow_auto_create_journal': True,
|
|
}
|
|
self.statement_import_model.import_file(cr, uid, [bank_statement_id], context=context)
|
|
line_id = self.bank_statement_line_model.search(cr, uid, [('name', '=', 'YOUR LOCAL SUPERMARKET')])[0]
|
|
statement_id = self.bank_statement_line_model.browse(cr, uid, line_id).statement_id.id
|
|
bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id)
|
|
assert float_compare(bank_st_record.balance_end_real, -1896.09, 2) == 0
|