[MIG] kpi_dashboard: Migration to 14.0
parent
4b3f01e27b
commit
c0474fa9a7
|
@ -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",
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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"}
|
||||
)
|
||||
|
|
|
@ -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"}
|
||||
)
|
||||
|
|
|
@ -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"}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
|
@ -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">
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -166,7 +166,7 @@
|
|||
</sheet>
|
||||
<footer>
|
||||
<button
|
||||
name="write"
|
||||
name="store_data"
|
||||
string="Save"
|
||||
type="object"
|
||||
class="oe_highlight"
|
||||
|
|
Loading…
Reference in New Issue