Browse Source

Fix threshold valid computation and added <sheet> to forms

pull/1095/head
Iván Todorovich 7 years ago
parent
commit
6da566c47e
  1. 19
      kpi/models/kpi_threshold.py
  2. 64
      kpi/views/kpi.xml
  3. 12
      kpi/views/kpi_category.xml
  4. 18
      kpi/views/kpi_history.xml
  5. 35
      kpi/views/kpi_threshold.xml
  6. 62
      kpi/views/kpi_threshold_range.xml

19
kpi/models/kpi_threshold.py

@ -21,19 +21,14 @@ class KPIThreshold(models.Model):
for range2 in obj.range_ids: for range2 in obj.range_ids:
if (range1.valid and range2.valid and if (range1.valid and range2.valid and
range1.min_value < range2.min_value): range1.min_value < range2.min_value):
result[obj.id] = range1.max_value <= range2.min_value
return result
@api.multi
def _compute_generate_invalid_message(self):
result = {}
for obj in self:
obj.valid = range1.max_value <= range2.min_value
if obj.valid: if obj.valid:
result[obj.id] = ""
obj.invalid_message = None
else: else:
result[obj.id] = ("Two of your ranges are overlapping. Please "
"make sure your ranges do not overlap.")
return result
obj.invalid_message = (
"Some ranges are invalid or overlapping. "
"Please make sure your ranges do not overlap.")
name = fields.Char('Name', size=50, required=True) name = fields.Char('Name', size=50, required=True)
range_ids = fields.Many2many( range_ids = fields.Many2many(
@ -46,7 +41,7 @@ class KPIThreshold(models.Model):
valid = fields.Boolean(string='Valid', required=True, valid = fields.Boolean(string='Valid', required=True,
compute="_compute_is_valid_threshold", default=True) compute="_compute_is_valid_threshold", default=True)
invalid_message = fields.Char(string='Message', size=100, invalid_message = fields.Char(string='Message', size=100,
compute="_compute_generate_invalid_message")
compute="_compute_is_valid_threshold")
kpi_ids = fields.One2many('kpi', 'threshold_id', 'KPIs') kpi_ids = fields.One2many('kpi', 'threshold_id', 'KPIs')
company_id = fields.Many2one( company_id = fields.Many2one(
'res.company', 'Company', 'res.company', 'Company',

64
kpi/views/kpi.xml

@ -48,37 +48,39 @@
<field name="model">kpi</field> <field name="model">kpi</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Key Performance Indicator"> <form string="Key Performance Indicator">
<group col="6" colspan="6">
<field name="name" colspan="2"/>
<field name="threshold_id" colspan="2"/>
<field name="category_id" colspan="2"/>
<newline/>
<field name="value" colspan="2"/>
<button name="compute_kpi_value" string="Compute KPI Now" colspan="2" type="object"/>
<field name="active" colspan="2"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<notebook colspan="6">
<page string="History">
<field name="history_ids" readonly="1" nolabel="1"/>
</page>
<page string="Computation">
<group col="6">
<field name="periodicity" colspan="2"/>
<field name="periodicity_uom" colspan="2"/>
<field name="next_execution_date" colspan="2"/>
<separator string="KPI Computation" colspan="6"/>
<newline/>
<field name="kpi_type" colspan="2"/>
<field name="dbsource_id" colspan="2" attrs="{'invisible' : [('kpi_type', '!=', 'external')]}"/>
<newline/>
<field name="kpi_code" colspan="6"/>
</group>
</page>
<page string="Description">
<field name="description" nolabel="1"/>
</page>
</notebook>
<sheet>
<group col="6" colspan="6">
<field name="name" colspan="2"/>
<field name="threshold_id" colspan="2"/>
<field name="category_id" colspan="2"/>
<newline/>
<field name="value" colspan="2"/>
<button name="compute_kpi_value" string="Compute KPI Now" colspan="2" type="object"/>
<field name="active" colspan="2"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<notebook colspan="6">
<page string="History">
<field name="history_ids" readonly="1" nolabel="1"/>
</page>
<page string="Computation">
<group col="6">
<field name="periodicity" colspan="2"/>
<field name="periodicity_uom" colspan="2"/>
<field name="next_execution_date" colspan="2"/>
<separator string="KPI Computation" colspan="6"/>
<newline/>
<field name="kpi_type" colspan="2"/>
<field name="dbsource_id" colspan="2" attrs="{'invisible' : [('kpi_type', '!=', 'external')]}"/>
<newline/>
<field name="kpi_code" colspan="6"/>
</group>
</page>
<page string="Description">
<field name="description" nolabel="1"/>
</page>
</notebook>
</sheet>
</form> </form>
</field> </field>
</record> </record>

12
kpi/views/kpi_category.xml

@ -23,11 +23,13 @@
<field name="model">kpi.category</field> <field name="model">kpi.category</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Category"> <form string="Category">
<group col="2" colspan="2">
<field name="name" colspan="2"/>
<newline/>
<field name="description" colspan="2"/>
</group>
<sheet>
<group col="2" colspan="2">
<field name="name" colspan="2"/>
<newline/>
<field name="description" colspan="2"/>
</group>
</sheet>
</form> </form>
</field> </field>
</record> </record>

18
kpi/views/kpi_history.xml

@ -23,14 +23,16 @@
<field name="model">kpi.history</field> <field name="model">kpi.history</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="KPI History"> <form string="KPI History">
<group col="4" colspan="4">
<field name="kpi_id"/>
<field name="name"/>
<field name="date"/>
<field name="value"/>
<field name="color" widget="color"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<sheet>
<group col="4" colspan="4">
<field name="kpi_id"/>
<field name="name"/>
<field name="date"/>
<field name="value"/>
<field name="color" widget="color"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</sheet>
</form> </form>
</field> </field>
</record> </record>

35
kpi/views/kpi_threshold.xml

@ -9,7 +9,7 @@
<field name="name">kpi.threshold.tree</field> <field name="name">kpi.threshold.tree</field>
<field name="model">kpi.threshold</field> <field name="model">kpi.threshold</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Thresholds">
<tree string="Thresholds" decoration-danger="invalid_message">
<field name="name"/> <field name="name"/>
<field name="invalid_message"/> <field name="invalid_message"/>
<field name="company_id" groups="base.group_multi_company"/> <field name="company_id" groups="base.group_multi_company"/>
@ -22,21 +22,24 @@
<field name="model">kpi.threshold</field> <field name="model">kpi.threshold</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Threshold"> <form string="Threshold">
<group col="6" colspan="6">
<field name="name" colspan="2"/>
<field name="company_id" groups="base.group_multi_company" colspan="2"/>
<newline/>
<separator string="Ranges" colspan="6"/>
<newline/>
<field name="range_ids" nolabel="1" colspan="6"/>
<newline/>
<separator string="KPIs" colspan="6"/>
<newline/>
<field name="kpi_ids" nolabel="1" colspan="6"/>
<newline/>
<field name="invalid_message" nolabel="1" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="2"/>
<newline/>
</group>
<sheet>
<group col="6" colspan="6">
<field name="name" colspan="2"/>
<field name="company_id" groups="base.group_multi_company" colspan="2"/>
<newline/>
<separator string="Ranges" colspan="6"/>
<newline/>
<field name="range_ids" nolabel="1" colspan="6"/>
<newline/>
<separator string="KPIs" colspan="6"/>
<newline/>
<field name="kpi_ids" nolabel="1" colspan="6"/>
<newline/>
<separator string="Errors" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="4"/>
<field name="invalid_message" nolabel="1" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="4"/>
<newline/>
</group>
</sheet>
</form> </form>
</field> </field>
</record> </record>

62
kpi/views/kpi_threshold_range.xml

@ -25,37 +25,39 @@
<field name="model">kpi.threshold.range</field> <field name="model">kpi.threshold.range</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Range"> <form string="Range">
<group col="6" colspan="6">
<field name="name"/>
<field name="color"/>
<field name="company_id" groups="base.group_multi_company"/>
<newline/>
<sheet>
<group col="6" colspan="6">
<field name="name"/>
<field name="color"/>
<field name="company_id" groups="base.group_multi_company"/>
<newline/>
<separator string="Minimum" colspan="4"/>
<newline/>
<field name="min_type" colspan="2"/>
<field name="min_fixed_value" colspan="2" attrs="{'invisible' : [('min_type', '!=', 'static')]}"/>
<field name="min_dbsource_id" colspan="2" attrs="{'invisible' : [('min_type', '!=', 'external')]}"/>
<newline/>
<field name="min_code" colspan="6" attrs="{'invisible' : [('min_type', 'NOT IN', ('local','external','python'))]}"/>
<newline/>
<field name="min_error" colspan="6" attrs="{'invisible': [('min_error', '=', False)]}" />
<newline/>
<separator string="Maximum" colspan="4"/>
<newline/>
<field name="max_type"/>
<field name="max_fixed_value" attrs="{'invisible' : [('max_type', '!=', 'static')]}"/>
<field name="max_dbsource_id" attrs="{'invisible' : [('max_type', '!=', 'external')]}"/>
<newline/>
<field name="max_code" colspan="6" attrs="{'invisible' : [('max_type', 'NOT IN', ('local','external','python'))]}"/>
<newline/>
<field name="max_error" colspan="6" attrs="{'invisible': [('max_error', '=', False)]}" />
<newline/>
<separator string="Thresholds" colspan="4"/>
<field name="threshold_ids" nolabel="1" colspan="4"/>
<separator string="Errors" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="4"/>
<field name="invalid_message" nolabel="1" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="4"/>
</group>
<separator string="Minimum" colspan="4"/>
<newline/>
<field name="min_type" colspan="2"/>
<field name="min_fixed_value" colspan="2" attrs="{'invisible' : [('min_type', '!=', 'static')]}"/>
<field name="min_dbsource_id" colspan="2" attrs="{'invisible' : [('min_type', '!=', 'external')]}"/>
<newline/>
<field name="min_code" colspan="6" attrs="{'invisible' : [('min_type', 'NOT IN', ('local','external','python'))]}"/>
<newline/>
<field name="min_error" colspan="6" attrs="{'invisible': [('min_error', '=', False)]}" />
<newline/>
<separator string="Maximum" colspan="4"/>
<newline/>
<field name="max_type"/>
<field name="max_fixed_value" attrs="{'invisible' : [('max_type', '!=', 'static')]}"/>
<field name="max_dbsource_id" attrs="{'invisible' : [('max_type', '!=', 'external')]}"/>
<newline/>
<field name="max_code" colspan="6" attrs="{'invisible' : [('max_type', 'NOT IN', ('local','external','python'))]}"/>
<newline/>
<field name="max_error" colspan="6" attrs="{'invisible': [('max_error', '=', False)]}" />
<newline/>
<separator string="Thresholds" colspan="4"/>
<field name="threshold_ids" nolabel="1" colspan="4"/>
<separator string="Errors" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="4"/>
<field name="invalid_message" nolabel="1" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="4"/>
</group>
</sheet>
</form> </form>
</field> </field>
</record> </record>

Loading…
Cancel
Save