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. 2
      kpi/views/kpi.xml
  3. 2
      kpi/views/kpi_category.xml
  4. 2
      kpi/views/kpi_history.xml
  5. 7
      kpi/views/kpi_threshold.xml
  6. 2
      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:
if (range1.valid and range2.valid and
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:
result[obj.id] = ""
obj.invalid_message = None
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)
range_ids = fields.Many2many(
@ -46,7 +41,7 @@ class KPIThreshold(models.Model):
valid = fields.Boolean(string='Valid', required=True,
compute="_compute_is_valid_threshold", default=True)
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')
company_id = fields.Many2one(
'res.company', 'Company',

2
kpi/views/kpi.xml

@ -48,6 +48,7 @@
<field name="model">kpi</field>
<field name="arch" type="xml">
<form string="Key Performance Indicator">
<sheet>
<group col="6" colspan="6">
<field name="name" colspan="2"/>
<field name="threshold_id" colspan="2"/>
@ -79,6 +80,7 @@
<field name="description" nolabel="1"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

2
kpi/views/kpi_category.xml

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

2
kpi/views/kpi_history.xml

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

7
kpi/views/kpi_threshold.xml

@ -9,7 +9,7 @@
<field name="name">kpi.threshold.tree</field>
<field name="model">kpi.threshold</field>
<field name="arch" type="xml">
<tree string="Thresholds">
<tree string="Thresholds" decoration-danger="invalid_message">
<field name="name"/>
<field name="invalid_message"/>
<field name="company_id" groups="base.group_multi_company"/>
@ -22,6 +22,7 @@
<field name="model">kpi.threshold</field>
<field name="arch" type="xml">
<form string="Threshold">
<sheet>
<group col="6" colspan="6">
<field name="name" colspan="2"/>
<field name="company_id" groups="base.group_multi_company" colspan="2"/>
@ -34,9 +35,11 @@
<newline/>
<field name="kpi_ids" nolabel="1" colspan="6"/>
<newline/>
<field name="invalid_message" nolabel="1" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="2"/>
<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>
</field>
</record>

2
kpi/views/kpi_threshold_range.xml

@ -25,6 +25,7 @@
<field name="model">kpi.threshold.range</field>
<field name="arch" type="xml">
<form string="Range">
<sheet>
<group col="6" colspan="6">
<field name="name"/>
<field name="color"/>
@ -56,6 +57,7 @@
<separator string="Errors" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="4"/>
<field name="invalid_message" nolabel="1" attrs="{'invisible' : [('invalid_message', '=', '')]}" colspan="4"/>
</group>
</sheet>
</form>
</field>
</record>

Loading…
Cancel
Save