diff --git a/__init__.py b/__init__.py index 3e86618..68ef3e4 100644 --- a/__init__.py +++ b/__init__.py @@ -9,10 +9,13 @@ from .planner import ScheduledBooking, ScheduledBookingCashbookRel from .cashbook import Cashbook, CashbookLine from .cron import Cron from .nextrun import NextRun +from .config import Configuration, UserConfiguration def register(): Pool.register( + Configuration, + UserConfiguration, Rule, ScheduledBooking, NextRun, diff --git a/config.py b/config.py new file mode 100644 index 0000000..226272c --- /dev/null +++ b/config.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# This file is part of the cashbook-planner 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 PoolMeta, Pool +from trytond.model import fields + +holidays = fields.Char( + string='Holidays', help='Semicolon separate list of dates:' + + ' yyyy-mm-dd = single date, mm-dd = annual repetition, ' + + 'easter = Easter Sunday, ascension = Ascension Day, offset ' + + 'with +/-n e.g.: easter+1 = Easter Monday') + + +class Configuration(metaclass=PoolMeta): + __name__ = 'cashbook.configuration' + + holidays = fields.MultiValue(holidays) + + @classmethod + def multivalue_model(cls, field): + """ get model for value + """ + pool = Pool() + + if field in ['holidays']: + return pool.get('cashbook.configuration_user') + return super(Configuration, cls).multivalue_model(field) + + @classmethod + def default_holidays(cls, **pattern): + return cls.multivalue_model('holidays').default_holidays() + +# end Configuration + + +class UserConfiguration(metaclass=PoolMeta): + __name__ = 'cashbook.configuration_user' + + holidays = holidays + + @classmethod + def default_holidays(cls): + return 'easter+1;easter-2;ascension;05-01;12-25;12-26;01-01;' + +# end CashbookLine diff --git a/config.xml b/config.xml new file mode 100644 index 0000000..19802e9 --- /dev/null +++ b/config.xml @@ -0,0 +1,15 @@ + + + + + + + cashbook.configuration + + configuration_form + + + + diff --git a/locale/de.po b/locale/de.po index c7404e3..140a7d2 100644 --- a/locale/de.po +++ b/locale/de.po @@ -79,6 +79,22 @@ msgid "User in companies" msgstr "Benutzer im Unternehmen" +########################## +# cashbook.configuration # +########################## +msgctxt "view:cashbook.configuration:" +msgid "Scheduled Bookings" +msgstr "geplante Buchungen" + +msgctxt "field:cashbook.configuration,holidays:" +msgid "Holidays" +msgstr "Feiertage" + +msgctxt "help:cashbook.configuration,holidays:" +msgid "Semicolon separate list of dates: yyyy-mm-dd = single date, mm-dd = annual repetition, easter = Easter Sunday, ascension = Ascension Day, offset with +/-n e.g.: easter+1 = Easter Monday" +msgstr "Semikolon getrennte Liste von Datumswerten: yyyy-mm-dd = Einzeldatum, mm-dd = jährliche Wiederholung, easter = Ostersonntag, ascension = Christi Himmelfahrt, Offset mit +/-n z.B: easter+1 = Ostermontag" + + #################### # cashbook.planner # #################### diff --git a/locale/en.po b/locale/en.po index 9ec77a4..abdc601 100644 --- a/locale/en.po +++ b/locale/en.po @@ -58,6 +58,18 @@ msgctxt "model:ir.rule.group,name:rg_nextrun_companies" msgid "User in companies" msgstr "User in companies" +msgctxt "view:cashbook.configuration:" +msgid "Scheduled Bookings" +msgstr "Scheduled Bookings" + +msgctxt "field:cashbook.configuration,holidays:" +msgid "Holidays" +msgstr "Holidays" + +msgctxt "help:cashbook.configuration,holidays:" +msgid "Semicolon separate list of dates: yyyy-mm-dd = single date, mm-dd = annual repetition, easter = Easter Sunday, ascension = Ascension Day, offset with +/-n e.g.: easter+1 = Easter Monday" +msgstr "Semicolon separate list of dates: yyyy-mm-dd = single date, mm-dd = annual repetition, easter = Easter Sunday, ascension = Ascension Day, offset with +/-n e.g.: easter+1 = Easter Monday" + msgctxt "model:cashbook.planner,name:" msgid "Scheduled Booking" msgstr "Scheduled Booking" diff --git a/tryton.cfg b/tryton.cfg index 5ede97e..1b8743e 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -8,6 +8,7 @@ xml: group.xml planner.xml nextrun.xml + config.xml cashbook.xml cron.xml menu.xml diff --git a/view/configuration_form.xml b/view/configuration_form.xml new file mode 100644 index 0000000..cb87bf7 --- /dev/null +++ b/view/configuration_form.xml @@ -0,0 +1,15 @@ + + + + + + + + +