diff --git a/kpi_dashboard/README.rst b/kpi_dashboard/README.rst
index ddc8b4889..db74bc809 100644
--- a/kpi_dashboard/README.rst
+++ b/kpi_dashboard/README.rst
@@ -45,6 +45,18 @@ Configure KPIs
#. Meter: result must contain `value`, `min` and `max`
#. Graph: result must contain a list on `graphs` containing `values`, `title` and `key`
+#. In order to compute the KPI you can use a predefined function from a model or
+ use the code to directly compute it.
+
+Using KPI with code
+~~~~~~~~~~~~~~~~~~~
+
+Define the code directly on the code field. You can use:
+
+* `self` and `model` as the kpi element
+* The script should create a variable called `result` as a dictionary that
+ will be stored as the value
+
Configure dashboards
~~~~~~~~~~~~~~~~~~~~
diff --git a/kpi_dashboard/__manifest__.py b/kpi_dashboard/__manifest__.py
index c655897cc..7f45bb92b 100644
--- a/kpi_dashboard/__manifest__.py
+++ b/kpi_dashboard/__manifest__.py
@@ -20,4 +20,5 @@
"views/kpi_kpi.xml",
"views/kpi_dashboard.xml",
],
+ "demo": ["demo/demo_dashboard.xml"],
}
diff --git a/kpi_dashboard/demo/demo_dashboard.xml b/kpi_dashboard/demo/demo_dashboard.xml
new file mode 100644
index 000000000..e86f457b0
--- /dev/null
+++ b/kpi_dashboard/demo/demo_dashboard.xml
@@ -0,0 +1,157 @@
+
+
+
+ Dashboard
+ 4
+ 50
+ 250
+ #020202
+
+
+
+ Number 01
+ $
+ code
+ number
+
+result = {"value": 10000,"previous": 12000}
+
+
+
+
+ Number 02
+ €
+ code
+ number
+
+result = {"value": 12000,"previous": 10000}
+
+
+
+
+
+
+ Meter 01
+ €
+ code
+ meter
+
+result = {"min": 0, "max": 100, "value": 90}
+
+
+
+
+ Meter 02
+ $
+ code
+ meter
+
+result = {"min": 0, "max": 100, "value": 40}
+
+
+
+
+
+
+ Graph
+ code
+ graph
+
+result = {"graphs": [
+ {
+ "values": [
+ {"x": i, "y": i * 1000}
+ for i in range(1, 12)
+ ],
+ "title": "Current Year",
+ "key": "current",
+ "area": True,
+ "color": "ffffff",
+ },
+ {
+ "values": [
+ {"x": i, "y": 1000 * (12-i)}
+ for i in range(1, 12)
+ ],
+ "title": "Previous Year",
+ "key": "previous",
+ "area": True,
+ "color": "000000",
+ },
+]}
+
+
+
+
+
+
+
+ Dashboard title
+
+ 1
+ 1
+ 4
+ #707070
+ #000000
+
+
+
+ Number 01
+
+
+ 1
+ 2
+ 4
+ #47bbb3
+ #ffffff
+
+
+
+ Number 02
+
+
+ 1
+ 6
+ 4
+ #ec663c
+ #ffffff
+
+
+
+ Meter 01
+
+
+ 2
+ 2
+ 4
+ #9c4274
+ #ffffff
+
+
+
+ Meter 02
+
+
+ 2
+ 6
+ 4
+ #12b0c5
+ #ffffff
+
+
+
+ Graph
+
+
+ 3
+ 2
+ 2
+ 8
+ #ff9618
+ #ffffff
+
+
+
diff --git a/kpi_dashboard/readme/CONFIGURE.rst b/kpi_dashboard/readme/CONFIGURE.rst
index bbbeb64de..a4e700e98 100644
--- a/kpi_dashboard/readme/CONFIGURE.rst
+++ b/kpi_dashboard/readme/CONFIGURE.rst
@@ -11,6 +11,17 @@ Configure KPIs
#. In order to compute the KPI you can use a predefined function from a model or
use the code to directly compute it.
+Using KPI with code
+~~~~~~~~~~~~~~~~~~~
+
+Define the code directly on the code field. You can use `self` and `model` as the kpi element
+The script should create a variable called `result` as a dictionary that
+will be stored as the value.
+For example, we can use::
+
+ result = {}
+ result['value'] = len(model.search([('id', '=', %s)]))
+ result['previous'] = len(model.search([('id', '!=', %s)]))
Configure dashboards
~~~~~~~~~~~~~~~~~~~~
diff --git a/kpi_dashboard/static/description/index.html b/kpi_dashboard/static/description/index.html
index 6da67fbd9..bde4304d4 100644
--- a/kpi_dashboard/static/description/index.html
+++ b/kpi_dashboard/static/description/index.html
@@ -3,7 +3,7 @@
-
+
Kpi Dashboard