diff --git a/kpi/__manifest__.py b/kpi/__manifest__.py
index 3c629dd94..734689a72 100644
--- a/kpi/__manifest__.py
+++ b/kpi/__manifest__.py
@@ -3,12 +3,12 @@
{
"name": "Key Performance Indicator",
- "version": "13.0.1.0.1",
+ "version": "17.0.1.0.0",
"author": "Savoir-faire Linux,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"license": "AGPL-3",
"category": "Report",
- "depends": ["base_external_dbsource"],
+ "depends": ["base_external_dbsource", "spreadsheet_dashboard"],
"data": [
"security/kpi_security.xml",
"security/ir.model.access.csv",
diff --git a/kpi/models/kpi.py b/kpi/models/kpi.py
index 6b1f9312f..b7ebb504a 100644
--- a/kpi/models/kpi.py
+++ b/kpi/models/kpi.py
@@ -16,9 +16,9 @@ _logger = logging.getLogger(__name__)
def is_one_value(result):
# check if sql query returns only one value
- if type(result) is dict and "value" in result.dictfetchone():
+ if isinstance(result, dict) and "value" in result.dictfetchone():
return True
- elif type(result) is list and "value" in result[0]:
+ elif isinstance(result, list) and "value" in result[0]:
return True
else:
return False
@@ -54,8 +54,8 @@ class KPI(models.Model):
_name = "kpi"
_description = "Key Performance Indicator"
- name = fields.Char("Name", required=True)
- description = fields.Text("Description")
+ name = fields.Char(required=True)
+ description = fields.Text()
category_id = fields.Many2one(
"kpi.category",
"Category",
@@ -66,7 +66,7 @@ class KPI(models.Model):
"Threshold",
required=True,
)
- periodicity = fields.Integer("Periodicity", default=1)
+ periodicity = fields.Integer(default=1)
periodicity_uom = fields.Selection(
[
@@ -83,14 +83,11 @@ class KPI(models.Model):
next_execution_date = fields.Datetime(
"Next execution date",
- readonly=True,
)
value = fields.Float(
- string="Value",
compute="_compute_display_last_kpi_value",
)
color = fields.Text(
- "Color",
compute="_compute_display_last_kpi_value",
)
last_execution = fields.Datetime(
@@ -122,7 +119,6 @@ class KPI(models.Model):
"History",
)
active = fields.Boolean(
- "Active",
help=(
"Only active KPIs will be updated by the scheduler based on"
" the periodicity configuration."
diff --git a/kpi/models/kpi_category.py b/kpi/models/kpi_category.py
index 17c572792..6491006c1 100644
--- a/kpi/models/kpi_category.py
+++ b/kpi/models/kpi_category.py
@@ -9,5 +9,5 @@ class KPICategory(models.Model):
_name = "kpi.category"
_description = "KPI Category"
- name = fields.Char("Name", size=50, required=True)
- description = fields.Text("Description")
+ name = fields.Char(required=True)
+ description = fields.Text()
diff --git a/kpi/models/kpi_history.py b/kpi/models/kpi_history.py
index 344d0c09c..e222e0243 100644
--- a/kpi/models/kpi_history.py
+++ b/kpi/models/kpi_history.py
@@ -12,7 +12,6 @@ class KPIHistory(models.Model):
_order = "date desc"
name = fields.Char(
- "Name",
size=150,
required=True,
default=fields.Datetime.now(),
@@ -21,11 +20,10 @@ class KPIHistory(models.Model):
date = fields.Datetime(
"Execution Date",
required=True,
- readonly=True,
default=lambda r: fields.Datetime.now(),
)
- value = fields.Float("Value", required=True, readonly=True)
- color = fields.Text("Color", required=True, readonly=True, default="#FFFFFF")
+ value = fields.Float(required=True)
+ color = fields.Text(required=True, default="#FFFFFF")
company_id = fields.Many2one(
"res.company", "Company", default=lambda self: self.env.company
)
diff --git a/kpi/models/kpi_threshold.py b/kpi/models/kpi_threshold.py
index 51fbdf930..5c9d3f893 100644
--- a/kpi/models/kpi_threshold.py
+++ b/kpi/models/kpi_threshold.py
@@ -34,7 +34,7 @@ class KPIThreshold(models.Model):
"Please make sure your ranges do not overlap."
)
- name = fields.Char("Name", size=50, required=True)
+ name = fields.Char(required=True)
range_ids = fields.Many2many(
"kpi.threshold.range",
"kpi_threshold_range_rel",
@@ -43,7 +43,6 @@ class KPIThreshold(models.Model):
"Ranges",
)
valid = fields.Boolean(
- string="Valid",
required=True,
compute="_compute_is_valid_threshold",
default=True,
@@ -63,10 +62,11 @@ class KPIThreshold(models.Model):
range_obj1 = self.env["kpi.threshold.range"]
range_obj2 = self.env["kpi.threshold.range"]
if data.get("range_ids"):
- for range1 in data["range_ids"][0][2]:
- range_obj1 = range_obj1.browse(range1)
- for range2 in data["range_ids"][0][2]:
- range_obj2 = range_obj2.browse(range2)
+ for range1 in data["range_ids"]:
+ range_obj1 = range_obj1.browse(range1[1])
+ for range2 in data["range_ids"]:
+ range_obj2 = range_obj2.browse(range2[1])
+
if (
range_obj1.valid
and range_obj2.valid
@@ -79,7 +79,7 @@ class KPIThreshold(models.Model):
)
range_obj2 = self.env["kpi.threshold.range"]
range_obj1 = self.env["kpi.threshold.range"]
- return super(KPIThreshold, self).create(data)
+ return super().create(data)
def get_color(self, kpi_value):
color = "#FFFFFF"
diff --git a/kpi/models/kpi_threshold_range.py b/kpi/models/kpi_threshold_range.py
index 434c4d489..4c669170b 100644
--- a/kpi/models/kpi_threshold_range.py
+++ b/kpi/models/kpi_threshold_range.py
@@ -9,9 +9,9 @@ from odoo.tools.safe_eval import safe_eval
def is_one_value(result):
# check if sql query returns only one value
- if type(result) is dict and "value" in result.dictfetchone():
+ if isinstance(result, dict) and "value" in result.dictfetchone():
return True
- elif type(result) is list and "value" in result[0]:
+ elif isinstance(result, list) and "value" in result[0]:
return True
else:
return False
@@ -58,16 +58,14 @@ class KPIThresholdRange(models.Model):
("external", "SQL - External DB"),
]
- name = fields.Char("Name", size=50, required=True)
+ name = fields.Char(required=True)
valid = fields.Boolean(
- string="Valid", required=True, compute="_compute_is_valid_range", default=True
+ required=True, compute="_compute_is_valid_range", default=True
)
invalid_message = fields.Char(
string="Message", size=100, compute="_compute_is_valid_range"
)
- min_type = fields.Selection(
- selection="_selection_value_type", string="Min Type", required=True
- )
+ min_type = fields.Selection(selection="_selection_value_type", required=True)
min_value = fields.Float(string="Minimum Value", compute="_compute_min_value")
min_fixed_value = fields.Float("Minimum Fixed Value")
min_code = fields.Text("Minimum Computation Code")
@@ -76,9 +74,7 @@ class KPIThresholdRange(models.Model):
"base.external.dbsource",
"External DB Source Minimum",
)
- max_type = fields.Selection(
- selection="_selection_value_type", string="Max Type", required=True
- )
+ max_type = fields.Selection(selection="_selection_value_type", required=True)
max_value = fields.Float(string="Maximum Value", compute="_compute_max_value")
max_fixed_value = fields.Float("Maximum Fixed Value")
max_code = fields.Text("Maximum Computation Code")
@@ -88,7 +84,7 @@ class KPIThresholdRange(models.Model):
"External DB Source Maximum",
)
- color = fields.Char(string="Color", help="Choose your color")
+ color = fields.Char(help="Choose your color")
threshold_ids = fields.Many2many(
"kpi.threshold",
diff --git a/kpi/static/description/icon.png b/kpi/static/description/icon.png
index 3a0328b51..9e53b1e96 100644
Binary files a/kpi/static/description/icon.png and b/kpi/static/description/icon.png differ
diff --git a/kpi/static/description/icon.svg b/kpi/static/description/icon.svg
new file mode 100644
index 000000000..2d9daf9ba
--- /dev/null
+++ b/kpi/static/description/icon.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/kpi/tests/test_kpi.py b/kpi/tests/test_kpi.py
index 96c63eb42..4953efe3b 100644
--- a/kpi/tests/test_kpi.py
+++ b/kpi/tests/test_kpi.py
@@ -4,8 +4,9 @@ from odoo.tests.common import TransactionCase
class TestKPI(TransactionCase):
- def setUp(self):
- super(TestKPI, self).setUp()
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
def test_invalid_threshold_range(self):
range1 = self.env["kpi.threshold.range"].create(
diff --git a/kpi/views/kpi_category_views.xml b/kpi/views/kpi_category_views.xml
index 466c5b80a..c809068a0 100644
--- a/kpi/views/kpi_category_views.xml
+++ b/kpi/views/kpi_category_views.xml
@@ -7,7 +7,7 @@
kpi.category.tree
kpi.category
-
+
diff --git a/kpi/views/kpi_history_views.xml b/kpi/views/kpi_history_views.xml
index c2abf7ebd..635368c4d 100644
--- a/kpi/views/kpi_history_views.xml
+++ b/kpi/views/kpi_history_views.xml
@@ -7,11 +7,11 @@
kpi.history.tree
kpi.history
-
+
-
-
-
+
+
+
@@ -25,9 +25,9 @@
-
-
-
+
+
+
diff --git a/kpi/views/kpi_threshold_range_views.xml b/kpi/views/kpi_threshold_range_views.xml
index 1473a32df..0ad77474b 100644
--- a/kpi/views/kpi_threshold_range_views.xml
+++ b/kpi/views/kpi_threshold_range_views.xml
@@ -7,11 +7,11 @@
kpi.threshold.range.tree
kpi.threshold.range
-
+
-
+
@@ -39,23 +39,19 @@
-
+
@@ -63,25 +59,21 @@
-
+
@@ -89,13 +81,13 @@
diff --git a/kpi/views/kpi_threshold_views.xml b/kpi/views/kpi_threshold_views.xml
index 280181ccf..c69ac6e42 100644
--- a/kpi/views/kpi_threshold_views.xml
+++ b/kpi/views/kpi_threshold_views.xml
@@ -7,7 +7,7 @@
kpi.threshold.tree
kpi.threshold
-
+
@@ -38,13 +38,13 @@
diff --git a/kpi/views/kpi_views.xml b/kpi/views/kpi_views.xml
index 34d68da09..85cc9bc35 100644
--- a/kpi/views/kpi_views.xml
+++ b/kpi/views/kpi_views.xml
@@ -8,9 +8,9 @@
kpi
-
+
-
+
@@ -24,8 +24,8 @@
-
-
+
+
@@ -41,7 +41,7 @@
t-attf-style="color:#{record.color.raw_value}"
>
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -152,7 +159,7 @@
- KPI Maintenance
+ KPI
kpi
tree,form
diff --git a/kpi/views/menu.xml b/kpi/views/menu.xml
index b951090e8..58e7b145d 100644
--- a/kpi/views/menu.xml
+++ b/kpi/views/menu.xml
@@ -2,19 +2,21 @@
+
+