[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", "name": "Kpi Dashboard",
"summary": """ "summary": """
Create Dashboards using kpis""", Create Dashboards using kpis""",
"version": "14.0.1.1.1", "version": "14.0.1.2.0",
"license": "AGPL-3", "license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)", "author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine", "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" _inherit = "ir.actions.act_window.view"
view_mode = fields.Selection( 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" _inherit = "ir.ui.view"
type = fields.Selection( 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 { return {
"name": self.name, "name": self.name,
"res_model": self._name, "res_model": self._name,
"view_mode": "dashboard", "view_mode": "kpi_dashboard",
"res_id": self.id, "res_id": self.id,
} }

View File

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

View File

@@ -7,7 +7,7 @@ odoo.define("kpi_dashboard.DashboardRenderer", function (require) {
var qweb = core.qweb; var qweb = core.qweb;
var DashboardRenderer = BasicRenderer.extend({ var DashboardRenderer = BasicRenderer.extend({
className: "o_dashboard_view", className: "o_kpi_dashboard_view",
_getDashboardWidget: function (kpi) { _getDashboardWidget: function (kpi) {
var Widget = registry.getAny([kpi.widget, "abstract"]); var Widget = registry.getAny([kpi.widget, "abstract"]);
var widget = new Widget(this, kpi); 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"], jsLibs: ["/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.js"],
cssLibs: ["/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.css"], cssLibs: ["/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.css"],
accesskey: "d", accesskey: "d",
display_name: _lt("Dashboard"), display_name: _lt("KPI Dashboard"),
icon: "fa-tachometer", icon: "fa-tachometer",
viewType: "dashboard", viewType: "kpi_dashboard",
config: _.extend({}, BasicView.prototype.config, { config: _.extend({}, BasicView.prototype.config, {
Controller: DashboardController, Controller: DashboardController,
Renderer: DashboardRenderer, 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; return DashboardView;
}); });

View File

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

View File

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

View File

@@ -84,10 +84,10 @@
</t> </t>
</t> </t>
<t t-name="kpi_dashboard.buttons"> <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 <button
type="button" type="button"
class="btn btn-primary o_dashboard_button_add" class="btn btn-primary o_kpi_dashboard_button_add"
accesskey="d" accesskey="d"
> >
Add to Dashboard Add to Dashboard

View File

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