mirror of https://github.com/OCA/web.git
[IMP] web_dashboard_tile: black, isort, prettier
parent
ffe3f9f5f0
commit
0d15ce1df8
|
@ -0,0 +1 @@
|
|||
../../../../web_dashboard_tile
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -2,14 +2,13 @@
|
|||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.http import Controller, route, request
|
||||
from odoo.http import Controller, request, route
|
||||
|
||||
|
||||
class WebDashboardTile(Controller):
|
||||
|
||||
@route('/web_dashboard_tile/create_tile', type='json', auth='user')
|
||||
@route("/web_dashboard_tile/create_tile", type="json", auth="user")
|
||||
def create_tile(self, model_name, *args, **kwargs):
|
||||
IrModel = request.env['ir.model']
|
||||
model = IrModel.search([('model', '=', model_name)])
|
||||
kwargs.update({'model_id': model.id})
|
||||
return request.env['tile.tile'].create(kwargs)
|
||||
IrModel = request.env["ir.model"]
|
||||
model = IrModel.search([("model", "=", model_name)])
|
||||
kwargs.update({"model_id": model.id})
|
||||
return request.env["tile.tile"].create(kwargs)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="category_module" model="tile.category">
|
||||
<field name="name">Modules</field>
|
||||
<field name="sequence">1</field>
|
||||
<field name="active" eval="True"/>
|
||||
<field name="active" eval="True" />
|
||||
</record>
|
||||
|
||||
<record id="category_currency" model="tile.category">
|
||||
<field name="name">Currencies</field>
|
||||
<field name="sequence">2</field>
|
||||
<field name="active" eval="True"/>
|
||||
<field name="active" eval="True" />
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
|
|
@ -1,28 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="installed_modules" model="tile.tile">
|
||||
<field name="name">Installed Modules</field>
|
||||
<field name="category_id" ref="category_module"/>
|
||||
<field name="model_id" ref="base.model_ir_module_module"/>
|
||||
<field name="action_id" ref="base.open_module_tree"/>
|
||||
<field name="domain">[['state', 'in', ['installed', 'to upgrade', 'to remove']]]</field>
|
||||
<field name="category_id" ref="category_module" />
|
||||
<field name="model_id" ref="base.model_ir_module_module" />
|
||||
<field name="action_id" ref="base.open_module_tree" />
|
||||
<field
|
||||
name="domain"
|
||||
>[['state', 'in', ['installed', 'to upgrade', 'to remove']]]</field>
|
||||
</record>
|
||||
|
||||
<record id="installed_OCA_modules" model="tile.tile">
|
||||
<field name="name">Installed OCA Modules</field>
|
||||
<field name="category_id" ref="category_module"/>
|
||||
<field name="model_id" ref="base.model_ir_module_module"/>
|
||||
<field name="action_id" ref="base.open_module_tree"/>
|
||||
<field name="domain">[['state', 'in', ['installed', 'to upgrade', 'to remove']], ['author', 'ilike', 'Odoo Community Association (OCA)']]</field>
|
||||
<field name="category_id" ref="category_module" />
|
||||
<field name="model_id" ref="base.model_ir_module_module" />
|
||||
<field name="action_id" ref="base.open_module_tree" />
|
||||
<field
|
||||
name="domain"
|
||||
>[['state', 'in', ['installed', 'to upgrade', 'to remove']], ['author', 'ilike', 'Odoo Community Association (OCA)']]</field>
|
||||
</record>
|
||||
|
||||
<record id="all_currency_with_rate" model="tile.tile">
|
||||
<field name="name">Currencies (Max Rate)</field>
|
||||
<field name="category_id" ref="category_currency"/>
|
||||
<field name="model_id" ref="base.model_res_currency"/>
|
||||
<field name="category_id" ref="category_currency" />
|
||||
<field name="model_id" ref="base.model_res_currency" />
|
||||
<field name="secondary_function">max</field>
|
||||
<field name="secondary_field_id" ref="base.field_res_currency__rate"/>
|
||||
<field name="secondary_field_id" ref="base.field_res_currency__rate" />
|
||||
<field name="domain">[]</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -13,17 +13,15 @@ def migrate(cr, version):
|
|||
|
||||
# categories was optional in previous versions
|
||||
# affecting all tiles without categories
|
||||
tiles_without_category = env["tile.tile"].search(
|
||||
[('category_id', '=', False)])
|
||||
tiles_without_category = env["tile.tile"].search([("category_id", "=", False)])
|
||||
if tiles_without_category:
|
||||
default_category = env["tile.category"].create({
|
||||
"name": "Default Category",
|
||||
})
|
||||
tiles_without_category.write({
|
||||
'category_id': default_category.id
|
||||
})
|
||||
default_category = env["tile.category"].create(
|
||||
{
|
||||
"name": "Default Category",
|
||||
}
|
||||
)
|
||||
tiles_without_category.write({"category_id": default_category.id})
|
||||
|
||||
# Enable all categories, to generate actions and menus
|
||||
categories = env['tile.category'].with_context(
|
||||
active_test=False).search([])
|
||||
categories.write({'active': True})
|
||||
categories = env["tile.category"].with_context(active_test=False).search([])
|
||||
categories.write({"active": True})
|
||||
|
|
|
@ -17,23 +17,24 @@ class TileCategory(models.Model):
|
|||
active = fields.Boolean(default=True)
|
||||
|
||||
action_id = fields.Many2one(
|
||||
string='Odoo Action', comodel_name='ir.actions.act_window',
|
||||
readonly=True)
|
||||
string="Odoo Action", comodel_name="ir.actions.act_window", readonly=True
|
||||
)
|
||||
|
||||
menu_id = fields.Many2one(
|
||||
string='Odoo Menu', comodel_name='ir.ui.menu', readonly=True)
|
||||
string="Odoo Menu", comodel_name="ir.ui.menu", readonly=True
|
||||
)
|
||||
|
||||
tile_ids = fields.One2many(
|
||||
string='Tiles', comodel_name='tile.tile',
|
||||
inverse_name='category_id')
|
||||
string="Tiles", comodel_name="tile.tile", inverse_name="category_id"
|
||||
)
|
||||
|
||||
tile_qty = fields.Integer(
|
||||
string='Tiles Quantity',
|
||||
compute='_compute_tile_qty',
|
||||
string="Tiles Quantity",
|
||||
compute="_compute_tile_qty",
|
||||
store=True,
|
||||
)
|
||||
|
||||
@api.depends('tile_ids')
|
||||
@api.depends("tile_ids")
|
||||
def _compute_tile_qty(self):
|
||||
for category in self:
|
||||
category.tile_qty = len(category.tile_ids)
|
||||
|
@ -41,34 +42,36 @@ class TileCategory(models.Model):
|
|||
def _prepare_action(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': self.name,
|
||||
'res_model': 'tile.tile',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'kanban',
|
||||
'domain': """[
|
||||
"name": self.name,
|
||||
"res_model": "tile.tile",
|
||||
"type": "ir.actions.act_window",
|
||||
"view_mode": "kanban",
|
||||
"domain": """[
|
||||
('hidden', '=', False),
|
||||
'|', ('user_id', '=', False), ('user_id', '=', uid),
|
||||
('category_id', '=', {self.id})
|
||||
]""".format(self=self),
|
||||
]""".format(
|
||||
self=self
|
||||
),
|
||||
}
|
||||
|
||||
def _prepare_menu(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': self.name,
|
||||
'parent_id': self.env.ref(
|
||||
'web_dashboard_tile.menu_dashboard_tile').id,
|
||||
'action': 'ir.actions.act_window,%d' % self.action_id.id,
|
||||
'sequence': self.sequence,
|
||||
"name": self.name,
|
||||
"parent_id": self.env.ref("web_dashboard_tile.menu_dashboard_tile").id,
|
||||
"action": "ir.actions.act_window,%d" % self.action_id.id,
|
||||
"sequence": self.sequence,
|
||||
}
|
||||
|
||||
def _create_ui(self):
|
||||
IrUiMenu = self.env['ir.ui.menu']
|
||||
IrActionsActWindows = self.env['ir.actions.act_window']
|
||||
IrUiMenu = self.env["ir.ui.menu"]
|
||||
IrActionsActWindows = self.env["ir.actions.act_window"]
|
||||
for category in self:
|
||||
if not category.action_id:
|
||||
category.action_id = IrActionsActWindows.create(
|
||||
category._prepare_action())
|
||||
category._prepare_action()
|
||||
)
|
||||
if not category.menu_id:
|
||||
category.menu_id = IrUiMenu.create(category._prepare_menu())
|
||||
|
||||
|
@ -88,16 +91,16 @@ class TileCategory(models.Model):
|
|||
|
||||
def write(self, vals):
|
||||
res = super().write(vals)
|
||||
if 'active' in vals.keys():
|
||||
if vals.get('active'):
|
||||
if "active" in vals.keys():
|
||||
if vals.get("active"):
|
||||
self._create_ui()
|
||||
else:
|
||||
self._delete_ui()
|
||||
if 'sequence' in vals.keys():
|
||||
self.mapped('menu_id').write({'sequence': vals['sequence']})
|
||||
if 'name' in vals.keys():
|
||||
self.mapped('menu_id').write({'name': vals['name']})
|
||||
self.mapped('action_id').write({'name': vals['name']})
|
||||
if "sequence" in vals.keys():
|
||||
self.mapped("menu_id").write({"sequence": vals["sequence"]})
|
||||
if "name" in vals.keys():
|
||||
self.mapped("menu_id").write({"name": vals["name"]})
|
||||
self.mapped("action_id").write({"name": vals["name"]})
|
||||
return res
|
||||
|
||||
def unlink(self):
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
|
||||
import datetime
|
||||
import time
|
||||
from statistics import median
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from collections import OrderedDict
|
||||
from statistics import median
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.exceptions import ValidationError, except_orm
|
||||
from odoo.tools.safe_eval import safe_eval as eval
|
||||
from odoo.tools.translate import _
|
||||
from odoo.exceptions import ValidationError, except_orm
|
||||
|
||||
|
||||
FIELD_FUNCTIONS = OrderedDict(
|
||||
[
|
||||
|
@ -81,8 +81,11 @@ class TileTile(models.Model):
|
|||
sequence = fields.Integer(default=0, required=True)
|
||||
|
||||
category_id = fields.Many2one(
|
||||
string="Category", comodel_name="tile.category", required=True,
|
||||
ondelete="CASCADE")
|
||||
string="Category",
|
||||
comodel_name="tile.category",
|
||||
required=True,
|
||||
ondelete="CASCADE",
|
||||
)
|
||||
|
||||
user_id = fields.Many2one(string="User", comodel_name="res.users")
|
||||
|
||||
|
@ -98,9 +101,7 @@ class TileTile(models.Model):
|
|||
"(that is, when User field is left empty)",
|
||||
)
|
||||
|
||||
model_id = fields.Many2one(
|
||||
comodel_name="ir.model", string="Model", required=True
|
||||
)
|
||||
model_id = fields.Many2one(comodel_name="ir.model", string="Model", required=True)
|
||||
|
||||
model_name = fields.Char(string="Model name", related="model_id.model")
|
||||
|
||||
|
@ -108,26 +109,30 @@ class TileTile(models.Model):
|
|||
|
||||
action_id = fields.Many2one(
|
||||
comodel_name="ir.actions.act_window",
|
||||
string="Action", help="Let empty to use the default action related to"
|
||||
" the selected model.",
|
||||
domain="[('res_model', '=', model_name)]")
|
||||
string="Action",
|
||||
help="Let empty to use the default action related to" " the selected model.",
|
||||
domain="[('res_model', '=', model_name)]",
|
||||
)
|
||||
|
||||
active = fields.Boolean(
|
||||
compute="_compute_active", search="_search_active", readonly=True
|
||||
)
|
||||
|
||||
hide_if_null = fields.Boolean(
|
||||
string="Hide if null", help="If checked, the item will be hidden"
|
||||
" if the primary value is null.")
|
||||
string="Hide if null",
|
||||
help="If checked, the item will be hidden" " if the primary value is null.",
|
||||
)
|
||||
|
||||
hidden = fields.Boolean(
|
||||
string="Hidden", compute="_compute_data",
|
||||
search="_search_hidden")
|
||||
string="Hidden", compute="_compute_data", search="_search_hidden"
|
||||
)
|
||||
|
||||
# Primary Value
|
||||
primary_function = fields.Selection(
|
||||
string="Primary Function", required=True,
|
||||
selection=FIELD_FUNCTION_SELECTION, default="count",
|
||||
string="Primary Function",
|
||||
required=True,
|
||||
selection=FIELD_FUNCTION_SELECTION,
|
||||
default="count",
|
||||
)
|
||||
|
||||
primary_field_id = fields.Many2one(
|
||||
|
@ -143,19 +148,20 @@ class TileTile(models.Model):
|
|||
"ie: '{:,} Kgs' will output '1,000 Kgs' if value is 1000.",
|
||||
)
|
||||
|
||||
primary_value = fields.Float(
|
||||
string="Primary Value", compute="_compute_data")
|
||||
primary_value = fields.Float(string="Primary Value", compute="_compute_data")
|
||||
|
||||
primary_formated_value = fields.Char(
|
||||
string="Primary Formated Value", compute="_compute_data")
|
||||
string="Primary Formated Value", compute="_compute_data"
|
||||
)
|
||||
|
||||
primary_helper = fields.Char(
|
||||
string="Primary Helper", compute="_compute_helper",
|
||||
store=True)
|
||||
string="Primary Helper", compute="_compute_helper", store=True
|
||||
)
|
||||
|
||||
# Secondary Value
|
||||
secondary_function = fields.Selection(
|
||||
string="Secondary Function", selection=FIELD_FUNCTION_SELECTION,
|
||||
string="Secondary Function",
|
||||
selection=FIELD_FUNCTION_SELECTION,
|
||||
)
|
||||
|
||||
secondary_field_id = fields.Many2one(
|
||||
|
@ -171,16 +177,14 @@ class TileTile(models.Model):
|
|||
"ie: '{:,} Kgs' will output '1,000 Kgs' if value is 1000.",
|
||||
)
|
||||
|
||||
secondary_value = fields.Float(
|
||||
string="Secondary Value", compute="_compute_data")
|
||||
secondary_value = fields.Float(string="Secondary Value", compute="_compute_data")
|
||||
|
||||
secondary_formated_value = fields.Char(
|
||||
string="Secondary Formated Value", compute="_compute_data"
|
||||
)
|
||||
|
||||
secondary_helper = fields.Char(
|
||||
string="Secondary Helper", compute="_compute_helper",
|
||||
store=True
|
||||
string="Secondary Helper", compute="_compute_helper", store=True
|
||||
)
|
||||
|
||||
error = fields.Char(string="Error Details", compute="_compute_data")
|
||||
|
@ -198,19 +202,14 @@ class TileTile(models.Model):
|
|||
count = model.search_count(eval(domain, eval_context))
|
||||
except Exception as e:
|
||||
tile.primary_value = 0.0
|
||||
tile.primary_formated_value =\
|
||||
tile.secondary_formated_value = _("Error")
|
||||
tile.primary_formated_value = tile.secondary_formated_value = _("Error")
|
||||
tile.error = str(e)
|
||||
return
|
||||
fields = [
|
||||
f.name
|
||||
for f in [tile.primary_field_id, tile.secondary_field_id]
|
||||
if f
|
||||
f.name for f in [tile.primary_field_id, tile.secondary_field_id] if f
|
||||
]
|
||||
read_vals = (
|
||||
fields
|
||||
and model.search_read(eval(domain, eval_context), fields)
|
||||
or []
|
||||
fields and model.search_read(eval(domain, eval_context), fields) or []
|
||||
)
|
||||
for f in ["primary_", "secondary_"]:
|
||||
f_function = f + "function"
|
||||
|
@ -231,8 +230,9 @@ class TileTile(models.Model):
|
|||
value = func(vals or [0.0])
|
||||
try:
|
||||
tile[f_value] = value
|
||||
tile[f_formated_value] = (
|
||||
tile[f_format] or "{:,}").format(value)
|
||||
tile[f_formated_value] = (tile[f_format] or "{:,}").format(
|
||||
value
|
||||
)
|
||||
if tile.hide_if_null and not value:
|
||||
tile.hidden = True
|
||||
except ValueError as e:
|
||||
|
@ -274,8 +274,9 @@ class TileTile(models.Model):
|
|||
def _search_hidden(self, operator, operand):
|
||||
items = self.search([])
|
||||
hidden_tile_ids = [x.id for x in items if x.hidden]
|
||||
if (operator == "=" and operand is False) or\
|
||||
(operator == "!=" and operand is True):
|
||||
if (operator == "=" and operand is False) or (
|
||||
operator == "!=" and operand is True
|
||||
):
|
||||
domain = [("id", "not in", hidden_tile_ids)]
|
||||
else:
|
||||
domain = [("id", "in", hidden_tile_ids)]
|
||||
|
@ -346,12 +347,14 @@ class TileTile(models.Model):
|
|||
"target": "current",
|
||||
"domain": self.domain,
|
||||
}
|
||||
action.update({
|
||||
"name": self.name,
|
||||
"display_name": self.name,
|
||||
"context": dict(self.env.context, group_by=False),
|
||||
"domain": self.domain,
|
||||
})
|
||||
action.update(
|
||||
{
|
||||
"name": self.name,
|
||||
"display_name": self.name,
|
||||
"context": dict(self.env.context, group_by=False),
|
||||
"domain": self.domain,
|
||||
}
|
||||
)
|
||||
return action
|
||||
|
||||
@api.model
|
||||
|
@ -359,9 +362,7 @@ class TileTile(models.Model):
|
|||
if "model_id" in vals and not vals["model_id"].isdigit():
|
||||
# need to replace model_name with its id
|
||||
vals["model_id"] = (
|
||||
self.env["ir.model"]
|
||||
.search([("model", "=", vals["model_id"])])
|
||||
.id
|
||||
self.env["ir.model"].search([("model", "=", vals["model_id"])]).id
|
||||
)
|
||||
self.create(vals)
|
||||
|
||||
|
|
|
@ -30,4 +30,3 @@ You can optionally define a secondary value, for that purpose :
|
|||
* You can define a specific format. (``.format()`` python syntax)
|
||||
|
||||
.. image:: ../static/description/tile_tile_form_secondary_value.png
|
||||
|
||||
|
|
|
@ -12,4 +12,3 @@
|
|||
* Restore original Domain + Filter when an action is set.
|
||||
* Posibility to hide the tile based on a field expression.
|
||||
* Posibility to set the background color based on a field expression.
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="model_tile_rule" model="ir.rule">
|
||||
<field name="name">tile.owner</field>
|
||||
<field name="model_id" ref="model_tile_tile" />
|
||||
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
|
||||
<field name="groups" eval="[(4, ref('base.group_user'))]" />
|
||||
<field name="domain_force">
|
||||
[
|
||||
'|',
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
/* Fix bug where draggin a tile results in the element losing its style */
|
||||
.o_kanban_view .oe_dashboard_tile {
|
||||
padding: 0px !important;
|
||||
padding: 0px !important;
|
||||
}
|
||||
.o_kanban_view .oe_dashboard_tile .tile_background {
|
||||
padding: 8px;
|
||||
height: 100%;
|
||||
padding: 8px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.o_kanban_view .oe_dashboard_tile .tile_label,
|
||||
|
@ -24,7 +24,7 @@
|
|||
font-size: 15px;
|
||||
}
|
||||
|
||||
.o_kanban_view .oe_dashboard_tile .tile_primary_value{
|
||||
.o_kanban_view .oe_dashboard_tile .tile_primary_value {
|
||||
font-size: 54px;
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
|
@ -32,7 +32,7 @@
|
|||
bottom: 5px;
|
||||
}
|
||||
|
||||
.o_kanban_view .oe_dashboard_tile .tile_secondary_value{
|
||||
.o_kanban_view .oe_dashboard_tile .tile_secondary_value {
|
||||
display: none;
|
||||
font-size: 18px;
|
||||
font-style: italic;
|
||||
|
@ -42,12 +42,12 @@
|
|||
bottom: 5px;
|
||||
}
|
||||
|
||||
.o_kanban_view .oe_dashboard_tile .with_secondary .tile_primary_value{
|
||||
.o_kanban_view .oe_dashboard_tile .with_secondary .tile_primary_value {
|
||||
font-size: 38px;
|
||||
bottom: 30px;
|
||||
}
|
||||
|
||||
.o_kanban_view .oe_dashboard_tile .with_secondary .tile_secondary_value{
|
||||
.o_kanban_view .oe_dashboard_tile .with_secondary .tile_secondary_value {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<menuitem id="menu_dashboard_tile"
|
||||
<menuitem
|
||||
id="menu_dashboard_tile"
|
||||
parent="base.menu_board_root"
|
||||
name="Overview"
|
||||
sequence="0"/>
|
||||
sequence="0"
|
||||
/>
|
||||
|
||||
<menuitem id="menu_dashboard_tile_settings"
|
||||
<menuitem
|
||||
id="menu_dashboard_tile_settings"
|
||||
parent="base.menu_board_root"
|
||||
name="Settings"
|
||||
sequence="100"/>
|
||||
sequence="100"
|
||||
/>
|
||||
|
||||
</odoo>
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel="stylesheet" href="/web_dashboard_tile/static/src/css/web_dashboard_tile.css"/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/web_dashboard_tile/static/src/css/web_dashboard_tile.css"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="action_category_2_tile" model="ir.actions.act_window">
|
||||
|
@ -15,21 +15,35 @@
|
|||
<form>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive">
|
||||
<field name="active" widget="boolean_button" options="{"terminology": "archive"}"/>
|
||||
<button
|
||||
name="toggle_active"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-archive"
|
||||
>
|
||||
<field
|
||||
name="active"
|
||||
widget="boolean_button"
|
||||
options="{"terminology": "archive"}"
|
||||
/>
|
||||
</button>
|
||||
<button class="oe_stat_button" type="action" name="%(web_dashboard_tile.action_category_2_tile)d"
|
||||
attrs="{'invisible': [('tile_qty', '=', 0)]}" icon="fa-list">
|
||||
<field string="Items" name="tile_qty" widget="statinfo"/>
|
||||
<button
|
||||
class="oe_stat_button"
|
||||
type="action"
|
||||
name="%(web_dashboard_tile.action_category_2_tile)d"
|
||||
attrs="{'invisible': [('tile_qty', '=', 0)]}"
|
||||
icon="fa-list"
|
||||
>
|
||||
<field string="Items" name="tile_qty" widget="statinfo" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1><field name="name" required="1"/></h1>
|
||||
<label for="name" class="oe_edit_only" />
|
||||
<h1><field name="name" required="1" /></h1>
|
||||
</div>
|
||||
<group string="Technical Informations">
|
||||
<field name="menu_id"/>
|
||||
<field name="action_id"/>
|
||||
<field name="menu_id" />
|
||||
<field name="action_id" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
@ -40,10 +54,10 @@
|
|||
<field name="model">tile.category</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree decoration-muted="(active == False)">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="name"/>
|
||||
<field name="tile_qty"/>
|
||||
<field name="active"/>
|
||||
<field name="sequence" widget="handle" />
|
||||
<field name="name" />
|
||||
<field name="tile_qty" />
|
||||
<field name="active" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -56,8 +70,11 @@
|
|||
<field name="context">{'active_test': False}</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_tile_category"
|
||||
<menuitem
|
||||
id="menu_tile_category"
|
||||
parent="menu_dashboard_tile_settings"
|
||||
action="action_tile_category" sequence="50"/>
|
||||
action="action_tile_category"
|
||||
sequence="50"
|
||||
/>
|
||||
|
||||
</odoo>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_tile_tile_search" model="ir.ui.view">
|
||||
<field name="model">tile.tile</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="name"/>
|
||||
<field name="category_id"/>
|
||||
<field name="model_id"/>
|
||||
<field name="name" />
|
||||
<field name="category_id" />
|
||||
<field name="model_id" />
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -16,17 +16,17 @@
|
|||
<field name="model">tile.tile</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="name"/>
|
||||
<field name="category_id"/>
|
||||
<field name="model_id"/>
|
||||
<field name="primary_function"/>
|
||||
<field name="primary_field_id"/>
|
||||
<field name="secondary_function"/>
|
||||
<field name="secondary_field_id"/>
|
||||
<field name="user_id"/>
|
||||
<field name="group_ids"/>
|
||||
<field name="background_color" widget="color"/>
|
||||
<field name="sequence" widget="handle" />
|
||||
<field name="name" />
|
||||
<field name="category_id" />
|
||||
<field name="model_id" />
|
||||
<field name="primary_function" />
|
||||
<field name="primary_field_id" />
|
||||
<field name="secondary_function" />
|
||||
<field name="secondary_field_id" />
|
||||
<field name="user_id" />
|
||||
<field name="group_ids" />
|
||||
<field name="background_color" widget="color" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -37,64 +37,79 @@
|
|||
<form>
|
||||
<sheet>
|
||||
<h1>
|
||||
<field name="name"/>
|
||||
<field name="name" />
|
||||
</h1>
|
||||
<group>
|
||||
<field name="category_id"/>
|
||||
<field name="user_id"/>
|
||||
<field name="category_id" />
|
||||
<field name="user_id" />
|
||||
</group>
|
||||
<group col="4">
|
||||
<separator string="Display" colspan="4"/>
|
||||
<field name="background_color" widget="color"/>
|
||||
<field name="font_color" widget="color"/>
|
||||
<separator string="Technical Informations" colspan="4"/>
|
||||
<field name="model_id"/>
|
||||
<field name="action_id"/>
|
||||
<field name="domain" colspan="4"/>
|
||||
<field name="model_name" invisible="1"/>
|
||||
<separator colspan="4"/>
|
||||
<field name="error" attrs="{'invisible':[('error','=',False)]}"/>
|
||||
<separator string="Display" colspan="4" />
|
||||
<field name="background_color" widget="color" />
|
||||
<field name="font_color" widget="color" />
|
||||
<separator string="Technical Informations" colspan="4" />
|
||||
<field name="model_id" />
|
||||
<field name="action_id" />
|
||||
<field name="domain" colspan="4" />
|
||||
<field name="model_name" invisible="1" />
|
||||
<separator colspan="4" />
|
||||
<field
|
||||
name="error"
|
||||
attrs="{'invisible':[('error','=',False)]}"
|
||||
/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Settings">
|
||||
<group string="Main Value">
|
||||
<group>
|
||||
<field name="primary_function"/>
|
||||
<field name="primary_field_id" attrs="{
|
||||
<field name="primary_function" />
|
||||
<field
|
||||
name="primary_field_id"
|
||||
attrs="{
|
||||
'invisible':[('primary_function','in',[False,'count'])],
|
||||
'required':[('primary_function','not in',[False,'count'])],
|
||||
}"/>
|
||||
}"
|
||||
/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="primary_format"/>
|
||||
<field name="hide_if_null"/>
|
||||
<field name="primary_format" />
|
||||
<field name="hide_if_null" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="primary_helper"/>
|
||||
<field name="primary_value"/>
|
||||
<field name="primary_formated_value" attrs="{'invisible':[('primary_value','=',False)]}"/>
|
||||
<field name="primary_helper" />
|
||||
<field name="primary_value" />
|
||||
<field
|
||||
name="primary_formated_value"
|
||||
attrs="{'invisible':[('primary_value','=',False)]}"
|
||||
/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="Secondary Value">
|
||||
<group>
|
||||
<field name="secondary_function"/>
|
||||
<field name="secondary_field_id" attrs="{
|
||||
<field name="secondary_function" />
|
||||
<field
|
||||
name="secondary_field_id"
|
||||
attrs="{
|
||||
'invisible':[('secondary_function','in',[False,'count'])],
|
||||
'required':[('secondary_function','not in',[False,'count'])],
|
||||
}"/>
|
||||
}"
|
||||
/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="secondary_format"/>
|
||||
<field name="secondary_format" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="secondary_helper"/>
|
||||
<field name="secondary_value"/>
|
||||
<field name="secondary_formated_value" attrs="{'invisible':[('secondary_value','=',False)]}"/>
|
||||
<field name="secondary_helper" />
|
||||
<field name="secondary_value" />
|
||||
<field
|
||||
name="secondary_formated_value"
|
||||
attrs="{'invisible':[('secondary_value','=',False)]}"
|
||||
/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Security">
|
||||
<field name="group_ids"/>
|
||||
<field name="group_ids" />
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
|
@ -107,38 +122,67 @@
|
|||
<field name="arch" type="xml">
|
||||
|
||||
<kanban edit="false" create="false">
|
||||
<field name="name"/>
|
||||
<field name="domain"/>
|
||||
<field name="model_id"/>
|
||||
<field name="action_id"/>
|
||||
<field name="background_color"/>
|
||||
<field name="font_color"/>
|
||||
<field name="primary_function"/>
|
||||
<field name="primary_helper"/>
|
||||
<field name="secondary_function"/>
|
||||
<field name="secondary_helper"/>
|
||||
<field name="name" />
|
||||
<field name="domain" />
|
||||
<field name="model_id" />
|
||||
<field name="action_id" />
|
||||
<field name="background_color" />
|
||||
<field name="font_color" />
|
||||
<field name="primary_function" />
|
||||
<field name="primary_helper" />
|
||||
<field name="secondary_function" />
|
||||
<field name="secondary_helper" />
|
||||
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="oe_dashboard_tile oe_kanban_global_click" t-attf-style="background-color:#{record.background_color.raw_value}" >
|
||||
<div
|
||||
t-attf-class="oe_dashboard_tile oe_kanban_global_click"
|
||||
t-attf-style="background-color:#{record.background_color.raw_value}"
|
||||
>
|
||||
<div class="oe_kanban_content">
|
||||
<a type="object" name="open_link" args="[]" t-attf-style="color:#{record.font_color.raw_value};">
|
||||
<div style="height:100%;" t-att-class="record.secondary_function.raw_value and 'with_secondary' or 'simple'">
|
||||
<a
|
||||
type="object"
|
||||
name="open_link"
|
||||
args="[]"
|
||||
t-attf-style="color:#{record.font_color.raw_value};"
|
||||
>
|
||||
<div
|
||||
style="height:100%;"
|
||||
t-att-class="record.secondary_function.raw_value and 'with_secondary' or 'simple'"
|
||||
>
|
||||
<div class="tile_label">
|
||||
<field name="name"/>
|
||||
<field name="name" />
|
||||
</div>
|
||||
<div class="tile_primary_value" t-att-title="record.primary_helper.raw_value">
|
||||
<t t-set="l" t-value="record.primary_formated_value.raw_value.length" />
|
||||
<t t-set="s" t-value="l>=12 and 35 or l>=10 and 45 or l>=8 and 55 or l>=6 and 75 or l>4 and 85 or 100"/>
|
||||
<span t-attf-style="font-size: #{s}%;"><field name="primary_formated_value"/></span>
|
||||
<div
|
||||
class="tile_primary_value"
|
||||
t-att-title="record.primary_helper.raw_value"
|
||||
>
|
||||
<t
|
||||
t-set="l"
|
||||
t-value="record.primary_formated_value.raw_value.length"
|
||||
/>
|
||||
<t
|
||||
t-set="s"
|
||||
t-value="l>=12 and 35 or l>=10 and 45 or l>=8 and 55 or l>=6 and 75 or l>4 and 85 or 100"
|
||||
/>
|
||||
<span
|
||||
t-attf-style="font-size: #{s}%;"
|
||||
><field
|
||||
name="primary_formated_value"
|
||||
/></span>
|
||||
</div>
|
||||
<div class="tile_secondary_value" t-att-title="record.secondary_helper.raw_value">
|
||||
<span><field name="secondary_formated_value"/></span>
|
||||
<div
|
||||
class="tile_secondary_value"
|
||||
t-att-title="record.secondary_helper.raw_value"
|
||||
>
|
||||
<span><field
|
||||
name="secondary_formated_value"
|
||||
/></span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="oe_clear"></div>
|
||||
<div class="oe_clear" />
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
|
@ -153,8 +197,11 @@
|
|||
<field name="view_mode">tree,form,kanban</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_tile_tile"
|
||||
<menuitem
|
||||
id="menu_tile_tile"
|
||||
parent="menu_dashboard_tile_settings"
|
||||
action="action_tile_tile" sequence="10"/>
|
||||
action="action_tile_tile"
|
||||
sequence="10"
|
||||
/>
|
||||
|
||||
</odoo>
|
||||
|
|
Loading…
Reference in New Issue