icon, menü, asset-liste ergänzt

This commit is contained in:
Frederik Jaeckel 2022-11-09 21:49:33 +01:00
parent c415f64a81
commit 0d8ef5081e
14 changed files with 391 additions and 1 deletions

View file

@ -2,3 +2,4 @@ syntax: glob
build/*
dist/*
mds_investment.egg-info/*
__pycache__/*

View file

@ -1,10 +1,12 @@
# -*- coding: utf-8 -*-
# This file is part of the cashbook-module from m-ds for Tryton.
# This file is part of the investment-module from m-ds for Tryton.
# The COPYRIGHT file at the top level of this repository contains the
# full copyright notices and license terms.
from trytond.pool import Pool
from .asset import Asset
def register():
Pool.register(
Asset,
module='investment', type_='model')

68
asset.py Normal file
View file

@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
# This file is part of the investment-module from m-ds for Tryton.
# The COPYRIGHT file at the top level of this repository contains the
# full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
from trytond.exceptions import UserError
from trytond.i18n import gettext
from trytond.transaction import Transaction
from trytond.pool import Pool
class Asset(ModelSQL, ModelView):
'Asset'
__name__ = 'investment.asset'
company = fields.Many2One(string='Company', model_name='company.company',
required=True, ondelete="RESTRICT")
company_currency = fields.Function(fields.Many2One(readonly=True,
string='Company Currency', states={'invisible': True},
model_name='currency.currency'),
'on_change_with_company_currency')
company_currency_digits = fields.Function(fields.Integer(
string='Currency Digits (Ref.)', readonly=True),
'on_change_with_currency_digits')
currency = fields.Many2One(string='Currency', select=True,
required=True, model_name='currency.currency', ondelete='RESTRICT')
currency_digits = fields.Integer(string='Currency Digits',
required=True)
@classmethod
def default_currency(cls):
""" currency of company
"""
Company = Pool().get('company.company')
company = cls.default_company()
if company:
company = Company(company)
if company.currency:
return company.currency.id
@staticmethod
def default_company():
return Transaction().context.get('company') or None
@fields.depends('currency')
def on_change_with_currency_digits(self, name=None):
""" currency of cashbook
"""
if self.currency:
return self.currency.digits
else:
return 2
@fields.depends('company', 'currency')
def on_change_with_company_currency(self, name=None):
""" get company-currency if its different from current
asset-currency
"""
if self.company:
if self.currency:
if self.company.currency.id != self.currency.id:
return self.company.currency.id
# end Asset

67
asset.xml Normal file
View file

@ -0,0 +1,67 @@
<?xml version="1.0"?>
<!-- This file is part of the investment-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>
<!-- views -->
<record model="ir.ui.view" id="asset_view_list">
<field name="model">investment.asset</field>
<field name="type">tree</field>
<field name="priority" eval="10"/>
<field name="name">asset_list</field>
</record>
<record model="ir.ui.view" id="asset_view_form">
<field name="model">investment.asset</field>
<field name="type">form</field>
<field name="priority" eval="20"/>
<field name="name">asset_form</field>
</record>
<!-- action view - list -->
<record model="ir.action.act_window" id="act_asset_view">
<field name="name">Asset</field>
<field name="res_model">investment.asset</field>
</record>
<record model="ir.action.act_window.view" id="act_asset_view-1">
<field name="sequence" eval="10"/>
<field name="view" ref="asset_view_list"/>
<field name="act_window" ref="act_asset_view"/>
</record>
<record model="ir.action.act_window.view" id="act_asset_view-2">
<field name="sequence" eval="20"/>
<field name="view" ref="asset_view_form"/>
<field name="act_window" ref="act_asset_view"/>
</record>
<!-- permission -->
<!-- anon: deny all -->
<record model="ir.model.access" id="access_asset-anon">
<field name="model" search="[('model', '=', 'investment.asset')]"/>
<field name="perm_read" eval="False"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<!-- group_investment: read -->
<record model="ir.model.access" id="access_asset-group_cashbook_admin">
<field name="model" search="[('model', '=', 'investment.asset')]"/>
<field name="group" ref="group_investment"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<!-- group_investment_admin: read/write -->
<record model="ir.model.access" id="access_asset-group_investment_admin">
<field name="model" search="[('model', '=', 'investment.asset')]"/>
<field name="group" ref="group_investment_admin"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
</data>
</tryton>

21
group.xml Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!-- This file is part of the investment-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="res.group" id="group_investment">
<field name="name">Investment</field>
</record>
<record model="res.group" id="group_investment_admin">
<field name="name">Investment Administrator</field>
</record>
<record model="res.user-res.group" id="user_admin-group_investment_admin">
<field name="user" ref="res.user_admin"/>
<field name="group" ref="group_investment_admin"/>
</record>
</data>
</tryton>

14
icon.xml Normal file
View file

@ -0,0 +1,14 @@
<?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.ui.icon" id="gain_icon">
<field name="name">mds-gaininvestment</field>
<field name="path">icon/gain_invest.svg</field>
</record>
</data>
</tryton>

7
icon/gain_invest.svg Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
<g><path d="M162.7,511.3L384.4,350l181.4,120.4l284.1-272.9l58.2,45.9l21.6-154.5l-166.9,14.9l46.5,55l-257,240l-170.9-113l-249.7,184L162.7,511.3L162.7,511.3z M10,929.5h980l-0.1-55.6H60.5V70.5H10L10,929.5L10,929.5z M146.2,804.4h238.2L384,444.1L146.2,615.4V804.4L146.2,804.4z M445.2,804.4h208.4V497.3l-74.8,76.2l-133.6-92.9V804.4L445.2,804.4z M716.2,804.4h208.6V257.9L716.2,462.2V804.4L716.2,804.4z"/></g>
</svg>

After

Width:  |  Height:  |  Size: 889 B

41
locale/convert_de2en.py Normal file
View file

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
# convert german 'de.po' to 'en.po'
lines = []
with open('de.po', 'rt') as fhdl:
lines = fhdl.readlines()
groups = []
group = {}
for line in lines:
if len(line.strip()) == 0:
if len(group) > 0:
groups.append(group)
group = {}
for x in ['msgctxt', 'msgid', 'msgstr']:
if line.startswith(x):
group[x] = line[len(x):].strip()
break
used_ids = []
with open('en.po', 'wt') as fhdl:
fhdl.write("""#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\\n"
""")
for line in groups:
if line['msgid'].strip() == '""':
continue
if line['msgctxt'] in used_ids:
raise ValueError('duplicate id: %s' % line['msgctxt'])
fhdl.write('msgctxt %s\nmsgid %s\nmsgstr %s\n\n' % (
line['msgctxt'],
line['msgid'],
line['msgid'],
))

65
locale/de.po Normal file
View file

@ -0,0 +1,65 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
#############
# res.group #
#############
msgctxt "model:res.group,name:group_investment"
msgid "Investment"
msgstr "Investition"
msgctxt "model:res.group,name:group_investment_admin"
msgid "Investment Administrator"
msgstr "Investition Administrator"
##############
# ir.ui.menu #
##############
msgctxt "model:ir.ui.menu,name:menu_investment"
msgid "Investment"
msgstr "Investition"
msgctxt "model:ir.ui.menu,name:menu_asset"
msgid "Asset"
msgstr "Vermögenswert"
#############
# ir.action #
#############
msgctxt "model:ir.action,name:act_asset_view"
msgid "Asset"
msgstr "Vermögenswert"
####################
# investment.asset #
####################
msgctxt "model:investment.asset,name:"
msgid "Asset"
msgstr "Vermögenswert"
msgctxt "field:investment.asset,company:"
msgid "Company"
msgstr "Unternehmen"
msgctxt "field:investment.asset,company_currency:"
msgid "Company Currency"
msgstr "Unternehmenswährung"
msgctxt "field:investment.asset,company_currency_digits:"
msgid "Currency Digits (Ref.)"
msgstr "Nachkommastellen Währung (Ref.)"
msgctxt "field:investment.asset,currency:"
msgid "Currency"
msgstr "Währung"
msgctxt "field:investment.asset,currency_digits:"
msgid "Currency Digits"
msgstr "Nachkommastellen Währung"

48
locale/en.po Normal file
View file

@ -0,0 +1,48 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "model:res.group,name:group_investment"
msgid "Investment"
msgstr "Investment"
msgctxt "model:res.group,name:group_investment_admin"
msgid "Investment Administrator"
msgstr "Investment Administrator"
msgctxt "model:ir.ui.menu,name:menu_investment"
msgid "Investment"
msgstr "Investment"
msgctxt "model:ir.ui.menu,name:menu_asset"
msgid "Asset"
msgstr "Asset"
msgctxt "model:ir.action,name:act_asset_view"
msgid "Asset"
msgstr "Asset"
msgctxt "model:investment.asset,name:"
msgid "Asset"
msgstr "Asset"
msgctxt "field:investment.asset,company:"
msgid "Company"
msgstr "Company"
msgctxt "field:investment.asset,company_currency:"
msgid "Company Currency"
msgstr "Company Currency"
msgctxt "field:investment.asset,company_currency_digits:"
msgid "Currency Digits (Ref.)"
msgstr "Currency Digits (Ref.)"
msgctxt "field:investment.asset,currency:"
msgid "Currency"
msgstr "Currency"
msgctxt "field:investment.asset,currency_digits:"
msgid "Currency Digits"
msgstr "Currency Digits"

33
menu.xml Normal file
View file

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<!-- This file is part of the investment-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>
<!-- menu: /Investment -->
<menuitem id="menu_investment" name="Investment"
icon="mds-gaininvestment" />
<record model="ir.ui.menu-res.group" id="menu_investment-group_investment">
<field name="menu" ref="menu_investment"/>
<field name="group" ref="group_investment"/>
</record>
<record model="ir.ui.menu-res.group" id="menu_investment-group_investment_admin">
<field name="menu" ref="menu_investment"/>
<field name="group" ref="group_investment_admin"/>
</record>
<!-- menu: /Investment/Asset -->
<menuitem id="menu_asset" action="act_asset_view"
icon="tryton-list" parent="menu_investment"/>
<record model="ir.ui.menu-res.group" id="menu_asset-group_investment">
<field name="menu" ref="menu_asset"/>
<field name="group" ref="group_investment"/>
</record>
<record model="ir.ui.menu-res.group" id="menu_asset-group_investment_admin">
<field name="menu" ref="menu_asset"/>
<field name="group" ref="group_investment_admin"/>
</record>
</data>
</tryton>

View file

@ -1,4 +1,10 @@
[tryton]
version=6.0.0
depends:
res
company
xml:
icon.xml
group.xml
asset.xml
menu.xml

10
view/asset_form.xml Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!-- This file is part of the investment-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="4">
<label name="currency" />
<field name="currency" />
<label name="currency_digits" />
<field name="currency_digits" />
</form>

7
view/asset_list.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!-- This file is part of the investment-module from m-ds for Tryton.
The COPYRIGHT file at the top level of this repository contains the
full copyright notices and license terms. -->
<tree>
<field name="currency"/>
</tree>