importiert kategorien
This commit is contained in:
parent
6a6d9bc5d7
commit
e2025a1711
7 changed files with 170 additions and 1 deletions
|
@ -6,13 +6,14 @@
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from .category import Category
|
from .category import Category
|
||||||
from .qiftool import QifTool
|
from .qiftool import QifTool
|
||||||
from .qif_import_wiz import ImportQifWizard, ImportQifWizardStart
|
from .qif_import_wiz import ImportQifWizard, ImportQifWizardStart, ImportQifWizardInfo
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
QifTool,
|
QifTool,
|
||||||
Category,
|
Category,
|
||||||
ImportQifWizardStart,
|
ImportQifWizardStart,
|
||||||
|
ImportQifWizardInfo,
|
||||||
module='cashbook_dataexchange', type_='model')
|
module='cashbook_dataexchange', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
ImportQifWizard,
|
ImportQifWizard,
|
||||||
|
|
40
locale/de.po
40
locale/de.po
|
@ -3,6 +3,14 @@ msgid ""
|
||||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
|
||||||
|
|
||||||
|
##############
|
||||||
|
# ir.message #
|
||||||
|
##############
|
||||||
|
msgctxt "model:ir.message,text:msg_wiz_categories_found"
|
||||||
|
msgid "The following categories are now imported:\n%(categories)s"
|
||||||
|
msgstr "Die folgenden Kategorien werden nun importiert:\n%(categories)s"
|
||||||
|
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# ir.action #
|
# ir.action #
|
||||||
#############
|
#############
|
||||||
|
@ -10,6 +18,10 @@ msgctxt "model:ir.action,name:act_import_qif_wizard"
|
||||||
msgid "Import QIF-File"
|
msgid "Import QIF-File"
|
||||||
msgstr "QIF-Datei importieren"
|
msgstr "QIF-Datei importieren"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action,name:msg_wiz_no_categories"
|
||||||
|
msgid "No categories were found in the file."
|
||||||
|
msgstr "In der Datei wurden keine Kategorien gefunden."
|
||||||
|
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# cashbook_dataexchange.qif_imp_wiz #
|
# cashbook_dataexchange.qif_imp_wiz #
|
||||||
|
@ -26,6 +38,14 @@ msgctxt "wizard_button:cashbook_dataexchange.qif_imp_wiz,start,readf:"
|
||||||
msgid "Read File"
|
msgid "Read File"
|
||||||
msgstr "Datei lesen"
|
msgstr "Datei lesen"
|
||||||
|
|
||||||
|
msgctxt "wizard_button:cashbook_dataexchange.qif_imp_wiz,showinfo,end:"
|
||||||
|
msgid "Cancel"
|
||||||
|
msgstr "Abbruch"
|
||||||
|
|
||||||
|
msgctxt "wizard_button:cashbook_dataexchange.qif_imp_wiz,showinfo,importf:"
|
||||||
|
msgid "Import Categories"
|
||||||
|
msgstr "Kategorien importieren"
|
||||||
|
|
||||||
|
|
||||||
###########################################
|
###########################################
|
||||||
# cashbook_dataexchange.qif_imp_wiz.start #
|
# cashbook_dataexchange.qif_imp_wiz.start #
|
||||||
|
@ -45,3 +65,23 @@ msgstr "QIF-Datei"
|
||||||
msgctxt "help:cashbook_dataexchange.qif_imp_wiz.start,file_:"
|
msgctxt "help:cashbook_dataexchange.qif_imp_wiz.start,file_:"
|
||||||
msgid "Quicken Interchange Format"
|
msgid "Quicken Interchange Format"
|
||||||
msgstr "Quicken Interchange Format"
|
msgstr "Quicken Interchange Format"
|
||||||
|
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# cashbook_dataexchange.qif_imp_wiz.info #
|
||||||
|
##########################################
|
||||||
|
msgctxt "model:cashbook_dataexchange.qif_imp_wiz.info,name:"
|
||||||
|
msgid "Import QIF-File"
|
||||||
|
msgstr "QIF-Datei importieren"
|
||||||
|
|
||||||
|
msgctxt "view:cashbook_dataexchange.qif_imp_wiz.info:"
|
||||||
|
msgid "Information"
|
||||||
|
msgstr "Information"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook_dataexchange.qif_imp_wiz.start,company:"
|
||||||
|
msgid "Company"
|
||||||
|
msgstr "Unternehmen"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook_dataexchange.qif_imp_wiz.start,info:"
|
||||||
|
msgid "Information"
|
||||||
|
msgstr "Information"
|
||||||
|
|
17
message.xml
Normal file
17
message.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of the cashbook-module from m-ds for Tryton.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
full copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record model="ir.message" id="msg_wiz_categories_found">
|
||||||
|
<field name="text">The following categories are now imported:\n%(categories)s</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.message" id="msg_wiz_no_categories">
|
||||||
|
<field name="text">No categories were found in the file.</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
|
@ -8,6 +8,7 @@ from trytond.pool import Pool
|
||||||
from trytond.model import ModelView, fields
|
from trytond.model import ModelView, fields
|
||||||
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
from trytond.i18n import gettext
|
||||||
|
|
||||||
|
|
||||||
class ImportQifWizardStart(ModelView):
|
class ImportQifWizardStart(ModelView):
|
||||||
|
@ -27,6 +28,18 @@ class ImportQifWizardStart(ModelView):
|
||||||
# end ImportQifWizardStart
|
# end ImportQifWizardStart
|
||||||
|
|
||||||
|
|
||||||
|
class ImportQifWizardInfo(ModelView):
|
||||||
|
'Import QIF-File'
|
||||||
|
__name__ = 'cashbook_dataexchange.qif_imp_wiz.info'
|
||||||
|
|
||||||
|
company = fields.Many2One(model_name='company.company',
|
||||||
|
string="Company", required=True,
|
||||||
|
states={'invisible': True})
|
||||||
|
info = fields.Text(string='Information', readonly=True)
|
||||||
|
|
||||||
|
# end ImportQifWizardInfo
|
||||||
|
|
||||||
|
|
||||||
class ImportQifWizard(Wizard):
|
class ImportQifWizard(Wizard):
|
||||||
'Import QIF-File'
|
'Import QIF-File'
|
||||||
__name__ = 'cashbook_dataexchange.qif_imp_wiz'
|
__name__ = 'cashbook_dataexchange.qif_imp_wiz'
|
||||||
|
@ -38,6 +51,85 @@ class ImportQifWizard(Wizard):
|
||||||
Button(string='Cancel', state='end', icon='tryton-cancel'),
|
Button(string='Cancel', state='end', icon='tryton-cancel'),
|
||||||
Button(string='Read File', state='readf', icon='tryton-forward', default=True),
|
Button(string='Read File', state='readf', icon='tryton-forward', default=True),
|
||||||
])
|
])
|
||||||
|
showinfo = StateView(model_name='cashbook_dataexchange.qif_imp_wiz.info', \
|
||||||
|
view='cashbook_dataexchange.qif_imp_wiz_info_form', \
|
||||||
|
buttons=[
|
||||||
|
Button(string='Cancel', state='end', icon='tryton-cancel'),
|
||||||
|
Button(string='Import Categories', state='importf', icon='tryton-import', default=True),
|
||||||
|
])
|
||||||
|
|
||||||
|
readf = StateTransition()
|
||||||
|
importf = StateTransition()
|
||||||
|
|
||||||
|
def default_showinfo(self, fields):
|
||||||
|
""" show import-info
|
||||||
|
"""
|
||||||
|
values = {
|
||||||
|
'company': self.start.company.id,
|
||||||
|
'info': getattr(self.showinfo, 'info', None),
|
||||||
|
}
|
||||||
|
return values
|
||||||
|
|
||||||
|
def transition_readf(self):
|
||||||
|
""" read file, show number of objects
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
QitTool = pool.get('cashbook_dataexchange.qiftool')
|
||||||
|
|
||||||
|
model = Transaction().context.get('active_model', '')
|
||||||
|
file_content = None
|
||||||
|
if isinstance(self.start.file_, bytes):
|
||||||
|
file_content = self.start.file_.decode('utf8')
|
||||||
|
|
||||||
|
if model == 'cashbook.category':
|
||||||
|
def get_catlist(catlist, parent_name=None):
|
||||||
|
""" generate list of categories
|
||||||
|
"""
|
||||||
|
names = []
|
||||||
|
for name1 in catlist.keys():
|
||||||
|
name_lst = []
|
||||||
|
if parent_name:
|
||||||
|
name_lst.append(parent_name)
|
||||||
|
name_lst.append(name1)
|
||||||
|
current_name = '/'.join(name_lst)
|
||||||
|
names.append(current_name)
|
||||||
|
names.extend(get_catlist(catlist[name1]['childs'], current_name))
|
||||||
|
return names
|
||||||
|
|
||||||
|
# read file content, extract categories
|
||||||
|
qif_content = QitTool.split_by_type(file_content)
|
||||||
|
if 'Cat' in qif_content.keys():
|
||||||
|
categories = QitTool.qif_read_categories(qif_content['Cat'])
|
||||||
|
self.showinfo.info = gettext(
|
||||||
|
'cashbook_dataexchange.msg_wiz_categories_found',
|
||||||
|
categories = '\n'.join(
|
||||||
|
[' '] +
|
||||||
|
['%s (in)' % x for x in get_catlist(categories['in'], None)]+
|
||||||
|
[' '] +
|
||||||
|
['%s (out)' % x for x in get_catlist(categories['out'], None)]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else :
|
||||||
|
self.showinfo.info = gettext('cashbook_dataexchange.msg_wiz_no_categories')
|
||||||
|
|
||||||
|
return 'showinfo'
|
||||||
|
|
||||||
|
def transition_importf(self):
|
||||||
|
""" read file, show number of objects
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Category = pool.get('cashbook.category')
|
||||||
|
|
||||||
|
model = Transaction().context.get('active_model', '')
|
||||||
|
file_content = None
|
||||||
|
if isinstance(self.start.file_, bytes):
|
||||||
|
file_content = self.start.file_.decode('utf8')
|
||||||
|
|
||||||
|
if model == 'cashbook.category':
|
||||||
|
if file_content:
|
||||||
|
records = Category.create_from_qif(file_content)
|
||||||
|
|
||||||
|
return 'end'
|
||||||
|
|
||||||
# end ImportQifWizard
|
# end ImportQifWizard
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,11 @@ full copyright notices and license terms. -->
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="name">wiz_qifimport_start_form</field>
|
<field name="name">wiz_qifimport_start_form</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record model="ir.ui.view" id="qif_imp_wiz_info_form">
|
||||||
|
<field name="model">cashbook_dataexchange.qif_imp_wiz.info</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">wiz_qifimport_info_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- import qif file wizard -->
|
<!-- import qif file wizard -->
|
||||||
<record model="ir.action.wizard" id="act_import_qif_wizard">
|
<record model="ir.action.wizard" id="act_import_qif_wizard">
|
||||||
|
|
|
@ -3,4 +3,5 @@ version=6.0.1
|
||||||
depends:
|
depends:
|
||||||
cashbook
|
cashbook
|
||||||
xml:
|
xml:
|
||||||
|
message.xml
|
||||||
qif_import_wiz.xml
|
qif_import_wiz.xml
|
||||||
|
|
13
view/wiz_qifimport_info_form.xml
Normal file
13
view/wiz_qifimport_info_form.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of the cashbook-module from m-ds for Tryton.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
full copyright notices and license terms. -->
|
||||||
|
<form col="2">
|
||||||
|
<label name="company"/>
|
||||||
|
<field name="company"/>
|
||||||
|
|
||||||
|
<group col="1" name="info" colspan="2" string="Information" yexpand="1">
|
||||||
|
<field name="info"/>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
</form>
|
Loading…
Add table
Add a link
Reference in a new issue