cashbook_report/evaluation.py

116 lines
3.2 KiB
Python
Raw Normal View History

2022-10-28 11:27:33 +00:00
# -*- 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 ModelView, ModelSQL, fields, Check
from trytond.pyson import Eval, Or, Bool, Id, Len
from trytond.transaction import Transaction
from .colors import sel_color as sel_bgcolor
sel_etype = [
('book', 'Cashbooks'),
('type', 'Types of Cashbooks'),
('currency', 'Currencys'),
]
sel_chart = [
('vbar', 'Vertical Bars'),
('hbar', 'Horizontal Bars'),
('pie', 'Pie'),
('line', 'Line'),
]
sel_maincolor = [
('default', 'Default'),
('red', 'Red'),
('green', 'Green'),
('grey', 'Grey'),
('black', 'Black'),
('darkcyan', 'Dark Cyan'),
]
class Evaluation(ModelSQL, ModelView):
'Evaluation'
__name__ = 'cashbook_report.evaluation'
company = fields.Many2One(string='Company', model_name='company.company',
required=True, ondelete="RESTRICT")
name = fields.Char(string='Name', required=True)
dtype = fields.Selection(string='Data type', required=True,
sort=False, selection=sel_etype,
help='Type of data displayed')
chart = fields.Selection(string='Chart type', required=True,
sort=False, selection=sel_chart,
help='Type of graphical presentation.')
legend = fields.Boolean(string='Legend')
maincolor = fields.Selection(string='Color scheme', required=True,
help='The color scheme determines the hue of all components of the chart.',
selection=sel_maincolor, sort=False)
bgcolor = fields.Selection(string='Background Color', required=True,
help='Background color of the chart area.', sort=False,
selection=sel_bgcolor)
posted = fields.Boolean(string='Posted', help='Posted amounts only.')
lines = fields.Many2Many(string='Cashbooks',
relation_name='cashbook_report.eval_book',
origin='evaluation', target='cashbook')
2022-10-28 11:27:33 +00:00
@staticmethod
def default_company():
return Transaction().context.get('company') or None
@classmethod
def default_posted(cls):
""" default: False
"""
return False
2022-10-28 11:27:33 +00:00
@classmethod
def default_bgcolor(cls):
""" default: Yellow 5
"""
return '#ffffc0'
@classmethod
def default_maincolor(cls):
""" default: 'default'
"""
return 'default'
@classmethod
def default_legend(cls):
""" default True
"""
return True
@classmethod
def default_dtype(cls):
2022-10-28 11:27:33 +00:00
""" default 'book'
"""
return 'book'
@classmethod
def default_chart(cls):
""" default 'pie'
2022-10-28 11:27:33 +00:00
"""
return 'pie'
# end Evaluation
class EvaluationCashbookRel(ModelSQL):
'Evaluation Cashbook Relation'
__name__ = 'cashbook_report.eval_book'
evaluation = fields.Many2One(string='Evaluation', required=True,
select=True, ondelete='CASCADE',
model_name='cashbook_report.evaluation')
cashbook = fields.Many2One(string='Cashbook', required=True,
select=True, ondelete='CASCADE',
model_name='cashbook.book')
# end EvaluationCashbookRel