dashboard-view ok
This commit is contained in:
parent
a2d715a54d
commit
bf7943af46
4 changed files with 58 additions and 59 deletions
|
@ -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
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
<sodipodi:namedview id="base" bordercolor="#666666" inkscape:pageshadow="2" inkscape:window-y="0" pagecolor="#ffffff" inkscape:window-maximized="0" inkscape:zoom="0.52073327" inkscape:window-x="0" inkscape:window-height="645" showgrid="false" borderopacity="1.0" inkscape:current-layer="layer1" inkscape:cx="-149.55582" inkscape:cy="165.38383" inkscape:window-width="674" inkscape:pageopacity="0.0" inkscape:document-units="px"/>
|
||||
<g id="layer1" inkscape:label="Capa 1" inkscape:groupmode="layer" transform="translate(-208.58 -360.8)">
|
||||
<g id="g3809" inkscape:export-ydpi="90" inkscape:export-xdpi="90">
|
||||
<path id="path2985" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#31c7fd" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-89.09 0-161.31-73.081-161.31-163.23 0-90.15 72.221-163.23 161.31-163.23 89.09 0 161.31 73.081 161.31 163.23z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391"/>
|
||||
<path id="path2985" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#fcb900" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-89.09 0-161.31-73.081-161.31-163.23 0-90.15 72.221-163.23 161.31-163.23 89.09 0 161.31 73.081 161.31 163.23z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391"/>
|
||||
|
||||
<path id="path2985-4" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#f4ff50" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-89.09 0-161.31-73.081-161.31-163.23 0-90.15 72.221-163.23 161.31-163.23 12.339 0 24.638 1.4327 36.655 4.27l-36.65 158.96z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391" sodipodi:end="4.9416218" sodipodi:start="0"/>
|
||||
<path id="path2985-4" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#fc0a00" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-89.09 0-161.31-73.081-161.31-163.23 0-90.15 72.221-163.23 161.31-163.23 12.339 0 24.638 1.4327 36.655 4.27l-36.65 158.96z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391" sodipodi:end="4.9416218" sodipodi:start="0"/>
|
||||
|
||||
<path id="path2985-7" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#ff8830" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-89.09 0-161.31-73.081-161.31-163.23 0-18.33 3.0511-36.529 9.0253-53.834l152.29 53.834z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391" sodipodi:end="3.4776855" sodipodi:start="0"/>
|
||||
<path id="path2985-7" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#153ca9" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-89.09 0-161.31-73.081-161.31-163.23 0-18.33 3.0511-36.529 9.0253-53.834l152.29 53.834z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391" sodipodi:end="3.4776855" sodipodi:start="0"/>
|
||||
|
||||
<path id="path2985-1" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#21b720" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-49.766 0-96.747-23.244-127.31-62.988l127.31-100.24z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391" sodipodi:end="2.4803257" sodipodi:start="0"/>
|
||||
<path id="path2985-1" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#06cb00" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-49.766 0-96.747-23.244-127.31-62.988l127.31-100.24z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391" sodipodi:end="2.4803257" sodipodi:start="0"/>
|
||||
</g>
|
||||
</g>
|
||||
<metadata id="metadata10">
|
||||
|
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" id="svg2" sodipodi:docname="_svgclean2.svg" viewBox="0 0 326.92 330.76" version="1.1" inkscape:version="0.48.3.1 r9886">
|
||||
<sodipodi:namedview id="base" bordercolor="#666666" inkscape:pageshadow="2" inkscape:window-y="0" pagecolor="#ffffff" inkscape:window-maximized="0" inkscape:zoom="0.52073327" inkscape:window-x="0" inkscape:window-height="645" showgrid="false" borderopacity="1.0" inkscape:current-layer="layer1" inkscape:cx="-149.55582" inkscape:cy="165.38383" inkscape:window-width="674" inkscape:pageopacity="0.0" inkscape:document-units="px"/>
|
||||
<g id="layer1" inkscape:label="Capa 1" inkscape:groupmode="layer" transform="translate(-208.58 -360.8)">
|
||||
<g id="g3809" inkscape:export-ydpi="90" inkscape:export-xdpi="90">
|
||||
<path id="path2985" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#0197fd" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-89.09 0-161.31-73.081-161.31-163.23 0-90.15 72.221-163.23 161.31-163.23 89.09 0 161.31 73.081 161.31 163.23z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391"/>
|
||||
<path id="path2985-4" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#f3ff00" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-89.09 0-161.31-73.081-161.31-163.23 0-90.15 72.221-163.23 161.31-163.23 12.339 0 24.638 1.4327 36.655 4.27l-36.65 158.96z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391" sodipodi:end="4.9416218" sodipodi:start="0"/>
|
||||
<path id="path2985-7" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#ff0000" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-89.09 0-161.31-73.081-161.31-163.23 0-18.33 3.0511-36.529 9.0253-53.834l152.29 53.834z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391" sodipodi:end="3.4776855" sodipodi:start="0"/>
|
||||
<path id="path2985-1" sodipodi:rx="161.31099" sodipodi:ry="163.23135" style="stroke:#000000;stroke-width:4.3;stroke-opacity:.55080;fill:#019700" sodipodi:type="arc" d="m389.83 174.75c0 90.15-72.221 163.23-161.31 163.23-49.766 0-96.747-23.244-127.31-62.988l127.31-100.24z" transform="translate(143.52,351.43)" sodipodi:cy="174.75357" sodipodi:cx="228.52391" sodipodi:end="2.4803257" sodipodi:start="0"/>
|
||||
</g>
|
||||
</g>
|
||||
<metadata id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work>
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<cc:license rdf:resource="http://creativecommons.org/licenses/publicdomain/"/>
|
||||
<dc:publisher>
|
||||
<cc:Agent rdf:about="http://openclipart.org/">
|
||||
<dc:title>Openclipart</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:publisher>
|
||||
</cc:Work>
|
||||
<cc:License rdf:about="http://creativecommons.org/licenses/publicdomain/">
|
||||
<cc:permits rdf:resource="http://creativecommons.org/ns#Reproduction"/>
|
||||
<cc:permits rdf:resource="http://creativecommons.org/ns#Distribution"/>
|
||||
<cc:permits rdf:resource="http://creativecommons.org/ns#DerivativeWorks"/>
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
</svg>
|
Before Width: | Height: | Size: 3.7 KiB |
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue