diff --git a/evaluation.py b/evaluation.py
index 33aa59e..1ad6cd7 100644
--- a/evaluation.py
+++ b/evaluation.py
@@ -12,6 +12,7 @@ from trytond.i18n import gettext
from trytond.exceptions import UserError
from trytond.pool import Pool
from .colors import sel_color as sel_bgcolor
+from .templates import template_view_graph, template_view_line
sel_etype = [
@@ -93,6 +94,11 @@ class Evaluation(ModelSQL, ModelView):
field='evaluation', readonly=True,
model_name='cashbook_report.eval_type')
+ action_view = fields.Many2One(string='Action View',
+ model_name='ir.action.act_window', ondelete='SET NULL')
+ ui_view_point = fields.Many2One(string='UI View Point',
+ model_name='ir.ui.view', ondelete='SET NULL')
+
@classmethod
def default_currency(cls):
""" currency of company
@@ -145,6 +151,73 @@ class Evaluation(ModelSQL, ModelView):
"""
return 'pie'
+ @classmethod
+ def actionview_create(cls, evaluations):
+ """ create action views for current setup of evaluation
+
+ """
+ pool = Pool()
+ ActionActWindow = pool.get('ir.action.act_window')
+ UiView = pool.get('ir.ui.view')
+
+ #cls.actionview_delete(charts)
+
+ to_write_eval = []
+ for evaluation in evaluations:
+ if evaluation.dtype:
+ if getattr(evaluation, evaluation.dtype) == 0:
+ continue
+
+ view_graph, = UiView.create([{
+ 'model': 'cashbook_report.%s' % {
+ 'cashbooks': 'eval_book',
+ 'types': 'eval_type',
+ 'currenciews': 'eval_currency',
+ }[evaluation.dtype],
+ 'module': 'cashbook_report',
+ 'priority': 10,
+ 'type': 'graph',
+ 'data': template_view_graph % {
+ 'bgcol': '#ffffc0',
+ 'legend': '1',
+ 'lines': template_view_line % {
+ 'fill': '1',
+ 'string': evaluation.dtype,
+ },
+ },
+ }])
+
+ view_chart, = UiView.create([{
+ 'model': 'cashbook_reporting.chart',
+ 'module': 'cashbook_reporting',
+ 'priority': 10,
+ 'type': 'form',
+ 'data': template_view_chart % {
+ 'view_ids': view_point.id,
+ 'fname': html.escape(chart.name),
+ },
+ }])
+
+ action_view, = ActionActWindow.create([{
+ 'res_model': 'cashbook_reporting.chart',
+ 'name': chart.name,
+ 'act_window_views': [('create', [{
+ 'view': view_chart.id,
+ 'sequence': 1,
+ }])],
+ }])
+
+ to_write_chart.extend([
+ [chart],
+ {
+ 'ui_view_point': view_point.id,
+ 'ui_view_chart': view_chart.id,
+ 'action_view': action_view.id,
+ }])
+
+ if len(to_write_chart) > 0:
+ Chart2.write(*to_write_chart)
+
@classmethod
def write(cls, *args):
""" unlink records if dtype changes
diff --git a/templates.py b/templates.py
index 7f0e2a8..75d361d 100644
--- a/templates.py
+++ b/templates.py
@@ -4,12 +4,12 @@
# full copyright notices and license terms.
-template_view_line = ''
+template_view_line = ''
-template_view_point = """
+template_view_graph = """
-
+
%(lines)s