[MIG] kpi_dashboard: Migration to 14.0

This commit is contained in:
Enric Tobella
2020-10-22 23:21:02 +02:00
committed by Brian McMaster
parent d8c5f0fc2d
commit 265982fdab
28 changed files with 189 additions and 227 deletions

View File

@@ -14,13 +14,13 @@ Kpi Dashboard
: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/12.0/kpi_dashboard
: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-12-0/reporting-engine-12-0-kpi_dashboard
: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/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/143/12.0
:target: https://runbot.odoo-community.org/runbot/143/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -75,7 +75,7 @@ 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20kpi_dashboard%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`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.
@@ -113,6 +113,6 @@ 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/12.0/kpi_dashboard>`_ project on GitHub.
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.

View File

@@ -5,7 +5,7 @@
"name": "Kpi Dashboard",
"summary": """
Create Dashboards using kpis""",
"version": "13.0.1.0.0",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",

View File

@@ -13,18 +13,14 @@
<field name="prefix">$</field>
<field name="computation_method">code</field>
<field name="widget">number</field>
<field name="code">
result = {"value": 10000,"previous": 12000}
</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>
<field name="code">result = {"value": 12000,"previous": 10000}</field>
</record>
<function
model="kpi.kpi"
@@ -36,18 +32,14 @@ result = {"value": 12000,"previous": 10000}
<field name="suffix"></field>
<field name="computation_method">code</field>
<field name="widget">meter</field>
<field name="code">
result = {"min": 0, "max": 100, "value": 90}
</field>
<field name="code">result = {"min": 0, "max": 100, "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, "max": 100, "value": 40}
</field>
<field name="code">result = {"min": 0, "max": 100, "value": 40}</field>
</record>
<function
model="kpi.kpi"
@@ -58,7 +50,9 @@ result = {"min": 0, "max": 100, "value": 40}
<field name="name">Graph</field>
<field name="computation_method">code</field>
<field name="widget">graph</field>
<field name="code">
<field
name="code"
><![CDATA[
result = {"graphs": [
{
"values": [
@@ -81,7 +75,7 @@ result = {"graphs": [
"color": "000000",
},
]}
</field>
]]></field>
</record>
<function model="kpi.kpi" name="compute" eval="[[ref('widget_graph')]]" />
<record id="widget_integer" model="kpi.kpi">
@@ -89,18 +83,22 @@ result = {"graphs": [
<field name="computation_method">code</field>
<field name="widget">integer</field>
<field name="compute_on_fly" eval="True" />
<field name="code">
<field
name="code"
><![CDATA[
result = {"value": self.env.context.get('counter', 990)}
</field>
]]></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">
<field
name="code"
><![CDATA[
result = {"value": self.env.context.get('counter', 990)}
</field>
]]></field>
</record>
<record id="dashboard_widget_text" model="kpi.dashboard.item">
<field name="name">Dashboard title</field>
@@ -161,13 +159,13 @@ result = {"value": self.env.context.get('counter', 990)}
<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_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>
<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>

View File

@@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * kpi_dashboard
# * kpi_dashboard
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -14,14 +14,14 @@ msgstr ""
"Plural-Forms: \n"
#. module: kpi_dashboard
#: code:addons/kpi_dashboard/models/kpi_kpi.py:153
#: code:addons/kpi_dashboard/models/kpi_kpi.py:0
#, python-format
msgid " or "
msgstr ""
#. module: kpi_dashboard
#. openerp-web
#: code:addons/kpi_dashboard/static/src/js/dashboard_controller.js:72
#: code:addons/kpi_dashboard/static/src/js/dashboard_controller.js:0
#, python-format
msgid "'%s' added to dashboard"
msgstr ""
@@ -53,24 +53,13 @@ msgstr ""
msgid "Active"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.actions.act_window.view,view_mode:0
#: selection:ir.ui.view,type:0
msgid "Activity"
msgstr ""
#. module: kpi_dashboard
#. openerp-web
#: code:addons/kpi_dashboard/static/src/xml/dashboard.xml:72
#: code:addons/kpi_dashboard/static/src/xml/dashboard.xml:0
#, python-format
msgid "Add to Dashboard"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi,widget:0
msgid "Altair"
msgstr ""
#. module: kpi_dashboard
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_kpi__args
msgid "Args"
@@ -81,17 +70,6 @@ msgstr ""
msgid "Background Color"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi,widget:0
msgid "Bokeh"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.actions.act_window.view,view_mode:0
#: selection:ir.ui.view,type:0
msgid "Calendar"
msgstr ""
#. module: kpi_dashboard
#: model_terms:ir.ui.view,arch_db:kpi_dashboard.kpi_dashboard_item_config_form_view
#: model_terms:ir.ui.view,arch_db:kpi_dashboard.kpi_dashboard_menu_form_view
@@ -100,8 +78,8 @@ msgstr ""
#. module: kpi_dashboard
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_kpi__code
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi__computation_method__code
#: model_terms:ir.ui.view,arch_db:kpi_dashboard.kpi_kpi_form_view
#: selection:kpi.kpi,computation_method:0
msgid "Code"
msgstr ""
@@ -162,13 +140,13 @@ msgstr ""
#. module: kpi_dashboard
#. openerp-web
#: code:addons/kpi_dashboard/static/src/js/dashboard_controller.js:76
#: code:addons/kpi_dashboard/static/src/js/dashboard_controller.js:0
#, python-format
msgid "Could not add KPI dashboard to dashboard"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi,widget:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi__widget__counter
msgid "Counter"
msgstr ""
@@ -204,12 +182,12 @@ msgstr ""
#. module: kpi_dashboard
#. openerp-web
#: code:addons/kpi_dashboard/static/src/js/dashboard_view.js:21
#: selection:ir.actions.act_window.view,view_mode:0
#: code:addons/kpi_dashboard/static/src/js/dashboard_view.js:0
#: model:ir.model,name:kpi_dashboard.model_kpi_dashboard
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard_item__dashboard_id
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard_menu__dashboard_id
#: selection:ir.ui.view,type:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__ir_actions_act_window_view__view_mode__dashboard
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__ir_ui_view__type__dashboard
#, python-format
msgid "Dashboard"
msgstr ""
@@ -225,11 +203,8 @@ msgid "Dashboard Items"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.ui.view,type:0
msgid "Diagram"
msgstr ""
#. module: kpi_dashboard
#: model:ir.model.fields,field_description:kpi_dashboard.field_ir_actions_act_window_view__display_name
#: model:ir.model.fields,field_description:kpi_dashboard.field_ir_ui_view__display_name
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard__display_name
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard_item__display_name
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard_menu__display_name
@@ -256,7 +231,7 @@ msgstr ""
#. module: kpi_dashboard
#. openerp-web
#: code:addons/kpi_dashboard/static/src/js/dashboard_controller.js:57
#: code:addons/kpi_dashboard/static/src/js/dashboard_controller.js:0
#, python-format
msgid "First you must create the Menu"
msgstr ""
@@ -266,24 +241,12 @@ msgstr ""
msgid "Font Color"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.actions.act_window.view,view_mode:0
#: selection:ir.ui.view,type:0
msgid "Form"
msgstr ""
#. module: kpi_dashboard
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_kpi__function
#: selection:kpi.kpi,computation_method:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi__computation_method__function
msgid "Function"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.actions.act_window.view,view_mode:0
#: selection:ir.ui.view,type:0
msgid "Gantt"
msgstr ""
#. module: kpi_dashboard
#: model_terms:ir.ui.view,arch_db:kpi_dashboard.kpi_dashboard_menu_form_view
msgid "Generate"
@@ -306,15 +269,13 @@ msgstr ""
#. module: kpi_dashboard
#. openerp-web
#: code:addons/kpi_dashboard/static/src/xml/dashboard.xml:25
#: code:addons/kpi_dashboard/static/src/xml/dashboard.xml:0
#, python-format
msgid "Go to"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.actions.act_window.view,view_mode:0
#: selection:ir.ui.view,type:0
#: selection:kpi.kpi,widget:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi__widget__graph
msgid "Graph"
msgstr ""
@@ -334,6 +295,8 @@ msgid "History"
msgstr ""
#. module: kpi_dashboard
#: model:ir.model.fields,field_description:kpi_dashboard.field_ir_actions_act_window_view__id
#: model:ir.model.fields,field_description:kpi_dashboard.field_ir_ui_view__id
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard__id
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard_item__id
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard_menu__id
@@ -344,7 +307,7 @@ msgid "ID"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi,widget:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi__widget__integer
msgid "Integer"
msgstr ""
@@ -373,12 +336,6 @@ msgstr ""
msgid "KPIs"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.actions.act_window.view,view_mode:0
#: selection:ir.ui.view,type:0
msgid "Kanban"
msgstr ""
#. module: kpi_dashboard
#: model:ir.actions.act_window,name:kpi_dashboard.kpi_kpi_act_window
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard_item__kpi_id
@@ -413,6 +370,8 @@ msgid "Kwargs"
msgstr ""
#. module: kpi_dashboard
#: model:ir.model.fields,field_description:kpi_dashboard.field_ir_actions_act_window_view____last_update
#: model:ir.model.fields,field_description:kpi_dashboard.field_ir_ui_view____last_update
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard____last_update
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard_item____last_update
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_dashboard_menu____last_update
@@ -444,7 +403,7 @@ msgstr ""
#. module: kpi_dashboard
#. openerp-web
#: code:addons/kpi_dashboard/static/src/xml/dashboard.xml:70
#: code:addons/kpi_dashboard/static/src/xml/dashboard.xml:0
#, python-format
msgid "Main actions"
msgstr ""
@@ -471,7 +430,7 @@ msgid "Menu"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi,widget:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi__widget__meter
msgid "Meter"
msgstr ""
@@ -509,7 +468,7 @@ msgid "Name"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi,widget:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi__widget__number
msgid "Number"
msgstr ""
@@ -518,15 +477,9 @@ msgstr ""
msgid "Number Of Columns"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.actions.act_window.view,view_mode:0
#: selection:ir.ui.view,type:0
msgid "Pivot"
msgstr ""
#. module: kpi_dashboard
#. openerp-web
#: code:addons/kpi_dashboard/static/src/js/dashboard_controller.js:73
#: code:addons/kpi_dashboard/static/src/js/dashboard_controller.js:0
#, python-format
msgid "Please refresh your browser for the changes to take effect."
msgstr ""
@@ -536,11 +489,6 @@ msgstr ""
msgid "Prefix"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.ui.view,type:0
msgid "QWeb"
msgstr ""
#. module: kpi_dashboard
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_kpi_history__raw_value
msgid "Raw Value"
@@ -561,11 +509,6 @@ msgstr ""
msgid "Save"
msgstr ""
#. module: kpi_dashboard
#: selection:ir.ui.view,type:0
msgid "Search"
msgstr ""
#. module: kpi_dashboard
#: model:ir.model.fields,help:kpi_dashboard.field_kpi_dashboard__compute_on_fly_refresh
msgid "Seconds to refresh on fly elements"
@@ -573,7 +516,8 @@ msgstr ""
#. module: kpi_dashboard
#. openerp-web
#: code:addons/kpi_dashboard/static/src/xml/dashboard.xml:34
#: code:addons/kpi_dashboard/static/src/xml/dashboard.xml:0
#: code:addons/kpi_dashboard/static/src/xml/dashboard.xml:0
#, python-format
msgid "Selection"
msgstr ""
@@ -600,7 +544,7 @@ msgid "Size Y"
msgstr ""
#. module: kpi_dashboard
#: code:addons/kpi_dashboard/models/kpi_dashboard.py:139
#: code:addons/kpi_dashboard/models/kpi_dashboard.py:0
#, python-format
msgid "Size Y of the widget cannot be bigger than 10"
msgstr ""
@@ -626,17 +570,11 @@ msgid "Suffix"
msgstr ""
#. module: kpi_dashboard
#: code:addons/kpi_dashboard/models/kpi_kpi.py:155
#: code:addons/kpi_dashboard/models/kpi_kpi.py:0
#, python-format
msgid "The code cannot contain the following terms: %s."
msgstr ""
#. module: kpi_dashboard
#: selection:ir.actions.act_window.view,view_mode:0
#: selection:ir.ui.view,type:0
msgid "Tree"
msgstr ""
#. module: kpi_dashboard
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_kpi__value
#: model:ir.model.fields,field_description:kpi_dashboard.field_kpi_kpi_history__value
@@ -666,7 +604,7 @@ msgid "Widget"
msgstr ""
#. module: kpi_dashboard
#: code:addons/kpi_dashboard/models/kpi_dashboard.py:160
#: code:addons/kpi_dashboard/models/kpi_dashboard.py:0
#, python-format
msgid "Widget %s is bigger than expected"
msgstr ""
@@ -687,7 +625,7 @@ msgid "Widget configuration"
msgstr ""
#. module: kpi_dashboard
#: code:addons/kpi_dashboard/models/kpi_dashboard.py:156
#: code:addons/kpi_dashboard/models/kpi_dashboard.py:0
#, python-format
msgid "Widgets cannot be crossed by other widgets"
msgstr ""
@@ -698,27 +636,26 @@ msgid "Width"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi.action,action:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi_action__action__ir_actions_act_url
msgid "ir.actions.act_url"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi.action,action:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi_action__action__ir_actions_act_window
msgid "ir.actions.act_window"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi.action,action:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi_action__action__ir_actions_client
msgid "ir.actions.client"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi.action,action:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi_action__action__ir_actions_report
msgid "ir.actions.report"
msgstr ""
#. module: kpi_dashboard
#: selection:kpi.kpi.action,action:0
#: model:ir.model.fields.selection,name:kpi_dashboard.selection__kpi_kpi_action__action__ir_actions_server
msgid "ir.actions.server"
msgstr ""

View File

@@ -7,4 +7,6 @@ from odoo import fields, models
class IrActionsActWindowView(models.Model):
_inherit = "ir.actions.act_window.view"
view_mode = fields.Selection(selection_add=[("dashboard", "Dashboard")])
view_mode = fields.Selection(
selection_add=[("dashboard", "Dashboard")], ondelete={"dashboard": "cascade"}
)

View File

@@ -7,4 +7,6 @@ from odoo import fields, models
class IrUiView(models.Model):
_inherit = "ir.ui.view"
type = fields.Selection(selection_add=[("dashboard", "Dashboard")])
type = fields.Selection(
selection_add=[("dashboard", "Dashboard")], ondelete={"dashboard": "cascade"}
)

View File

@@ -11,9 +11,13 @@ class KpiDashboard(models.Model):
_description = "Dashboard"
name = fields.Char(required=True)
active = fields.Boolean(default=True,)
active = fields.Boolean(
default=True,
)
item_ids = fields.One2many(
"kpi.dashboard.item", inverse_name="dashboard_id", copy=True,
"kpi.dashboard.item",
inverse_name="dashboard_id",
copy=True,
)
number_of_columns = fields.Integer(default=5, required=True)
compute_on_fly_refresh = fields.Integer(
@@ -25,7 +29,9 @@ class KpiDashboard(models.Model):
widget_dimension_x = fields.Integer(default=250, required=True)
widget_dimension_y = fields.Integer(default=250, required=True)
background_color = fields.Char(required=True, default="#f9f9f9")
group_ids = fields.Many2many("res.groups",)
group_ids = fields.Many2many(
"res.groups",
)
menu_id = fields.Many2one("ir.ui.menu", copy=False)
def write(self, vals):
@@ -227,3 +233,6 @@ class KpiDashboardItem(models.Model):
"kpi_dashboard.kpi_dashboard_item_config_form_view"
).id,
}
def store_data(self):
return {"type": "ir.actions.act_window_close"}

View File

@@ -2,9 +2,9 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import ast
import datetime
import json
import re
from datetime import date, datetime, time
from dateutil import relativedelta
@@ -24,11 +24,15 @@ class KpiKpi(models.Model):
active = fields.Boolean(default=True)
cron_id = fields.Many2one("ir.cron", readonly=True, copy=False)
computation_method = fields.Selection(
[("function", "Function"), ("code", "Code")], required=True
[("function", "Function"), ("code", "Code")],
required=True,
default="code",
)
value = fields.Serialized()
dashboard_item_ids = fields.One2many("kpi.dashboard.item", inverse_name="kpi_id")
model_id = fields.Many2one("ir.model",)
model_id = fields.Many2one(
"ir.model",
)
function = fields.Char()
args = fields.Char()
kwargs = fields.Char()
@@ -144,6 +148,8 @@ class KpiKpi(models.Model):
"self": self,
"model": self.browse(),
"datetime": datetime,
"date": date,
"time": time,
"float_compare": float_compare,
"relativedelta": relativedelta.relativedelta,
}
@@ -231,6 +237,7 @@ class KpiKpiHistory(models.Model):
widget = fields.Selection(
selection=lambda self: self.env["kpi.kpi"]._fields["widget"].selection,
required=True,
default="number",
)
@api.depends("value")

View File

@@ -9,3 +9,4 @@ manage_kpi_dashboard_kpi,manage_kpi_dashboard_kpi,model_kpi_dashboard_item,group
manage_kpi_kpi,manage_kpi_kpi,model_kpi_kpi,group_kpi_dashboard_manager,1,1,1,1
manage_kpi_kpi_action,manage_kpi_kpi_action,model_kpi_kpi_action,group_kpi_dashboard_manager,1,1,1,1
manage_kpi_kpi_history,manage_kpi_kpi_history,model_kpi_kpi_history,group_kpi_dashboard_manager,1,1,1,1
access_kpi_dashboard_menu,access_kpi_dashboard_menu,model_kpi_dashboard_menu,group_kpi_dashboard_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
9 manage_kpi_kpi manage_kpi_kpi model_kpi_kpi group_kpi_dashboard_manager 1 1 1 1
10 manage_kpi_kpi_action manage_kpi_kpi_action model_kpi_kpi_action group_kpi_dashboard_manager 1 1 1 1
11 manage_kpi_kpi_history manage_kpi_kpi_history model_kpi_kpi_history group_kpi_dashboard_manager 1 1 1 1
12 access_kpi_dashboard_menu access_kpi_dashboard_menu model_kpi_dashboard_menu group_kpi_dashboard_manager 1 1 1 1

View File

@@ -9,9 +9,10 @@
<record id="rule_kpi_dashboard" model="ir.rule">
<field name="name">KPI Dashboard: User</field>
<field name="model_id" ref="model_kpi_dashboard" />
<field
name="domain_force"
>['|', ('group_ids', '=', False), ('group_ids', 'in', user.groups_id.ids)]</field>
<field name="domain_force">
['|', ('group_ids', '=', False), ('group_ids', 'in',
user.groups_id.ids)]
</field>
<field name="groups" eval="[(4, ref('base.group_user'))]" />
</record>
<record id="rule_kpi_dashboard_all" model="ir.rule">

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/12.0/kpi_dashboard"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-12-0/reporting-engine-12-0-kpi_dashboard"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/143/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/14.0/kpi_dashboard"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-0-kpi_dashboard"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/143/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds new kinds of dashboards on a specific new type of view.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@@ -431,7 +431,7 @@ result['previous'] = len(model.search([('id', '!=', %s)]))
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20kpi_dashboard%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="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**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -457,7 +457,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/etobella"><img alt="etobella" src="https://github.com/etobella.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/12.0/kpi_dashboard">OCA/reporting-engine</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/14.0/kpi_dashboard">OCA/reporting-engine</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -1,7 +1,7 @@
/*
global py
*/
odoo.define("kpi_dashboard.DashboardController", function(require) {
odoo.define("kpi_dashboard.DashboardController", function (require) {
"use strict";
var BasicController = require("web.BasicController");
@@ -11,7 +11,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
var _t = core._t;
var DashboardController = BasicController.extend({
init: function() {
init: function () {
this._super.apply(this, arguments);
this.dashboard_context = {};
this.dashboard_color_data = [];
@@ -23,15 +23,15 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
add_modify_color: "_addModifyColor",
refresh_colors: "_refreshColors",
}),
_refreshOnFly: function() {
_refreshOnFly: function () {
var self = this;
this._rpc({
model: this.modelName,
method: "read_dashboard_on_fly",
args: [[this.renderer.state.res_id]],
context: this._getContext(),
}).then(function(data) {
_.each(data, function(item) {
}).then(function (data) {
_.each(data, function (item) {
// We will follow the same logic used on Bus Notifications
self.renderer._onNotification([
["kpi_dashboard_" + self.renderer.state.res_id, item],
@@ -39,21 +39,21 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
});
});
},
renderPager: function($node, options) {
renderPager: function ($node, options) {
// eslint-disable-next-line no-param-reassign
options = _.extend({}, options, {
validate: this.canBeDiscarded.bind(this),
});
this._super($node, options);
},
_pushState: function(state) {
_pushState: function (state) {
// eslint-disable-next-line no-param-reassign
state = state || {};
var env = this.model.get(this.handle, {env: true});
state.id = env.currentId;
this._super(state);
},
_addDashboard: function() {
_addDashboard: function () {
var self = this;
var action = self.initialState.specialData.action_id;
var name = self.initialState.specialData.name;
@@ -71,7 +71,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
name: name,
},
})
.then(function(r) {
.then(function (r) {
if (r) {
self.do_notify(
_.str.sprintf(_t("'%s' added to dashboard"), name),
@@ -84,7 +84,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
}
});
},
_updateButtons: function() {
_updateButtons: function () {
// HOOK Function
this.$buttons.on(
"click",
@@ -92,7 +92,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
this._addDashboard.bind(this)
);
},
renderButtons: function($node) {
renderButtons: function ($node) {
if (!$node) {
return;
}
@@ -103,7 +103,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
this._updateButtons();
this.$buttons.appendTo($node);
},
_getContext: function() {
_getContext: function () {
return _.extend(
{},
this.model.get(this.handle, {raw: true}).getContext(),
@@ -111,7 +111,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
this.dashboard_context
);
},
_modifyContext: function(event) {
_modifyContext: function (event) {
var ctx = this._getContext();
this.dashboard_context = _.extend(
this.dashboard_context,
@@ -119,7 +119,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
context: _.extend(
ctx,
{
__getattr__: function() {
__getattr__: function () {
return false;
},
}
@@ -131,23 +131,23 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
this._refreshOnFly(event);
this._refreshColors();
},
_addModifyColor: function(event) {
_addModifyColor: function (event) {
this.dashboard_color_data.push([
event.data.element_id,
event.data.expression,
]);
},
_refreshColors: function() {
_refreshColors: function () {
var self = this;
var ctx = this._getContext();
_.each(this.dashboard_color_data, function(data) {
_.each(this.dashboard_color_data, function (data) {
var color = py.eval(data[1], {
context: _.extend(ctx, {
__getattr__: function() {
__getattr__: function () {
return false;
},
}),
check_if: function(args) {
check_if: function (args) {
if (args[0].toJSON()) {
return args[1];
}

View File

@@ -1,16 +1,16 @@
odoo.define("kpi_dashboard.DashboardModel", function(require) {
odoo.define("kpi_dashboard.DashboardModel", function (require) {
"use strict";
var BasicModel = require("web.BasicModel");
var DashboardModel = BasicModel.extend({
_fetchRecord: function(record) {
_fetchRecord: function (record) {
return this._rpc({
model: record.model,
method: "read_dashboard",
args: [[record.res_id]],
context: _.extend({}, record.getContext(), {bin_size: true}),
}).then(function(result) {
}).then(function (result) {
record.specialData = result;
return result;
});

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.DashboardRenderer", function(require) {
odoo.define("kpi_dashboard.DashboardRenderer", function (require) {
"use strict";
var BasicRenderer = require("web.BasicRenderer");
@@ -8,25 +8,25 @@ odoo.define("kpi_dashboard.DashboardRenderer", function(require) {
var DashboardRenderer = BasicRenderer.extend({
className: "o_dashboard_view",
_getDashboardWidget: function(kpi) {
_getDashboardWidget: function (kpi) {
var Widget = registry.getAny([kpi.widget, "abstract"]);
var widget = new Widget(this, kpi);
return widget;
},
_onClickModifyContext: function(modify_context_expression, event) {
_onClickModifyContext: function (modify_context_expression, event) {
this.trigger_up("modify_context", {
context: modify_context_expression,
event: event,
});
},
_renderView: function() {
_renderView: function () {
this.$el.html($(qweb.render("dashboard_kpi.dashboard")));
this.$el.css("background-color", this.state.specialData.background_color);
this.$el.find(".gridster").css("width", this.state.specialData.width);
this.$grid = this.$el.find(".gridster ul");
var self = this;
this.kpi_widget = {};
_.each(this.state.specialData.item_ids, function(kpi) {
_.each(this.state.specialData.item_ids, function (kpi) {
var element = $(qweb.render("kpi_dashboard.kpi", {widget: kpi}));
element.css("background-color", kpi.color);
element.css("color", kpi.font_color);
@@ -72,7 +72,7 @@ odoo.define("kpi_dashboard.DashboardRenderer", function(require) {
this.call("bus_service", "onNotification", this, this._onNotification);
if (this.state.specialData.compute_on_fly_refresh > 0) {
// Setting the refresh interval
this.on_fly_interval = setInterval(function() {
this.on_fly_interval = setInterval(function () {
self.trigger_up("refresh_on_fly");
}, this.state.specialData.compute_on_fly_refresh * 1000);
}
@@ -82,16 +82,16 @@ odoo.define("kpi_dashboard.DashboardRenderer", function(require) {
// context
return $.when();
},
on_detach_callback: function() {
on_detach_callback: function () {
// We want to clear the refresh interval once we exit the view
if (this.on_fly_interval) {
clearInterval(this.on_fly_interval);
}
this._super.apply(this, arguments);
},
_onNotification: function(notifications) {
_onNotification: function (notifications) {
var self = this;
_.each(notifications, function(notification) {
_.each(notifications, function (notification) {
var channel = notification[0];
var message = notification[1];
if (channel === self.channel && message) {

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.DashboardView", function(require) {
odoo.define("kpi_dashboard.DashboardView", function (require) {
"use strict";
var BasicView = require("web.BasicView");
@@ -24,7 +24,7 @@ odoo.define("kpi_dashboard.DashboardView", function(require) {
}),
multi_record: false,
searchable: false,
init: function() {
init: function () {
this._super.apply(this, arguments);
this.controllerParams.mode = "readonly";
this.loadParams.type = "record";

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.KpiFieldWidget", function(require) {
odoo.define("kpi_dashboard.KpiFieldWidget", function (require) {
"use strict";
var basic_fields = require("web.basic_fields");
@@ -11,7 +11,7 @@ odoo.define("kpi_dashboard.KpiFieldWidget", function(require) {
jsLibs: ["/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.js"],
cssLibs: ["/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.css"],
className: "o_dashboard_view",
_renderReadonly: function() {
_renderReadonly: function () {
this.$el.html($(qweb.render("dashboard_kpi.dashboard")));
var marginx = 0;
var marginy = 0;

View File

@@ -1,7 +1,7 @@
/*
global nv
*/
odoo.define("web.nvd3.extensions", function() {
odoo.define("web.nvd3.extensions", function () {
"use strict";
/**
@@ -16,7 +16,7 @@ odoo.define("web.nvd3.extensions", function() {
// see https://github.com/novus/nvd3/pull/396 for more details
// Adds a resize listener to the window.
nv.utils.onWindowResize = function(fun) {
nv.utils.onWindowResize = function (fun) {
if (fun === null) return;
window.addEventListener("resize", fun);
};
@@ -25,7 +25,7 @@ odoo.define("web.nvd3.extensions", function() {
nv.utils.windowResize = nv.utils.onWindowResize;
// Removes a resize listener from the window.
nv.utils.offWindowResize = function(fun) {
nv.utils.offWindowResize = function (fun) {
if (fun === null) return;
window.removeEventListener("resize", fun);
};
@@ -33,7 +33,7 @@ odoo.define("web.nvd3.extensions", function() {
// Monkey patch nvd3 to prevent crashes when user changes view and nvd3
// tries to remove tooltips after 500 ms... seriously nvd3, what were you
// thinking?
nv.tooltip.cleanup = function() {
nv.tooltip.cleanup = function () {
$(".nvtooltip").remove();
};
@@ -41,7 +41,7 @@ odoo.define("web.nvd3.extensions", function() {
// with a negative `top`; with this patch the highest tooltip's position is
// still in the graph
var originalCalcTooltipPosition = nv.tooltip.calcTooltipPosition;
nv.tooltip.calcTooltipPosition = function() {
nv.tooltip.calcTooltipPosition = function () {
var container = originalCalcTooltipPosition.apply(this, arguments);
container.style.top =
container.style.top.split("px")[0] < 0 ? 0 + "px" : container.style.top;

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.AbstractWidget", function(require) {
odoo.define("kpi_dashboard.AbstractWidget", function (require) {
"use strict";
var Widget = require("web.Widget");
var field_utils = require("web.field_utils");
@@ -17,7 +17,7 @@ odoo.define("kpi_dashboard.AbstractWidget", function(require) {
"click .o_kpi_dashboard_toggle_button": "_onClickToggleButton",
"click .direct_action": "_onClickDirectAction",
},
init: function(parent, kpi_values) {
init: function (parent, kpi_values) {
this._super(parent);
this.col = kpi_values.col;
this.row = kpi_values.row;
@@ -37,21 +37,21 @@ odoo.define("kpi_dashboard.AbstractWidget", function(require) {
this.widget_size_y =
this.widget_dimension_y * this.sizey + (this.sizey - 1) * this.margin_y;
},
willStart: function() {
willStart: function () {
// We need to load the libraries before the start
return $.when(ajax.loadLibs(this), this._super.apply(this, arguments));
},
start: function() {
start: function () {
var self = this;
return this._super.apply(this, arguments).then(function() {
return this._super.apply(this, arguments).then(function () {
self._fillWidget(self.values);
});
},
_onClickToggleButton: function(event) {
_onClickToggleButton: function (event) {
event.preventDefault();
this.$el.toggleClass("o_dropdown_open");
},
_fillWidget: function(values) {
_fillWidget: function (values) {
// This function fills the widget values
if (this.$el === undefined) return;
this.fillWidget(values);
@@ -73,20 +73,20 @@ odoo.define("kpi_dashboard.AbstractWidget", function(require) {
if ($manage && this.showManagePanel(values))
$manage.toggleClass("hidden", false);
},
showManagePanel: function(values) {
showManagePanel: function (values) {
// Hook for extensions
return values.actions !== undefined;
},
fillWidget: function(values) {
fillWidget: function (values) {
// Specific function that will be changed by specific widget
var value = values.value;
var self = this;
_.each(value, function(val, key) {
_.each(value, function (val, key) {
var item = self.$el.find("[data-bind=" + key + "]");
if (item) item.text(val);
});
},
_onClickDirectAction: function(event) {
_onClickDirectAction: function (event) {
event.preventDefault();
var $data = $(event.currentTarget).closest("a");
var action = this.actions[$($data).data("id")];

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.CounterWidget", function(require) {
odoo.define("kpi_dashboard.CounterWidget", function (require) {
"use strict";
var IntegerWidget = require("kpi_dashboard.IntegerWidget");

View File

@@ -1,7 +1,7 @@
/*
global nv, d3
*/
odoo.define("kpi_dashboard.GraphWidget", function(require) {
odoo.define("kpi_dashboard.GraphWidget", function (require) {
"use strict";
var AbstractWidget = require("kpi_dashboard.AbstractWidget");
@@ -17,12 +17,12 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
"/kpi_dashboard/static/src/js/lib/nvd3.js",
],
cssLibs: ["/kpi_dashboard/static/lib/nvd3/nv.d3.css"],
start: function() {
start: function () {
this._onResize = this._onResize.bind(this);
nv.utils.windowResize(this._onResize);
return this._super.apply(this, arguments);
},
destroy: function() {
destroy: function () {
if ("nv" in window && nv.utils && nv.utils.offWindowResize) {
// If the widget is destroyed before the lazy loaded libs (nv) are
// actually loaded (i.e. after the widget has actually started),
@@ -31,9 +31,9 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
}
this._super.apply(this, arguments);
},
_getChartOptions: function() {
_getChartOptions: function () {
return {
x: function(d, u) {
x: function (d, u) {
return u;
},
margin: {left: 0, right: 0, top: 5, bottom: 0},
@@ -44,11 +44,11 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
width: this.widget_size_x - 20,
};
},
_chartConfiguration: function(values) {
_chartConfiguration: function (values) {
this.chart.forceY([0]);
this.chart.xAxis.tickFormat(function(d) {
this.chart.xAxis.tickFormat(function (d) {
var label = "";
_.each(values.value.graphs, function(v) {
_.each(values.value.graphs, function (v) {
if (v.values[d] && v.values[d].x) {
label = v.values[d].x;
}
@@ -57,7 +57,7 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
});
this.chart.yAxis.tickFormat(d3.format(",.2f"));
this.chart.tooltip.contentGenerator(function(key) {
this.chart.tooltip.contentGenerator(function (key) {
return qweb.render("GraphCustomTooltip", {
color: key.point.color,
key: key.series[0].title,
@@ -65,7 +65,7 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
});
});
},
_addGraph: function(values) {
_addGraph: function (values) {
var data = values.value.graphs;
this.$svg.addClass("o_graph_linechart");
this.chart = nv.models.lineChart();
@@ -79,23 +79,23 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
this.$("svg").css("height", this.widget_size_y - 90);
this._customizeChart();
},
fillWidget: function(values) {
fillWidget: function (values) {
var self = this;
var element = this.$el.find('[data-bind="value"]');
element.empty();
element.css("padding-left", 10).css("padding-right", 10);
this.chart = null;
nv.addGraph(function() {
nv.addGraph(function () {
self.$svg = self.$el
.find('[data-bind="value"]')
.append("<svg width=" + (self.widget_size_x - 20) + ">");
self._addGraph(values);
});
},
_customizeChart: function() {
_customizeChart: function () {
// Hook function
},
_onResize: function() {
_onResize: function () {
if (this.chart) {
this.chart.update();
this._customizeChart();

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.IntegerWidget", function(require) {
odoo.define("kpi_dashboard.IntegerWidget", function (require) {
"use strict";
var AbstractWidget = require("kpi_dashboard.AbstractWidget");
@@ -14,12 +14,12 @@ odoo.define("kpi_dashboard.IntegerWidget", function(require) {
[1000000, "M", [3, 1]],
[1000, "K", [3, 1]],
],
shortNumber: function(num) {
shortNumber: function (num) {
var suffix = "";
var shortened = false;
var digits = this.digits;
var result = num;
_.each(this.shortList, function(shortItem) {
_.each(this.shortList, function (shortItem) {
if (!shortened && Math.abs(num) >= shortItem[0]) {
shortened = true;
suffix = shortItem[1];
@@ -33,7 +33,7 @@ odoo.define("kpi_dashboard.IntegerWidget", function(require) {
}) + suffix
);
},
fillWidget: function(values) {
fillWidget: function (values) {
var widget = this.$el;
var value = values.value.value;
if (value === undefined) {

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.MeterWidget", function(require) {
odoo.define("kpi_dashboard.MeterWidget", function (require) {
"use strict";
var AbstractWidget = require("kpi_dashboard.AbstractWidget");
@@ -7,14 +7,14 @@ odoo.define("kpi_dashboard.MeterWidget", function(require) {
var MeterWidget = AbstractWidget.extend({
template: "kpi_dashboard.meter",
jsLibs: ["/kpi_dashboard/static/lib/gauge/GaugeMeter.js"],
fillWidget: function(values) {
fillWidget: function (values) {
var input = this.$el.find('[data-bind="value"]');
var options = this._getMeterOptions(values);
var margin = (this.widget_dimension_x - options.size) / 2;
input.gaugeMeter(options);
input.parent().css("padding-left", margin);
},
_getMeterOptions: function(values) {
_getMeterOptions: function (values) {
var size = Math.min(this.widget_size_x, this.widget_size_y - 40) - 10;
return {
percent: values.value.value,

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.NumberWidget", function(require) {
odoo.define("kpi_dashboard.NumberWidget", function (require) {
"use strict";
var IntegerWidget = require("kpi_dashboard.IntegerWidget");
@@ -7,7 +7,7 @@ odoo.define("kpi_dashboard.NumberWidget", function(require) {
var NumberWidget = IntegerWidget.extend({
digits: [3, 1],
shortNumber: function(num) {
shortNumber: function (num) {
if (Math.abs(num) < 10) {
return field_utils.format.float(num, false, {
digits: [3, 2],

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.TextWidget", function(require) {
odoo.define("kpi_dashboard.TextWidget", function (require) {
"use strict";
var AbstractWidget = require("kpi_dashboard.AbstractWidget");
@@ -6,7 +6,7 @@ odoo.define("kpi_dashboard.TextWidget", function(require) {
var TextWidget = AbstractWidget.extend({
template: "kpi_dashboard.base_text",
fillWidget: function() {
fillWidget: function () {
return;
},
});

View File

@@ -1,4 +1,4 @@
odoo.define("kpi_dashboard.widget_registry", function(require) {
odoo.define("kpi_dashboard.widget_registry", function (require) {
"use strict";
var Registry = require("web.Registry");

View File

@@ -29,7 +29,10 @@
class="direct_action"
t-att-data-id="action_id"
t-att-data-type="action.type"
>Go to <t t-esc="action.name" /></a>
>
Go to
<t t-esc="action.name" />
</a>
</div>
</t>
</t>

View File

@@ -45,7 +45,8 @@ result = {{}}
result['value'] = len(model.search([('id', '=', {})]))
result['previous'] = len(model.search([('id', '!=', {})]))
""".format(
self.kpi.id, self.kpi.id,
self.kpi.id,
self.kpi.id,
)
self.kpi.compute()
value = self.kpi.value
@@ -65,7 +66,8 @@ result = {{}}
result['value'] = len(model.search([('id', '=', {})]))
result['previous'] = len(model.search([('id', '!=', {})]))
""".format(
self.kpi.id, self.kpi.id,
self.kpi.id,
self.kpi.id,
)
self.kpi.compute()
value = self.kpi.value

View File

@@ -166,7 +166,7 @@
</sheet>
<footer>
<button
name="write"
name="store_data"
string="Save"
type="object"
class="oe_highlight"