[IMP] kpi_dashboard: Set history & Add compute on the fly & Show value on kpi computation

This commit is contained in:
Enric Tobella
2020-07-07 12:37:05 +02:00
parent c519637842
commit 025c4dae22
7 changed files with 278 additions and 12 deletions

View File

@@ -4,6 +4,55 @@
<odoo>
<record model="ir.actions.act_window" id="kpi_kpi_history_act_window">
<field name="name">Kpi History</field>
<field name="res_model">kpi.kpi.history</field>
<field name="view_mode">tree</field>
<field name="domain">[('kpi_id', '=', active_id)]</field>
<field name="context">{}</field>
</record>
<record model="ir.ui.view" id="kpi_kpi_history_widget_form_view">
<field name="name">kpi.kpi.history.raw.form (in kpi_dashboard)</field>
<field name="model">kpi.kpi.history</field>
<field name="arch" type="xml">
<form>
<field name="create_date" invisible="1"/>
<field name="widget" invisible="1"/>
<field name="name" invisible="1"/>
<field name="value"
widget="kpi"
options="{'date': 'create_date', 'widget': 'widget', 'name': 'name'}"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="kpi_kpi_history_raw_form_view">
<field name="name">kpi.kpi.history.raw.form (in kpi_dashboard)</field>
<field name="model">kpi.kpi.history</field>
<field name="arch" type="xml">
<form>
<field name="raw_value"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="kpi_kpi_history_tree_view">
<field name="name">kpi.kpi.history.tree (in kpi_dashboard)</field>
<field name="model">kpi.kpi.history</field>
<field name="arch" type="xml">
<tree create="0" delete="0">
<field name="create_date"/>
<button name="show_form" string="Show value" type="object"
context="{'form_id': %(kpi_dashboard.kpi_kpi_history_widget_form_view)d}"
/>
<button name="show_form" string="Raw value" type="object"
context="{'form_id': %(kpi_dashboard.kpi_kpi_history_raw_form_view)d}"
/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="kpi_kpi_form_view">
<field name="name">kpi.kpi.form (in kpi_dashboard)</field>
<field name="model">kpi.kpi</field>
@@ -11,11 +60,20 @@
<form>
<header>
<button name="generate_cron" string="Generate cron" type="object"
attrs="{'invisible': [('cron_id', '!=',False)]}"/>
<button name="compute" string="Compute now" type="object"/>
attrs="{'invisible': ['|', ('cron_id', '!=',False), ('compute_on_fly', '=', True)]}"/>
<button name="compute" string="Compute now" type="object" attrs="{'invisible': [('compute_on_fly', '=', True)]}"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box"/>
<div class="oe_button_box" name="button_box">
<button name="%(kpi_dashboard.kpi_kpi_history_act_window)d"
string="Show history"
type="action"
attrs="{'invisible': ['|', ('store_history', '=', False), ('compute_on_fly', '=', True)]}"
icon="fa-history"/>
<button string="Show value" type="object" name="show_value"
icon="fa-paint-brush"
/>
</div>
<h2>
<field name="name"/>
</h2>
@@ -23,6 +81,10 @@
<group>
<field name="computation_method"/>
<field name="widget"/>
<field name="store_history" attrs="{'invisible': [('compute_on_fly', '=', True)]}"/>
<field name="store_history_interval" attrs="{'invisible': [('store_history', '=', False)]}"/>
<field name="store_history_interval_number" attrs="{'invisible': [('store_history', '=', False)]}"/>
<field name="compute_on_fly" attrs="{'invisible': [('store_history', '=', True)]}"/>
<field name="model_id" attrs="{'invisible': [('computation_method', '!=', 'function')]}"/>
<field name="function" attrs="{'required': [('computation_method', '=', 'function')], 'invisible': [('computation_method', '!=', 'function')]}"/>
<field name="args" attrs="{'invisible': [('computation_method', '!=', 'function')]}"/>
@@ -56,6 +118,21 @@
</field>
</record>
<record model="ir.ui.view" id="kpi_kpi_widget_form_view">
<field name="name">kpi.kpi.raw.form (in kpi_dashboard)</field>
<field name="model">kpi.kpi</field>
<field name="arch" type="xml">
<form>
<field name="computed_date" invisible="1"/>
<field name="widget" invisible="1"/>
<field name="name" invisible="1"/>
<field name="computed_value"
widget="kpi"
options="{'date': 'computed_date', 'widget': 'widget', 'name': 'name'}"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="kpi_kpi_search_view">
<field name="name">kpi.kpi.search (in kpi_dashboard)</field>
<field name="model">kpi.kpi</field>

View File

@@ -18,6 +18,7 @@
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/meter_widget.js"/>
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/graph_widget.js"/>
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/text_widget.js"/>
<script type="text/javascript" src="/kpi_dashboard/static/src/js/field_widget.js"/>
<link rel="stylesheet" type="text/scss" href="/kpi_dashboard/static/src/scss/kpi_dashboard.scss"/>
</xpath>