[MIG] kpi_dashboard: Migration to 14.0

This commit is contained in:
Enric Tobella
2020-10-22 23:21:02 +02:00
parent 4b3f01e27b
commit c0474fa9a7
25 changed files with 143 additions and 118 deletions

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")