diff --git a/evaluation.py b/evaluation.py
index b36b8b3..d24aa22 100644
--- a/evaluation.py
+++ b/evaluation.py
@@ -85,8 +85,12 @@ class Evaluation(ModelSQL, ModelView):
field='evaluation', readonly=True,
model_name='cashbook_report.eval_line')
- ui_view_chart = fields.Many2One(string='UI View Point',
+ ui_view_chart = fields.Many2One(string='UI View Chart',
model_name='ir.ui.view', ondelete='SET NULL')
+ dashb_actwin = fields.Many2One(string='Dashboard Window',
+ model_name='ir.action.act_window', ondelete='SET NULL')
+ dashb_actview = fields.Many2One(string='Dashboard View',
+ model_name='ir.action.act_window.view', ondelete='SET NULL')
@classmethod
def default_currency(cls):
@@ -140,20 +144,49 @@ class Evaluation(ModelSQL, ModelView):
"""
return 'pie'
+ @classmethod
+ def get_create_view_data(cls, evaluation):
+ """ generate dictionary to create view-xml
+ """
+ return {
+ 'model': 'cashbook_report.eval_line',
+ 'module': 'cashbook_report',
+ 'priority': 10,
+ 'type': 'graph',
+ 'data': template_view_graph % {
+ 'bgcol': '' if evaluation.bgcolor == 'default' \
+ else 'background="%s"' % evaluation.bgcolor,
+ 'legend': '1' if evaluation.legend == True else '0',
+ 'type': evaluation.chart,
+ 'colscheme': '' if evaluation.maincolor == 'default' \
+ else 'color="%s"' % evaluation.maincolor,
+ 'lines': template_view_line % {
+ 'fill': '1',
+ 'string': evaluation.dtype_string,
+ },
+ },
+ }
+
@classmethod
def uiview_delete(cls, evaluations):
""" delete action view from evalualtion
"""
pool = Pool()
UiView = pool.get('ir.ui.view')
+ ActWin = pool.get('ir.action.act_window')
to_delete_uiview = []
+ to_delete_window = []
for evaluation in evaluations:
if evaluation.ui_view_chart:
to_delete_uiview.append(evaluation.ui_view_chart)
+ if evaluation.dashb_actwin:
+ to_delete_window.append(evaluation.dashb_actwin)
if len(to_delete_uiview) > 0:
UiView.delete(to_delete_uiview)
+ if len(to_delete_window) > 0:
+ ActWin.delete(to_delete_window)
@classmethod
def uiview_create(cls, evaluations):
@@ -161,43 +194,41 @@ class Evaluation(ModelSQL, ModelView):
"""
pool = Pool()
UiView = pool.get('ir.ui.view')
+ ActWin = pool.get('ir.action.act_window')
+ ActView = pool.get('ir.action.act_window.view')
Evaluation2 = pool.get('cashbook_report.evaluation')
cls.uiview_delete(evaluations)
to_write_eval = []
for evaluation in evaluations:
- if evaluation.dtype:
- # skip if no data to show
- if len(evaluation.line_values) == 0:
- continue
+ view_graph, = UiView.create([
+ cls.get_create_view_data(evaluation),
+ ])
- view_graph, = UiView.create([{
- 'model': 'cashbook_report.eval_line',
- 'module': 'cashbook_report',
- 'priority': 10,
- 'type': 'graph',
- 'data': template_view_graph % {
- 'bgcol': '' if evaluation.bgcolor == 'default' \
- else 'background="%s"' % evaluation.bgcolor,
- 'legend': '1' if evaluation.legend == True else '0',
- 'type': evaluation.chart,
- 'colscheme': '' if evaluation.maincolor == 'default' \
- else 'color="%s"' % evaluation.maincolor,
- 'lines': template_view_line % {
- 'fill': '1',
- 'string': evaluation.dtype_string,
- },
- },
+ dashb_actwin, = ActWin.create([{
+ 'name': evaluation.dtype_string,
+ 'res_model': 'cashbook_report.eval_line',
+ 'usage': 'dashboard',
+ 'domain': '[["evaluation", "=", %d]]' % evaluation.id,
+ }])
+
+ dashb_actview, = ActView.create([{
+ 'sequence': 10,
+ 'view': view_graph.id,
+ 'act_window': dashb_actwin.id,
}])
to_write_eval.extend([
[evaluation],
{
'ui_view_chart': view_graph.id,
+ 'dashb_actwin': dashb_actwin.id,
+ 'dashb_actview': dashb_actview.id,
}])
if len(to_write_eval) > 0:
+ print('-- to_write_eval:', to_write_eval)
Evaluation2.write(*to_write_eval)
@classmethod
diff --git a/icon/piechart.svg b/icon/piechart.svg
index c1e7045..187d831 100644
--- a/icon/piechart.svg
+++ b/icon/piechart.svg
@@ -4,13 +4,13 @@
-
+
-
+
-
+
-
+
diff --git a/icon/piechart2.svg b/icon/piechart2.svg
deleted file mode 100644
index a8d9351..0000000
--- a/icon/piechart2.svg
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/tests/test_report.py b/tests/test_report.py
index 584f56a..f424f29 100644
--- a/tests/test_report.py
+++ b/tests/test_report.py
@@ -446,7 +446,7 @@ class ReportTestCase(CashbookTestCase):
# must fail
self.assertRaisesRegex(UserError,
- 'A value is required for field "Type" in "Evaluation Line Relation".',
+ 'A value is required for field "Data type" in "Evaluation Line Relation".',
Evaluation.create,
[{
'name': 'Evaluation 1',