Skip to content

Commit

Permalink
Merge PR #814 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed May 10, 2024
2 parents ffaf7a1 + 8393e57 commit 3321d65
Show file tree
Hide file tree
Showing 50 changed files with 20,068 additions and 0 deletions.
121 changes: 121 additions & 0 deletions kpi_dashboard/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
=============
Kpi Dashboard
=============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3f7c1c23f7a3a6d0be24a8c1fdfd24dbca96ce6215e852d52674f9cf90f6c96f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/14.0/kpi_dashboard
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-0-kpi_dashboard
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds new kinds of dashboards on a specific new type of view.

**Table of contents**

.. contents::
:local:

Configuration
=============

Configure KPIs
~~~~~~~~~~~~~~

#. Access `Dashboards > Configuration > KPI Dashboards > Configure KPI`
#. Create a new KPI specifying the computation method and the kpi type

#. Number: result must contain a `value` and, if needed, a `previous`
#. Meter: To show a percentage value, result must contain `value`. `value` must be a positive integer between 0 to 100. Meter is implemented with GaugeMeter (https://github.com/Mictronics/GaugeMeter). It can be customized by setting parameters for GaugeMeter in result. See https://github.com/Mictronics/GaugeMeter#parameter-definitions for details.
#. 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.
For example, we can use::

result = {}
result['value'] = len(model.search([('id', '=', %s)]))
result['previous'] = len(model.search([('id', '!=', %s)]))

Configure dashboards
~~~~~~~~~~~~~~~~~~~~

#. Access `Dashboards > Configuration > KPI Dashboards > Configure Dashboards`
#. Create a new dashboard and specify all the standard parameters on `Widget configuration`
#. Append elements on KPIs
#. You can preview the element using the dashboard view
#. You can create the menu entry directly using the `Generate menu` button

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20kpi_dashboard%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Creu Blanca

Contributors
~~~~~~~~~~~~

* Enric Tobella <etobella@creublanca.es>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-etobella| image:: https://github.com/etobella.png?size=40px
:target: https://github.com/etobella
:alt: etobella

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-etobella|

