48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
# -*- 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
|