diff --git a/.hgignore b/.hgignore index 6e89aca..8fa47cf 100644 --- a/.hgignore +++ b/.hgignore @@ -2,3 +2,4 @@ syntax: glob build/* dist/* mds_investment.egg-info/* +__pycache__/* diff --git a/__init__.py b/__init__.py index b40698c..461ecbc 100644 --- a/__init__.py +++ b/__init__.py @@ -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') diff --git a/asset.py b/asset.py new file mode 100644 index 0000000..4d4d162 --- /dev/null +++ b/asset.py @@ -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 diff --git a/asset.xml b/asset.xml new file mode 100644 index 0000000..c90cd67 --- /dev/null +++ b/asset.xml @@ -0,0 +1,67 @@ + + + + + + + + investment.asset + tree + + asset_list + + + investment.asset + form + + asset_form + + + + + Asset + investment.asset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/group.xml b/group.xml new file mode 100644 index 0000000..8061883 --- /dev/null +++ b/group.xml @@ -0,0 +1,21 @@ + + + + + + + Investment + + + Investment Administrator + + + + + + + + + diff --git a/icon.xml b/icon.xml new file mode 100644 index 0000000..376e9d0 --- /dev/null +++ b/icon.xml @@ -0,0 +1,14 @@ + + + + + + + mds-gaininvestment + icon/gain_invest.svg + + + + diff --git a/icon/gain_invest.svg b/icon/gain_invest.svg new file mode 100644 index 0000000..3085593 --- /dev/null +++ b/icon/gain_invest.svg @@ -0,0 +1,7 @@ + + + + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + \ No newline at end of file diff --git a/locale/convert_de2en.py b/locale/convert_de2en.py new file mode 100644 index 0000000..cb661e1 --- /dev/null +++ b/locale/convert_de2en.py @@ -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'], + )) diff --git a/locale/de.po b/locale/de.po new file mode 100644 index 0000000..08040d4 --- /dev/null +++ b/locale/de.po @@ -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" + + diff --git a/locale/en.po b/locale/en.po new file mode 100644 index 0000000..afbfae4 --- /dev/null +++ b/locale/en.po @@ -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" + diff --git a/menu.xml b/menu.xml new file mode 100644 index 0000000..ad16e04 --- /dev/null +++ b/menu.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tryton.cfg b/tryton.cfg index 92ae3f7..835fdd2 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,4 +1,10 @@ [tryton] version=6.0.0 depends: + res + company xml: + icon.xml + group.xml + asset.xml + menu.xml diff --git a/view/asset_form.xml b/view/asset_form.xml new file mode 100644 index 0000000..25722e0 --- /dev/null +++ b/view/asset_form.xml @@ -0,0 +1,10 @@ + + +
+