neu: kategorie, config + test
This commit is contained in:
parent
b9bb433c39
commit
d6a8b254a3
28 changed files with 1255 additions and 35 deletions
79
configuration.py
Normal file
79
configuration.py
Normal file
|
@ -0,0 +1,79 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# 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.
|
||||
|
||||
from trytond.model import ModelSingleton, ModelView, ModelSQL, Workflow, fields, Check
|
||||
from .model import UserMultiValueMixin, UserValueMixin
|
||||
from trytond.pyson import Eval, If
|
||||
from trytond.pool import Pool
|
||||
|
||||
|
||||
class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
|
||||
'Configuration'
|
||||
__name__ = 'cashbook.configuration'
|
||||
|
||||
date_from = fields.MultiValue(fields.Date(string='Start Date', depends=['date_to'],
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
()),
|
||||
]))
|
||||
date_to = fields.MultiValue(fields.Date(string='End Date', depends=['date_from'],
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
()),
|
||||
]))
|
||||
checked = fields.MultiValue(fields.Boolean(string='Checked'))
|
||||
done = fields.MultiValue(fields.Boolean(string='Done'))
|
||||
|
||||
@classmethod
|
||||
def multivalue_model(cls, field):
|
||||
""" get model for value
|
||||
"""
|
||||
pool = Pool()
|
||||
|
||||
if field in ['date_from', 'date_to', 'checked', 'done']:
|
||||
return pool.get('cashbook.configuration_user')
|
||||
return super(Configuration, cls).multivalue_model(field)
|
||||
|
||||
@classmethod
|
||||
def default_checked(cls, **pattern):
|
||||
return cls.multivalue_model('checked').default_checked()
|
||||
|
||||
@classmethod
|
||||
def default_done(cls, **pattern):
|
||||
return cls.multivalue_model('done').default_done()
|
||||
|
||||
# end Configuration
|
||||
|
||||
|
||||
class UserConfiguration(ModelSQL, UserValueMixin):
|
||||
'User Configuration'
|
||||
__name__ = 'cashbook.configuration_user'
|
||||
|
||||
date_from = fields.Date(string='Start Date', depends=['date_to'],
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
()),
|
||||
])
|
||||
date_to = fields.Date(string='End Date', depends=['date_from'],
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
()),
|
||||
])
|
||||
checked = fields.Boolean(string='Checked')
|
||||
done = fields.Boolean(string='Done')
|
||||
|
||||
@classmethod
|
||||
def default_checked(cls):
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def default_done(cls):
|
||||
return False
|
||||
|
||||
# end UserConfiguration
|
Loading…
Add table
Add a link
Reference in a new issue