config: allow setting of holidays for each user

This commit is contained in:
Frederik Jaeckel 2024-06-01 13:33:45 +02:00
parent 73a7c1d86c
commit b5f774003f
7 changed files with 110 additions and 0 deletions

View file

@ -9,10 +9,13 @@ from .planner import ScheduledBooking, ScheduledBookingCashbookRel
from .cashbook import Cashbook, CashbookLine from .cashbook import Cashbook, CashbookLine
from .cron import Cron from .cron import Cron
from .nextrun import NextRun from .nextrun import NextRun
from .config import Configuration, UserConfiguration
def register(): def register():
Pool.register( Pool.register(
Configuration,
UserConfiguration,
Rule, Rule,
ScheduledBooking, ScheduledBooking,
NextRun, NextRun,

48
config.py Normal file
View file

@ -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

15
config.xml Normal file
View file

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!-- 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. -->
<tryton>
<data>
<record model="ir.ui.view" id="configuration_view_form">
<field name="model">cashbook.configuration</field>
<field name="inherit" ref="cashbook.configuration_view_form"/>
<field name="name">configuration_form</field>
</record>
</data>
</tryton>

View file

@ -79,6 +79,22 @@ msgid "User in companies"
msgstr "Benutzer im Unternehmen" 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 # # cashbook.planner #
#################### ####################

View file

@ -58,6 +58,18 @@ msgctxt "model:ir.rule.group,name:rg_nextrun_companies"
msgid "User in companies" msgid "User in companies"
msgstr "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:" msgctxt "model:cashbook.planner,name:"
msgid "Scheduled Booking" msgid "Scheduled Booking"
msgstr "Scheduled Booking" msgstr "Scheduled Booking"

View file

@ -8,6 +8,7 @@ xml:
group.xml group.xml
planner.xml planner.xml
nextrun.xml nextrun.xml
config.xml
cashbook.xml cashbook.xml
cron.xml cron.xml
menu.xml menu.xml

View file

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!-- 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. -->
<data>
<xpath expr="/form/separator[@id='sepcb']" position="before">
<separator id="planner" colspan="4" string="Scheduled Bookings"/>
<label name="holidays"/>
<field name="holidays" colspan="3"/>
<newline/>
</xpath>
</data>