formatting
This commit is contained in:
parent
40d3a9e825
commit
900c2b975c
6 changed files with 63 additions and 63 deletions
|
@ -7,9 +7,11 @@ from trytond.pool import Pool
|
||||||
from .category import Category
|
from .category import Category
|
||||||
from .book import Book
|
from .book import Book
|
||||||
from .qiftool import QifTool
|
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
|
from .qif_export import QifCategoryExport, QifBookExport
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
QifTool,
|
QifTool,
|
||||||
|
|
|
@ -24,8 +24,7 @@ class ImportQifWizardStart(ModelView):
|
||||||
string='Cashbook', readonly=True,
|
string='Cashbook', readonly=True,
|
||||||
model_name='cashbook.book',
|
model_name='cashbook.book',
|
||||||
states={
|
states={
|
||||||
'invisible': ~Bool(Eval('book')),
|
'invisible': ~Bool(Eval('book'))})
|
||||||
})
|
|
||||||
file_ = fields.Binary(
|
file_ = fields.Binary(
|
||||||
string="QIF-File", required=True,
|
string="QIF-File", required=True,
|
||||||
help='Quicken Interchange Format')
|
help='Quicken Interchange Format')
|
||||||
|
@ -47,8 +46,7 @@ class ImportQifWizardInfo(ModelView):
|
||||||
book = fields.Many2One(
|
book = fields.Many2One(
|
||||||
string='Cash Book', readonly=True, model_name='cashbook.book',
|
string='Cash Book', readonly=True, model_name='cashbook.book',
|
||||||
states={
|
states={
|
||||||
'invisible': ~Bool(Eval('book')),
|
'invisible': ~Bool(Eval('book'))})
|
||||||
})
|
|
||||||
allowimport = fields.Boolean(
|
allowimport = fields.Boolean(
|
||||||
string='Import Enabled',
|
string='Import Enabled',
|
||||||
states={'invisible': True})
|
states={'invisible': True})
|
||||||
|
@ -69,8 +67,7 @@ class ImportQifWizard(Wizard):
|
||||||
Button(string='Cancel', state='end', icon='tryton-cancel'),
|
Button(string='Cancel', state='end', icon='tryton-cancel'),
|
||||||
Button(
|
Button(
|
||||||
string='Read File', state='readf',
|
string='Read File', state='readf',
|
||||||
icon='tryton-forward', default=True),
|
icon='tryton-forward', default=True)])
|
||||||
])
|
|
||||||
showinfo = StateView(
|
showinfo = StateView(
|
||||||
model_name='cashbook_dataexchange.qif_imp_wiz.info',
|
model_name='cashbook_dataexchange.qif_imp_wiz.info',
|
||||||
view='cashbook_dataexchange.qif_imp_wiz_info_form',
|
view='cashbook_dataexchange.qif_imp_wiz_info_form',
|
||||||
|
@ -79,10 +76,7 @@ class ImportQifWizard(Wizard):
|
||||||
Button(
|
Button(
|
||||||
string='Import Data', state='importf',
|
string='Import Data', state='importf',
|
||||||
icon='tryton-import', default=True,
|
icon='tryton-import', default=True,
|
||||||
states={
|
states={'readonly': ~Eval('allowimport', False)})])
|
||||||
'readonly': Eval('allowimport', False) == False,
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
|
|
||||||
readf = StateTransition()
|
readf = StateTransition()
|
||||||
importf = StateTransition()
|
importf = StateTransition()
|
||||||
|
@ -94,8 +88,7 @@ class ImportQifWizard(Wizard):
|
||||||
|
|
||||||
values = {
|
values = {
|
||||||
'company': Transaction().context.get('company'),
|
'company': Transaction().context.get('company'),
|
||||||
'book': None,
|
'book': None}
|
||||||
}
|
|
||||||
|
|
||||||
model = context.get('active_model', '')
|
model = context.get('active_model', '')
|
||||||
if model == 'cashbook.book':
|
if model == 'cashbook.book':
|
||||||
|
@ -170,8 +163,7 @@ class ImportQifWizard(Wizard):
|
||||||
['%s (in)' % x for x in in_categories] +
|
['%s (in)' % x for x in in_categories] +
|
||||||
[''] +
|
[''] +
|
||||||
['%s (out)' % x for x in out_categories]
|
['%s (out)' % x for x in out_categories]
|
||||||
)
|
))
|
||||||
)
|
|
||||||
if len(to_create) > 0:
|
if len(to_create) > 0:
|
||||||
self.showinfo.allowimport = True
|
self.showinfo.allowimport = True
|
||||||
else:
|
else:
|
||||||
|
@ -182,8 +174,7 @@ class ImportQifWizard(Wizard):
|
||||||
qif_content = QifTool.split_by_type(file_content)
|
qif_content = QifTool.split_by_type(file_content)
|
||||||
if 'Bank' in qif_content.keys():
|
if 'Bank' in qif_content.keys():
|
||||||
to_create = QifTool.convert_parties_to_create(
|
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(
|
self.showinfo.info = gettext(
|
||||||
'cashbook_dataexchange.msg_wiz_parties_found',
|
'cashbook_dataexchange.msg_wiz_parties_found',
|
||||||
numparties=len(to_create),
|
numparties=len(to_create),
|
||||||
|
@ -266,8 +257,7 @@ class ImportQifWizard(Wizard):
|
||||||
Book.create_from_qif(self.showinfo.book, file_content)
|
Book.create_from_qif(self.showinfo.book, file_content)
|
||||||
lines = Line.search([
|
lines = Line.search([
|
||||||
('cashbook.id', '=', self.showinfo.book.id),
|
('cashbook.id', '=', self.showinfo.book.id),
|
||||||
('state', '=', 'edit'),
|
('state', '=', 'edit')])
|
||||||
])
|
|
||||||
if len(lines) > 0:
|
if len(lines) > 0:
|
||||||
Line.wfcheck(lines)
|
Line.wfcheck(lines)
|
||||||
elif model == 'party.party':
|
elif model == 'party.party':
|
||||||
|
|
70
setup.py
70
setup.py
|
@ -2,7 +2,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Always prefer setuptools over distutils
|
# Always prefer setuptools over distutils
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup
|
||||||
# To use a consistent encoding
|
# To use a consistent encoding
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path
|
from os import path
|
||||||
|
@ -36,7 +36,7 @@ with open(path.join(here, 'versiondep.txt'), encoding='utf-8') as f:
|
||||||
l2 = i.strip().split(';')
|
l2 = i.strip().split(';')
|
||||||
if len(l2) < 4:
|
if len(l2) < 4:
|
||||||
continue
|
continue
|
||||||
modversion[l2[0]] = {'min':l2[1], 'max':l2[2], 'prefix':l2[3]}
|
modversion[l2[0]] = {'min': l2[1], 'max': l2[2], 'prefix': l2[3]}
|
||||||
|
|
||||||
# tryton-version
|
# tryton-version
|
||||||
major_version = 6
|
major_version = 6
|
||||||
|
@ -51,19 +51,21 @@ for dep in info.get('depends', []):
|
||||||
prefix = modversion[dep]['prefix']
|
prefix = modversion[dep]['prefix']
|
||||||
|
|
||||||
if len(modversion[dep]['max']) > 0:
|
if len(modversion[dep]['max']) > 0:
|
||||||
requires.append('%s_%s >= %s, <= %s' %
|
requires.append('%s_%s >= %s, <= %s' % (
|
||||||
(prefix, dep, modversion[dep]['min'], modversion[dep]['max']))
|
prefix, dep, modversion[dep]['min'],
|
||||||
else :
|
modversion[dep]['max']))
|
||||||
requires.append('%s_%s >= %s' %
|
else:
|
||||||
(prefix, dep, modversion[dep]['min']))
|
requires.append('%s_%s >= %s' % (
|
||||||
else :
|
prefix, dep, modversion[dep]['min']))
|
||||||
requires.append('%s_%s >= %s.%s, < %s.%s' %
|
else:
|
||||||
('trytond', dep, major_version, minor_version,
|
requires.append('%s_%s >= %s.%s, < %s.%s' % (
|
||||||
|
'trytond', dep, major_version, minor_version,
|
||||||
major_version, minor_version + 1))
|
major_version, minor_version + 1))
|
||||||
requires.append('trytond >= %s.%s, < %s.%s' %
|
requires.append('trytond >= %s.%s, < %s.%s' % (
|
||||||
(major_version, minor_version, major_version, minor_version + 1))
|
major_version, minor_version, major_version, minor_version + 1))
|
||||||
|
|
||||||
setup(name='%s_%s' % (PREFIX, MODULE),
|
setup(
|
||||||
|
name='%s_%s' % (PREFIX, MODULE),
|
||||||
version=info.get('version', '0.0.1'),
|
version=info.get('version', '0.0.1'),
|
||||||
description='Tryton module to add import/export to cashbook.',
|
description='Tryton module to add import/export to cashbook.',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
@ -74,36 +76,34 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
||||||
author_email='service@m-ds.de',
|
author_email='service@m-ds.de',
|
||||||
license='GPL-3',
|
license='GPL-3',
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 5 - Production/Stable',
|
'Development Status :: 5 - Production/Stable',
|
||||||
'Environment :: Plugins',
|
'Environment :: Plugins',
|
||||||
'Framework :: Tryton',
|
'Framework :: Tryton',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'Intended Audience :: Customer Service',
|
'Intended Audience :: Customer Service',
|
||||||
'Intended Audience :: Information Technology',
|
'Intended Audience :: Information Technology',
|
||||||
'Intended Audience :: Financial and Insurance Industry',
|
'Intended Audience :: Financial and Insurance Industry',
|
||||||
'Topic :: Office/Business',
|
'Topic :: Office/Business',
|
||||||
'Topic :: Office/Business :: Financial :: Accounting',
|
'Topic :: Office/Business :: Financial :: Accounting',
|
||||||
'Natural Language :: German',
|
'Natural Language :: German',
|
||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
'License :: OSI Approved :: GNU General Public License (GPL)',
|
'License :: OSI Approved :: GNU General Public License (GPL)',
|
||||||
'Programming Language :: Python :: 3.7',
|
'Programming Language :: Python :: 3.7',
|
||||||
'Programming Language :: Python :: 3.8',
|
'Programming Language :: Python :: 3.8',
|
||||||
'Programming Language :: Python :: 3.9',
|
'Programming Language :: Python :: 3.9',
|
||||||
],
|
],
|
||||||
|
|
||||||
keywords='tryton cashbook import export',
|
keywords='tryton cashbook import export',
|
||||||
package_dir={'trytond.modules.%s' % MODULE: '.'},
|
package_dir={'trytond.modules.%s' % MODULE: '.'},
|
||||||
packages=[
|
packages=[
|
||||||
'trytond.modules.%s' % MODULE,
|
'trytond.modules.%s' % MODULE,
|
||||||
],
|
],
|
||||||
package_data={
|
package_data={
|
||||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
'trytond.modules.%s' % MODULE: (info.get('xml', []) + [
|
||||||
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
'tryton.cfg', 'locale/*.po', 'tests/*.py',
|
||||||
'report/*.fods', 'view/*.xml',
|
'report/*.fods', 'view/*.xml',
|
||||||
'versiondep.txt', 'README.rst']),
|
'versiondep.txt', 'README.rst']),
|
||||||
},
|
},
|
||||||
|
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
entry_points="""
|
entry_points="""
|
||||||
|
|
|
@ -21,7 +21,8 @@ class CategoryTestCase(object):
|
||||||
"""
|
"""
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Category = pool.get('cashbook.category')
|
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()
|
company = self.prep_company()
|
||||||
with Transaction().set_context({
|
with Transaction().set_context({
|
||||||
|
@ -358,7 +359,8 @@ I
|
||||||
'bookingtype': 'mvout',
|
'bookingtype': 'mvout',
|
||||||
'booktransf': books[1].id,
|
'booktransf': books[1].id,
|
||||||
'description':
|
'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),
|
'date': date(2013, 12, 5),
|
||||||
'amount': Decimal('56.37'),
|
'amount': Decimal('56.37'),
|
||||||
|
@ -475,7 +477,8 @@ I
|
||||||
|
|
||||||
result = QifTool.qif_read_categories(
|
result = QifTool.qif_read_categories(
|
||||||
'NGehalt\nI\n^\nNGehalt:Zulagen\nI\n^' +
|
'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, {
|
self.assertEqual(result, {
|
||||||
'in': {
|
'in': {
|
||||||
'Gehalt': {
|
'Gehalt': {
|
||||||
|
|
|
@ -19,7 +19,8 @@ class PartyTestCase(object):
|
||||||
"""
|
"""
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Party = pool.get('party.party')
|
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()
|
company = self.prep_company()
|
||||||
with Transaction().set_context({
|
with Transaction().set_context({
|
||||||
|
@ -45,8 +46,9 @@ class PartyTestCase(object):
|
||||||
|
|
||||||
self.assertEqual(list(result.keys()), ['view'])
|
self.assertEqual(list(result.keys()), ['view'])
|
||||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||||
self.assertEqual(result['view']['defaults']['info'],
|
self.assertEqual(
|
||||||
"""The following 3 parties are now imported:\n
|
result['view']['defaults']['info'],
|
||||||
|
"""The following 3 parties are now imported:\n
|
||||||
Opening Balance
|
Opening Balance
|
||||||
GA NR00002168 BLZ10000000 0
|
GA NR00002168 BLZ10000000 0
|
||||||
Foodshop Zehlendorf""")
|
Foodshop Zehlendorf""")
|
||||||
|
@ -61,7 +63,8 @@ Foodshop Zehlendorf""")
|
||||||
self.assertEqual(len(records), 4)
|
self.assertEqual(len(records), 4)
|
||||||
|
|
||||||
self.assertEqual(records[0].rec_name, 'Foodshop Zehlendorf')
|
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[2].rec_name, 'm-ds')
|
||||||
self.assertEqual(records[3].rec_name, 'Opening Balance')
|
self.assertEqual(records[3].rec_name, 'Opening Balance')
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,8 @@ class TransactionTestCase(object):
|
||||||
Party = pool.get('party.party')
|
Party = pool.get('party.party')
|
||||||
Category = pool.get('cashbook.category')
|
Category = pool.get('cashbook.category')
|
||||||
Book = pool.get('cashbook.book')
|
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()
|
company = self.prep_company()
|
||||||
with Transaction().set_context({
|
with Transaction().set_context({
|
||||||
|
@ -223,7 +224,8 @@ Mreturn of bottles
|
||||||
Party = pool.get('party.party')
|
Party = pool.get('party.party')
|
||||||
Category = pool.get('cashbook.category')
|
Category = pool.get('cashbook.category')
|
||||||
Book = pool.get('cashbook.book')
|
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()
|
company = self.prep_company()
|
||||||
with Transaction().set_context({
|
with Transaction().set_context({
|
||||||
|
|
Loading…
Reference in a new issue