kategorie: domain-views, importer ergänzt
This commit is contained in:
parent
d383b8f9c1
commit
532d9cc7c8
3 changed files with 106 additions and 9 deletions
41
category.xml
41
category.xml
|
@ -42,6 +42,26 @@ full copyright notices and license terms. -->
|
||||||
<field name="act_window" ref="act_category_list"/>
|
<field name="act_window" ref="act_category_list"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- domain view - list -->
|
||||||
|
<record model="ir.action.act_window.domain" id="act_category_list_domain_in">
|
||||||
|
<field name="name">Revenue</field>
|
||||||
|
<field name="sequence" eval="10"/>
|
||||||
|
<field name="domain" eval="[('cattype', '=', 'in')]" pyson="1"/>
|
||||||
|
<field name="act_window" ref="act_category_list"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.domain" id="act_category_list_domain_out">
|
||||||
|
<field name="name">Expense</field>
|
||||||
|
<field name="sequence" eval="20"/>
|
||||||
|
<field name="domain" eval="[('cattype', '=', 'out')]" pyson="1"/>
|
||||||
|
<field name="act_window" ref="act_category_list"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.domain" id="act_category_list_domain_all">
|
||||||
|
<field name="name">All</field>
|
||||||
|
<field name="sequence" eval="999"/>
|
||||||
|
<field name="domain"/>
|
||||||
|
<field name="act_window" ref="act_category_list"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- action view - tree -->
|
<!-- action view - tree -->
|
||||||
<record model="ir.action.act_window" id="act_category_tree">
|
<record model="ir.action.act_window" id="act_category_tree">
|
||||||
<field name="name">Category</field>
|
<field name="name">Category</field>
|
||||||
|
@ -59,6 +79,27 @@ full copyright notices and license terms. -->
|
||||||
<field name="act_window" ref="act_category_tree"/>
|
<field name="act_window" ref="act_category_tree"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- domain view - tree -->
|
||||||
|
<record model="ir.action.act_window.domain" id="act_category_tree_domain_in">
|
||||||
|
<field name="name">Revenue</field>
|
||||||
|
<field name="sequence" eval="10"/>
|
||||||
|
<field name="domain" eval="[('cattype', '=', 'in')]" pyson="1"/>
|
||||||
|
<field name="act_window" ref="act_category_tree"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.domain" id="act_category_tree_domain_out">
|
||||||
|
<field name="name">Expense</field>
|
||||||
|
<field name="sequence" eval="20"/>
|
||||||
|
<field name="domain" eval="[('cattype', '=', 'out')]" pyson="1"/>
|
||||||
|
<field name="act_window" ref="act_category_tree"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.domain" id="act_category_tree_domain_all">
|
||||||
|
<field name="name">All</field>
|
||||||
|
<field name="sequence" eval="999"/>
|
||||||
|
<field name="domain"/>
|
||||||
|
<field name="act_window" ref="act_category_tree"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
<!-- permission -->
|
<!-- permission -->
|
||||||
<!-- anon: deny all -->
|
<!-- anon: deny all -->
|
||||||
<record model="ir.model.access" id="access_category-anon">
|
<record model="ir.model.access" id="access_category-anon">
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
from quiffen import Qif
|
|
||||||
|
|
||||||
file_name = 'bargeld.qif'
|
file_name = 'bargeld.qif'
|
||||||
|
file_category_income = 'category_income.qif'
|
||||||
|
file_category_expense = 'category_expense.qif'
|
||||||
company_name = 'm-ds'
|
company_name = 'm-ds'
|
||||||
|
|
||||||
|
from quiffen import Qif
|
||||||
from proteus import config, Model
|
from proteus import config, Model
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
import json
|
||||||
|
|
||||||
cfg1 = config.set_trytond(
|
cfg1 = config.set_trytond(
|
||||||
'postgresql://postgres:test1@localhost:5432/tr44/',
|
'postgresql://postgres:test1@localhost:5432/tr44/',
|
||||||
|
@ -28,12 +30,16 @@ if not len(mod_lst) == len(need_modules):
|
||||||
raise ValueError('einige module sind nicht aktiviert!')
|
raise ValueError('einige module sind nicht aktiviert!')
|
||||||
|
|
||||||
|
|
||||||
def add_category(category, parent, company):
|
def add_category(category, parent, company, cattype):
|
||||||
""" check or add category
|
""" check or add category
|
||||||
"""
|
"""
|
||||||
Category = Model.get('cashbook.category')
|
Category = Model.get('cashbook.category')
|
||||||
|
|
||||||
query = [('name', '=', category.name)]
|
query = [
|
||||||
|
('name', '=', category.name),
|
||||||
|
('cattype', '=', cattype),
|
||||||
|
]
|
||||||
|
|
||||||
if parent is None:
|
if parent is None:
|
||||||
query.append(('parent', '=', None))
|
query.append(('parent', '=', None))
|
||||||
else :
|
else :
|
||||||
|
@ -47,7 +53,7 @@ def add_category(category, parent, company):
|
||||||
print('- new-go:', getattr(parent, 'rec_name', '-'), category.name, category.income, category.expense)
|
print('- new-go:', getattr(parent, 'rec_name', '-'), category.name, category.income, category.expense)
|
||||||
cashbook_category, = Category.create([{
|
cashbook_category, = Category.create([{
|
||||||
'name': category.name,
|
'name': category.name,
|
||||||
'cattype': 'in' if category.income == True else 'out',
|
'cattype': cattype,
|
||||||
'parent': getattr(parent, 'id', None),
|
'parent': getattr(parent, 'id', None),
|
||||||
}], context={'company': company.id})
|
}], context={'company': company.id})
|
||||||
cashbook_category = Category(cashbook_category)
|
cashbook_category = Category(cashbook_category)
|
||||||
|
@ -56,17 +62,43 @@ def add_category(category, parent, company):
|
||||||
raise ValueError('invalid num of category')
|
raise ValueError('invalid num of category')
|
||||||
|
|
||||||
for subcat in category.children:
|
for subcat in category.children:
|
||||||
add_category(subcat, cashbook_category, company)
|
add_category(subcat, cashbook_category, company, cattype)
|
||||||
|
|
||||||
# end add_category
|
# end add_category
|
||||||
|
|
||||||
|
|
||||||
qif = Qif.parse(file_name, day_first=True)
|
def get_category_tree(categories):
|
||||||
|
""" convert categories in dict-tree
|
||||||
|
"""
|
||||||
|
result = []
|
||||||
|
for category in categories:
|
||||||
|
cat1 = {
|
||||||
|
'name': category.name,
|
||||||
|
'type': 'in' if category.income == True else 'out' if category.expense == True else 'ups',
|
||||||
|
}
|
||||||
|
cat1['childs'] = get_category_tree(category.children)
|
||||||
|
result.append(cat1)
|
||||||
|
return result
|
||||||
|
|
||||||
|
# end get_category_tree
|
||||||
|
|
||||||
|
|
||||||
Company = Model.get('company.company')
|
Company = Model.get('company.company')
|
||||||
company1, = Company.find([('rec_name', '=', company_name)])
|
company1, = Company.find([('rec_name', '=', company_name)])
|
||||||
|
|
||||||
# import categories
|
|
||||||
|
# income-category
|
||||||
|
qif = Qif.parse(file_category_income, day_first=True)
|
||||||
|
cat_tree = []
|
||||||
for catname in qif.categories.keys():
|
for catname in qif.categories.keys():
|
||||||
category = qif.categories[catname]
|
category = qif.categories[catname]
|
||||||
add_category(category, None, company1)
|
#cat_tree.extend(get_category_tree([category]))
|
||||||
|
add_category(category, None, company1, 'in')
|
||||||
|
|
||||||
|
# expense-category
|
||||||
|
qif = Qif.parse(file_category_expense, day_first=True)
|
||||||
|
cat_tree = []
|
||||||
|
for catname in qif.categories.keys():
|
||||||
|
category = qif.categories[catname]
|
||||||
|
#cat_tree.extend(get_category_tree([category]))
|
||||||
|
add_category(category, None, company1, 'out')
|
||||||
|
|
24
locale/de.po
24
locale/de.po
|
@ -318,6 +318,30 @@ msgctxt "model:ir.action.act_window.domain,name:act_line_domain_all"
|
||||||
msgid "All"
|
msgid "All"
|
||||||
msgstr "Alle"
|
msgstr "Alle"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action.act_window.domain,name:act_category_tree_domain_in"
|
||||||
|
msgid "Revenue"
|
||||||
|
msgstr "Einnahmen"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action.act_window.domain,name:act_category_tree_domain_out"
|
||||||
|
msgid "Expense"
|
||||||
|
msgstr "Ausgaben"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action.act_window.domain,name:act_category_tree_domain_all"
|
||||||
|
msgid "All"
|
||||||
|
msgstr "Alle"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action.act_window.domain,name:act_category_list_domain_in"
|
||||||
|
msgid "Revenue"
|
||||||
|
msgstr "Einnahmen"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action.act_window.domain,name:act_category_list_domain_out"
|
||||||
|
msgid "Expense"
|
||||||
|
msgstr "Ausgaben"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action.act_window.domain,name:act_category_list_domain_all"
|
||||||
|
msgid "All"
|
||||||
|
msgstr "Alle"
|
||||||
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# ir.model.button #
|
# ir.model.button #
|
||||||
|
|
Loading…
Reference in a new issue