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

  1. # -*- coding: utf-8 -*-
  2. # noqa: This is a backport from Odoo. OCA has no control over style here.
  3. # flake8: noqa
  4. from openerp.tests.common import TransactionCase
  5. from openerp.modules.module import get_module_resource
  6. class TestQifFile(TransactionCase):
  7. """Tests for import bank statement qif file format (account.bank.statement.import)
  8. """
  9. def setUp(self):
  10. super(TestQifFile, self).setUp()
  11. self.statement_import_model = self.registry('account.bank.statement.import')
  12. self.bank_statement_model = self.registry('account.bank.statement')
  13. self.bank_statement_line_model = self.registry('account.bank.statement.line')
  14. def test_qif_file_import(self):
  15. from openerp.tools import float_compare
  16. cr, uid = self.cr, self.uid
  17. qif_file_path = get_module_resource('account_bank_statement_import_qif', 'test_qif_file', 'test_qif.qif')
  18. qif_file = open(qif_file_path, 'rb').read().encode('base64')
  19. bank_statement_id = self.statement_import_model.create(cr, uid, dict(
  20. data_file=qif_file,
  21. ))
  22. context = {
  23. 'journal_id': self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'bank_journal')[1],
  24. 'allow_auto_create_journal': True,
  25. }
  26. self.statement_import_model.import_file(cr, uid, [bank_statement_id], context=context)
  27. line_id = self.bank_statement_line_model.search(cr, uid, [('name', '=', 'YOUR LOCAL SUPERMARKET')])[0]
  28. statement_id = self.bank_statement_line_model.browse(cr, uid, line_id).statement_id.id
  29. bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id)
  30. assert float_compare(bank_st_record.balance_end_real, -1896.09, 2) == 0