[IMP] kpi_dashboard: Allow installation with EE

This commit is contained in:
Enric Tobella
2023-05-09 09:39:20 +02:00
parent 47bb1cdd99
commit ce4aa39c2c
12 changed files with 48 additions and 16 deletions

View File

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

View File

@@ -0,0 +1,30 @@
# Copyright 2023 CreuBlanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
"""We need to do the changes on pre-migration in order to avoid cascades"""
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_ui_view as iuv
SET type = 'kpi_dashboard'
FROM ir_model_data as imd
WHERE
iuv.id = imd.res_id
AND imd.module = 'kpi_dashboard'
AND imd.name = 'kpi_dashboard_dashboard_view'
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_act_window
SET view_mode = 'kpi_dashboard'
WHERE view_mode = 'dashboard' AND res_model = 'kpi.dashboard'
""",
)

View File

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

View File

@@ -8,5 +8,6 @@ class IrUiView(models.Model):
_inherit = "ir.ui.view"
type = fields.Selection(
selection_add=[("dashboard", "Dashboard")], ondelete={"dashboard": "cascade"}
selection_add=[("kpi_dashboard", "Dashboard")],
ondelete={"kpi_dashboard": "cascade"},
)

View File

@@ -90,7 +90,7 @@ class KpiDashboard(models.Model):
return {
"name": self.name,
"res_model": self._name,
"view_mode": "dashboard",
"view_mode": "kpi_dashboard",
"res_id": self.id,
}

View File

@@ -67,7 +67,7 @@ odoo.define("kpi_dashboard.DashboardController", function (require) {
action_id: action,
context_to_save: {res_id: self.initialState.res_id},
domain: [("id", "=", self.initialState.res_id)],
view_mode: "dashboard",
view_mode: "kpi_dashboard",
name: name,
},
})
@@ -88,7 +88,7 @@ odoo.define("kpi_dashboard.DashboardController", function (require) {
// HOOK Function
this.$buttons.on(
"click",
".o_dashboard_button_add",
".o_kpi_dashboard_button_add",
this._addDashboard.bind(this)
);
},

View File

@@ -7,7 +7,7 @@ odoo.define("kpi_dashboard.DashboardRenderer", function (require) {
var qweb = core.qweb;
var DashboardRenderer = BasicRenderer.extend({
className: "o_dashboard_view",
className: "o_kpi_dashboard_view",
_getDashboardWidget: function (kpi) {
var Widget = registry.getAny([kpi.widget, "abstract"]);
var widget = new Widget(this, kpi);

View File

@@ -14,9 +14,9 @@ odoo.define("kpi_dashboard.DashboardView", function (require) {
jsLibs: ["/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.js"],
cssLibs: ["/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.css"],
accesskey: "d",
display_name: _lt("Dashboard"),
display_name: _lt("KPI Dashboard"),
icon: "fa-tachometer",
viewType: "dashboard",
viewType: "kpi_dashboard",
config: _.extend({}, BasicView.prototype.config, {
Controller: DashboardController,
Renderer: DashboardRenderer,
@@ -34,7 +34,7 @@ odoo.define("kpi_dashboard.DashboardView", function (require) {
},
});
view_registry.add("dashboard", DashboardView);
view_registry.add("kpi_dashboard", DashboardView);
return DashboardView;
});

View File

@@ -10,7 +10,7 @@ odoo.define("kpi_dashboard.KpiFieldWidget", function (require) {
var KpiFieldWidget = basic_fields.FieldChar.extend({
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",
className: "o_kpi_dashboard_view",
_renderReadonly: function () {
this.$el.html($(qweb.render("dashboard_kpi.dashboard")));
var marginx = 0;

View File

@@ -1,4 +1,4 @@
.o_dashboard_view {
.o_kpi_dashboard_view {
height: 100%;
@include o-webclient-padding(
$top: $o-horizontal-padding/2,

View File

@@ -84,10 +84,10 @@
</t>
</t>
<t t-name="kpi_dashboard.buttons">
<div class="o_dashboard_buttons" role="toolbar" aria-label="Main actions">
<div class="o_kpi_dashboard_buttons" role="toolbar" aria-label="Main actions">
<button
type="button"
class="btn btn-primary o_dashboard_button_add"
class="btn btn-primary o_kpi_dashboard_button_add"
accesskey="d"
>
Add to Dashboard

View File

@@ -98,14 +98,14 @@
<field name="name">kpi.dashboard.dashboard (in kpi_dashboard)</field>
<field name="model">kpi.dashboard</field>
<field name="arch" type="xml">
<dashboard />
<kpi_dashboard />
</field>
</record>
<record model="ir.actions.act_window" id="kpi_dashboard_act_window">
<field name="name">Kpi Dashboard</field>
<!-- TODO -->
<field name="res_model">kpi.dashboard</field>
<field name="view_mode">tree,form,dashboard</field>
<field name="view_mode">tree,form,kpi_dashboard</field>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>