This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/14.0/kpi_dashboard>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions kpi_dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
44 changes: 44 additions & 0 deletions kpi_dashboard/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2020 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Kpi Dashboard",
"summary": """Create Dashboards using kpis""",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"depends": ["bus", "board", "base_sparse_field"],
"qweb": ["static/src/xml/dashboard.xml"],
"data": [
"wizards/kpi_dashboard_menu.xml",
"security/security.xml",
"security/ir.model.access.csv",
"views/kpi_menu.xml",
"views/kpi_kpi.xml",
"views/kpi_dashboard.xml",
],
"assets": {
"web.assets_backend": [
"kpi_dashboard/static/src/js/widget_registry.js",
"kpi_dashboard/static/src/js/widget/abstract_widget.js",
"kpi_dashboard/static/src/js/dashboard_renderer.js",
"kpi_dashboard/static/src/js/dashboard_model.js",
"kpi_dashboard/static/src/js/dashboard_controller.js",
"kpi_dashboard/static/src/js/dashboard_view.js",
"kpi_dashboard/static/src/js/widget/integer_widget.js",
"kpi_dashboard/static/src/js/widget/number_widget.js",
"kpi_dashboard/static/src/js/widget/counter_widget.js",
"kpi_dashboard/static/src/js/widget/meter_widget.js",
"kpi_dashboard/static/src/js/widget/graph_widget.js",
"kpi_dashboard/static/src/js/widget/text_widget.js",
"kpi_dashboard/static/src/js/field_widget.js",
"kpi_dashboard/static/src/scss/kpi_dashboard.scss",
],
"web.assets_qweb": [
"kpi_dashboard/static/src/xml/**/*",
],
},
"demo": ["demo/demo_dashboard.xml"],
"maintainers": ["etobella"],
}
203 changes: 203 additions & 0 deletions kpi_dashboard/demo/demo_dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="demo_dashboard" model="kpi.dashboard">
<field name="name">Dashboard</field>
<field name="number_of_columns">4</field>
<field name="widget_dimension_y">50</field>
<field name="widget_dimension_x">250</field>
<field name="background_color">#020202</field>
<field name="compute_on_fly_refresh">30</field>
</record>
<record id="widget_number_01" model="kpi.kpi">
<field name="name">Number 01</field>
<field name="prefix">$</field>
<field name="computation_method">code</field>
<field name="widget">number</field>
<field name="code">result = {"value": 10000,"previous": 12000}</field>
</record>
<record id="widget_number_02" model="kpi.kpi">
<field name="name">Number 02</field>
<field name="suffix">€</field>
<field name="computation_method">code</field>
<field name="widget">number</field>
<field name="code">result = {"value": 12000,"previous": 10000}</field>
</record>
<function
model="kpi.kpi"
name="compute"
eval="[[ref('widget_number_01'), ref('widget_number_02')]]"
/>
<record id="widget_meter_01" model="kpi.kpi">
<field name="name">Meter 01</field>
<field name="suffix">%</field>
<field name="computation_method">code</field>
<field name="widget">meter</field>
<field name="code">result = {"value": 90}</field>
</record>
<record id="widget_meter_02" model="kpi.kpi">
<field name="name">Meter 02</field>
<field name="prefix">$</field>
<field name="computation_method">code</field>
<field name="widget">meter</field>
<field
name="code"
>result = {"min": 0, "total": 200, "used": 90, "showvalue": True}</field>
</record>
<function
model="kpi.kpi"
name="compute"
eval="[[ref('widget_meter_01'), ref('widget_meter_02')]]"
/>
<record id="widget_graph" model="kpi.kpi">
<field name="name">Graph</field>
<field name="computation_method">code</field>
<field name="widget">graph</field>
<field
name="code"
><![CDATA[
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",
},
]}
]]></field>
</record>
<function model="kpi.kpi" name="compute" eval="[[ref('widget_graph')]]" />
<record id="widget_integer" model="kpi.kpi">
<field name="name">Integer counter</field>
<field name="computation_method">code</field>
<field name="widget">integer</field>
<field name="compute_on_fly" eval="True" />
<field
name="code"
><![CDATA[
result = {"value": self.env.context.get('counter', 990)}
]]></field>
</record>
<record id="widget_counter" model="kpi.kpi">
<field name="name">Counter</field>
<field name="computation_method">code</field>
<field name="widget">counter</field>
<field name="compute_on_fly" eval="True" />
<field
name="code"
><![CDATA[
result = {"value": self.env.context.get('counter', 990)}
]]></field>
</record>
<record id="dashboard_widget_text" model="kpi.dashboard.item">
<field name="name">Dashboard title</field>
<field name="dashboard_id" ref="demo_dashboard" />
<field name="column">1</field>
<field name="row">1</field>
<field name="size_x">4</field>
<field name="color">#707070</field>
<field name="font_color">#000000</field>
</record>
<record id="dashboard_widget_number_01" model="kpi.dashboard.item">
<field name="name">Number 01</field>
<field name="dashboard_id" ref="demo_dashboard" />
<field name="kpi_id" ref="widget_number_01" />
<field name="column">1</field>
<field name="row">2</field>
<field name="size_y">4</field>
<field name="color">#47bbb3</field>
<field name="font_color">#ffffff</field>
</record>
<record id="dashboard_widget_number_02" model="kpi.dashboard.item">
<field name="name">Number 02</field>
<field name="dashboard_id" ref="demo_dashboard" />
<field name="kpi_id" ref="widget_number_02" />
<field name="column">1</field>
<field name="row">6</field>
<field name="size_y">4</field>
<field name="color">#ec663c</field>
<field name="font_color">#ffffff</field>
</record>
<record id="dashboard_widget_meter_01" model="kpi.dashboard.item">
<field name="name">Meter 01</field>
<field name="dashboard_id" ref="demo_dashboard" />
<field name="kpi_id" ref="widget_meter_01" />
<field name="column">2</field>
<field name="row">2</field>
<field name="size_y">4</field>
<field name="color">#9c4274</field>
<field name="font_color">#ffffff</field>
</record>
<record id="dashboard_widget_meter_02" model="kpi.dashboard.item">
<field name="name">Meter 02</field>
<field name="dashboard_id" ref="demo_dashboard" />
<field name="kpi_id" ref="widget_meter_02" />
<field name="column">2</field>
<field name="row">6</field>
<field name="size_y">4</field>
<field name="color">#12b0c5</field>
<field name="font_color">#ffffff</field>
</record>
<record id="dashboard_widget_add_counter" model="kpi.dashboard.item">
<field name="name">+1 to Counter</field>
<field name="dashboard_id" ref="demo_dashboard" />
<field name="column">3</field>
<field name="row">10</field>
<field name="size_y">1</field>
<field name="size_x">2</field>
<field name="color">#B41F1F</field>
<field name="font_color">#EEBF77</field>
<field name="modify_context" eval="True" />
<field name="modify_context_expression">
{'counter': (context.counter or 990) + 1}
</field>
<field name="modify_color" eval="True" />
<field name="modify_color_expression">
check_if(((context.counter or 990) + 1) % 2, '#ff0000', '#00ff00')
</field>
</record>
<record id="dashboard_widget_counter" model="kpi.dashboard.item">
<field name="name">Counter</field>
<field name="dashboard_id" ref="demo_dashboard" />
<field name="kpi_id" ref="widget_counter" />
<field name="column">3</field>
<field name="row">11</field>
<field name="size_y">3</field>
<field name="color">#4B0082</field>
<field name="font_color">#ffffff</field>
</record>
<record id="dashboard_widget_integer" model="kpi.dashboard.item">
<field name="name">Integer</field>
<field name="dashboard_id" ref="demo_dashboard" />
<field name="kpi_id" ref="widget_integer" />
<field name="column">4</field>
<field name="row">11</field>
<field name="size_y">3</field>
<field name="color">#ffffff</field>
<field name="font_color">#4B0082</field>
</record>
<record id="dashboard_widget_graph" model="kpi.dashboard.item">
<field name="name">Graph</field>
<field name="dashboard_id" ref="demo_dashboard" />
<field name="kpi_id" ref="widget_graph" />
<field name="column">3</field>
<field name="row">2</field>
<field name="size_x">2</field>
<field name="size_y">8</field>
<field name="color">#ff9618</field>
<field name="font_color">#ffffff</field>
</record>
</odoo>
Loading

0 comments on commit 3321d65

Please sign in to comment.