diff --git a/__init__.py b/__init__.py index ca56a2a..eca81a7 100644 --- a/__init__.py +++ b/__init__.py @@ -7,9 +7,11 @@ from trytond.pool import Pool from .category import Category from .book import Book from .qiftool import QifTool -from .qif_import_wiz import ImportQifWizard, ImportQifWizardStart, ImportQifWizardInfo +from .qif_import_wiz import ( + ImportQifWizard, ImportQifWizardStart, ImportQifWizardInfo) from .qif_export import QifCategoryExport, QifBookExport + def register(): Pool.register( QifTool, diff --git a/qif_import_wiz.py b/qif_import_wiz.py index c72d1a8..d79f927 100644 --- a/qif_import_wiz.py +++ b/qif_import_wiz.py @@ -24,8 +24,7 @@ class ImportQifWizardStart(ModelView): string='Cashbook', readonly=True, model_name='cashbook.book', states={ - 'invisible': ~Bool(Eval('book')), - }) + 'invisible': ~Bool(Eval('book'))}) file_ = fields.Binary( string="QIF-File", required=True, help='Quicken Interchange Format') @@ -47,8 +46,7 @@ class ImportQifWizardInfo(ModelView): book = fields.Many2One( string='Cash Book', readonly=True, model_name='cashbook.book', states={ - 'invisible': ~Bool(Eval('book')), - }) + 'invisible': ~Bool(Eval('book'))}) allowimport = fields.Boolean( string='Import Enabled', states={'invisible': True}) @@ -69,8 +67,7 @@ class ImportQifWizard(Wizard): Button(string='Cancel', state='end', icon='tryton-cancel'), Button( string='Read File', state='readf', - icon='tryton-forward', default=True), - ]) + icon='tryton-forward', default=True)]) showinfo = StateView( model_name='cashbook_dataexchange.qif_imp_wiz.info', view='cashbook_dataexchange.qif_imp_wiz_info_form', @@ -79,10 +76,7 @@ class ImportQifWizard(Wizard): Button( string='Import Data', state='importf', icon='tryton-import', default=True, - states={ - 'readonly': Eval('allowimport', False) == False, - }), - ]) + states={'readonly': ~Eval('allowimport', False)})]) readf = StateTransition() importf = StateTransition() @@ -94,8 +88,7 @@ class ImportQifWizard(Wizard): values = { 'company': Transaction().context.get('company'), - 'book': None, - } + 'book': None} model = context.get('active_model', '') if model == 'cashbook.book': @@ -170,8 +163,7 @@ class ImportQifWizard(Wizard): ['%s (in)' % x for x in in_categories] + [''] + ['%s (out)' % x for x in out_categories] - ) - ) + )) if len(to_create) > 0: self.showinfo.allowimport = True else: @@ -182,8 +174,7 @@ class ImportQifWizard(Wizard): qif_content = QifTool.split_by_type(file_content) if 'Bank' in qif_content.keys(): to_create = QifTool.convert_parties_to_create( - QifTool.qif_read_transactions(qif_content['Bank']) - ) + QifTool.qif_read_transactions(qif_content['Bank'])) self.showinfo.info = gettext( 'cashbook_dataexchange.msg_wiz_parties_found', numparties=len(to_create), @@ -266,8 +257,7 @@ class ImportQifWizard(Wizard): Book.create_from_qif(self.showinfo.book, file_content) lines = Line.search([ ('cashbook.id', '=', self.showinfo.book.id), - ('state', '=', 'edit'), - ]) + ('state', '=', 'edit')]) if len(lines) > 0: Line.wfcheck(lines) elif model == 'party.party': diff --git a/tests/category.py b/tests/category.py index 7d8d775..fdbd2a6 100644 --- a/tests/category.py +++ b/tests/category.py @@ -21,7 +21,8 @@ class CategoryTestCase(object): """ pool = Pool() Category = pool.get('cashbook.category') - ImportWiz = pool.get('cashbook_dataexchange.qif_imp_wiz', type='wizard') + ImportWiz = pool.get( + 'cashbook_dataexchange.qif_imp_wiz', type='wizard') company = self.prep_company() with Transaction().set_context({ @@ -358,7 +359,8 @@ I 'bookingtype': 'mvout', 'booktransf': books[1].id, 'description': - 'GA NR00002168 BLZ10000000 0; 05.12/06.42UHR TT TELTOW', + 'GA NR00002168 BLZ10000000 0; 05.12/06.42UHR ' + + 'TT TELTOW', }, { 'date': date(2013, 12, 5), 'amount': Decimal('56.37'), @@ -475,7 +477,8 @@ I result = QifTool.qif_read_categories( 'NGehalt\nI\n^\nNGehalt:Zulagen\nI\n^' + - 'NTelekommunikation\nE\n^\nNTelekommunikation:Online-Dienste\nE\n^') + 'NTelekommunikation\nE\n^\nNTelekommunikation:' + + 'Online-Dienste\nE\n^') self.assertEqual(result, { 'in': { 'Gehalt': { diff --git a/tests/party.py b/tests/party.py index 418c816..4a6f113 100644 --- a/tests/party.py +++ b/tests/party.py @@ -19,7 +19,8 @@ class PartyTestCase(object): """ pool = Pool() Party = pool.get('party.party') - ImportWiz = pool.get('cashbook_dataexchange.qif_imp_wiz', type='wizard') + ImportWiz = pool.get( + 'cashbook_dataexchange.qif_imp_wiz', type='wizard') company = self.prep_company() with Transaction().set_context({ @@ -45,8 +46,9 @@ class PartyTestCase(object): self.assertEqual(list(result.keys()), ['view']) self.assertEqual(result['view']['defaults']['company'], company.id) - self.assertEqual(result['view']['defaults']['info'], -"""The following 3 parties are now imported:\n + self.assertEqual( + result['view']['defaults']['info'], + """The following 3 parties are now imported:\n Opening Balance GA NR00002168 BLZ10000000 0 Foodshop Zehlendorf""") @@ -61,7 +63,8 @@ Foodshop Zehlendorf""") self.assertEqual(len(records), 4) self.assertEqual(records[0].rec_name, 'Foodshop Zehlendorf') - self.assertEqual(records[1].rec_name, 'GA NR00002168 BLZ10000000 0') + self.assertEqual( + records[1].rec_name, 'GA NR00002168 BLZ10000000 0') self.assertEqual(records[2].rec_name, 'm-ds') self.assertEqual(records[3].rec_name, 'Opening Balance') diff --git a/tests/transaction.py b/tests/transaction.py index eb5de30..b4448cf 100644 --- a/tests/transaction.py +++ b/tests/transaction.py @@ -84,7 +84,8 @@ class TransactionTestCase(object): Party = pool.get('party.party') Category = pool.get('cashbook.category') Book = pool.get('cashbook.book') - ImportWiz = pool.get('cashbook_dataexchange.qif_imp_wiz', type='wizard') + ImportWiz = pool.get( + 'cashbook_dataexchange.qif_imp_wiz', type='wizard') company = self.prep_company() with Transaction().set_context({ @@ -223,7 +224,8 @@ Mreturn of bottles Party = pool.get('party.party') Category = pool.get('cashbook.category') Book = pool.get('cashbook.book') - ImportWiz = pool.get('cashbook_dataexchange.qif_imp_wiz', type='wizard') + ImportWiz = pool.get( + 'cashbook_dataexchange.qif_imp_wiz', type='wizard') company = self.prep_company() with Transaction().set_context({