Browse Source

[MIG] account_bank_statement_import_qif: Migration to 11.0

* Metafiles updated
* Test adapted to Python 3
* Code adapted to Python 3
pull/129/head
Pedro M. Baeza 7 years ago
parent
commit
84b93bba8f
  1. 18
      account_bank_statement_import_qif/README.rst
  2. 1
      account_bank_statement_import_qif/__init__.py
  3. 5
      account_bank_statement_import_qif/__manifest__.py
  4. 3
      account_bank_statement_import_qif/tests/__init__.py
  5. 6
      account_bank_statement_import_qif/tests/test_import_bank_statement.py
  6. 1
      account_bank_statement_import_qif/wizards/__init__.py
  7. 10
      account_bank_statement_import_qif/wizards/account_bank_statement_import_qif.py

18
account_bank_statement_import_qif/README.rst

@ -26,14 +26,14 @@ Usage
To use this module, you need to:
#. Go to *Accounting* dashboard.
#. Go to *Invoicing / Accounting* dashboard.
#. Click on *Import statement* from any of the bank journals.
#. Select a QIF file.
#. Press *Import*.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/174/9.0
:target: https://runbot.odoo-community.org/runbot/174/11.0
Bug Tracker
===========
@ -50,11 +50,15 @@ Credits
Contributors
------------
* Odoo SA
* Alexis de Lattre <alexis@via.ecp.fr>
* Laurent Mignon <laurent.mignon@acsone.eu>
* Ronald Portier <rportier@therp.nl>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Odoo SA
* Akretion
* Alexis de Lattre <alexis@via.ecp.fr>
* ACSONE A/V
* Laurent Mignon <laurent.mignon@acsone.eu>
* Therp
* Ronald Portier <rportier@therp.nl>
* Tecnativa (https://www.tecnativa.com)
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
Maintainer
----------

1
account_bank_statement_import_qif/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import wizards

5
account_bank_statement_import_qif/__manifest__.py

@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Odoo S. A.
# Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu>
# Copyright 2015 Ronald Portier <rportier@therp.nl>
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2016-2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Import QIF Bank Statements',
'category': 'Accounting',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'author': 'OpenERP SA,'
'Tecnativa,'
'Odoo Community Association (OCA)',

3
account_bank_statement_import_qif/tests/__init__.py

@ -1,2 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_import_bank_statement

6
account_bank_statement_import_qif/tests/test_import_bank_statement.py

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Odoo S. A.
# Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu>
# Copyright 2015 Ronald Portier <rportier@therp.nl>
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2016-2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
from odoo.modules.module import get_module_resource
import base64
class TestQifFile(TransactionCase):
@ -32,7 +32,7 @@ class TestQifFile(TransactionCase):
qif_file_path = get_module_resource(
'account_bank_statement_import_qif', 'tests', 'test_qif.qif',
)
qif_file = open(qif_file_path, 'rb').read().encode('base64')
qif_file = base64.b64encode(open(qif_file_path, 'rb').read())
wizard = self.statement_import_model.with_context(
journal_id=self.journal.id
).create(

1
account_bank_statement_import_qif/wizards/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_bank_statement_import_qif

10
account_bank_statement_import_qif/wizards/account_bank_statement_import_qif.py

@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Odoo S. A.
# Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu>
# Copyright 2015 Ronald Portier <rportier@therp.nl>
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2016-2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import StringIO
import dateutil.parser
from odoo.tools.translate import _
@ -18,16 +16,14 @@ class AccountBankStatementImport(models.TransientModel):
@api.model
def _check_qif(self, data_file):
return data_file.strip().startswith('!Type:')
return data_file.strip().startswith(b'!Type:')
def _parse_file(self, data_file):
if not self._check_qif(data_file):
return super(AccountBankStatementImport, self)._parse_file(
data_file)
try:
file_data = ""
for line in StringIO.StringIO(data_file).readlines():
file_data += line
file_data = data_file.decode()
if '\r' in file_data:
data_list = file_data.split('\r')
else:

Loading…
Cancel
Save