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. 16
      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

16
account_bank_statement_import_qif/README.rst

@ -26,14 +26,14 @@ Usage
To use this module, you need to: 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. #. Click on *Import statement* from any of the bank journals.
#. Select a QIF file. #. Select a QIF file.
#. Press *Import*. #. Press *Import*.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :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 Bug Tracker
=========== ===========
@ -51,10 +51,14 @@ Contributors
------------ ------------
* Odoo SA * 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>
* 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 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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import wizards 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 Odoo S. A.
# Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu> # Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu>
# Copyright 2015 Ronald Portier <rportier@therp.nl> # 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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
'name': 'Import QIF Bank Statements', 'name': 'Import QIF Bank Statements',
'category': 'Accounting', 'category': 'Accounting',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'author': 'OpenERP SA,' 'author': 'OpenERP SA,'
'Tecnativa,' 'Tecnativa,'
'Odoo Community Association (OCA)', '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 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 Odoo S. A.
# Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu> # Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu>
# Copyright 2015 Ronald Portier <rportier@therp.nl> # 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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase from odoo.tests.common import TransactionCase
from odoo.modules.module import get_module_resource from odoo.modules.module import get_module_resource
import base64
class TestQifFile(TransactionCase): class TestQifFile(TransactionCase):
@ -32,7 +32,7 @@ class TestQifFile(TransactionCase):
qif_file_path = get_module_resource( qif_file_path = get_module_resource(
'account_bank_statement_import_qif', 'tests', 'test_qif.qif', '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( wizard = self.statement_import_model.with_context(
journal_id=self.journal.id journal_id=self.journal.id
).create( ).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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_bank_statement_import_qif 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 Odoo S. A.
# Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu> # Copyright 2015 Laurent Mignon <laurent.mignon@acsone.eu>
# Copyright 2015 Ronald Portier <rportier@therp.nl> # 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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import StringIO
import dateutil.parser import dateutil.parser
from odoo.tools.translate import _ from odoo.tools.translate import _
@ -18,16 +16,14 @@ class AccountBankStatementImport(models.TransientModel):
@api.model @api.model
def _check_qif(self, data_file): 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): def _parse_file(self, data_file):
if not self._check_qif(data_file): if not self._check_qif(data_file):
return super(AccountBankStatementImport, self)._parse_file( return super(AccountBankStatementImport, self)._parse_file(
data_file) data_file)
try: try:
file_data = ""
for line in StringIO.StringIO(data_file).readlines():
file_data += line
file_data = data_file.decode()
if '\r' in file_data: if '\r' in file_data:
data_list = file_data.split('\r') data_list = file_data.split('\r')
else: else:

Loading…
Cancel
Save