Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions web_dashboard_tile/models/tile_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ class TileTile(models.Model):

domain = fields.Text(default="[]", required=True)

domain_error = fields.Char(compute="_compute_data")
domain_error = fields.Char(compute="_compute_data", compute_sudo=True)

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.",
help="Let empty to use the default action related to the selected model.",
domain="[('res_model', '=', model_name)]",
)

Expand All @@ -122,10 +122,12 @@ class TileTile(models.Model):

hide_if_null = fields.Boolean(
string="Hide if null",
help="If checked, the item will be hidden" " if the primary value is null.",
help="If checked, the item will be hidden if the primary value is null.",
)

hidden = fields.Boolean(compute="_compute_data", search="_search_hidden")
hidden = fields.Boolean(
compute="_compute_data", compute_sudo=True, search="_search_hidden"
)

# Primary Value
primary_function = fields.Selection(
Expand All @@ -146,13 +148,13 @@ class TileTile(models.Model):
"ie: '{:,} Kgs' will output '1,000 Kgs' if value is 1000.",
)

primary_value = fields.Float(compute="_compute_data")
primary_value = fields.Float(compute="_compute_data", compute_sudo=True)

primary_formated_value = fields.Char(compute="_compute_data")
primary_formated_value = fields.Char(compute="_compute_data", compute_sudo=True)

primary_helper = fields.Char(compute="_compute_helper", store=True)

primary_error = fields.Char(compute="_compute_data")
primary_error = fields.Char(compute="_compute_data", compute_sudo=True)

# Secondary Value
secondary_function = fields.Selection(
Expand All @@ -171,13 +173,13 @@ class TileTile(models.Model):
"ie: '{:,} Kgs' will output '1,000 Kgs' if value is 1000.",
)

secondary_value = fields.Float(compute="_compute_data")
secondary_value = fields.Float(compute="_compute_data", compute_sudo=True)

secondary_formated_value = fields.Char(compute="_compute_data")
secondary_formated_value = fields.Char(compute="_compute_data", compute_sudo=True)

secondary_helper = fields.Char(compute="_compute_helper", store=True)

secondary_error = fields.Char(compute="_compute_data")
secondary_error = fields.Char(compute="_compute_data", compute_sudo=True)

# Compute Section
@api.depends(
Expand All @@ -202,7 +204,7 @@ def _compute_data(self):
tile.primary_error = False
tile.secondary_error = False
if not tile.model_id or not tile.active:
return
continue

model = self.env[tile.model_id.model]
eval_context = self._get_eval_context()
Expand All @@ -214,7 +216,7 @@ def _compute_data(self):
"Domain Error"
)
tile.domain_error = str(e)
return
continue
fields = [
f.name for f in [tile.primary_field_id, tile.secondary_field_id] if f
]
Expand Down
77 changes: 53 additions & 24 deletions web_dashboard_tile/views/tile_tile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@
<field name="name" />
<field name="category_id" />
<field name="model_id" />
<group>
<filter
string="Category"
name="group_by_category_id"
domain="[]"
context="{'group_by':'category_id'}"
/>
<filter
string="Model"
name="group_by_model_id"
domain="[]"
context="{'group_by':'model_id'}"
/>
</group>
</search>
</field>
</record>
Expand All @@ -19,13 +33,13 @@
<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="model_id" optional="hide" />
<field name="primary_function" optional="show" />
<field name="primary_field_id" optional="show" />
<field name="secondary_function" optional="hide" />
<field name="secondary_field_id" optional="hide" />
<field name="user_id" optional="hide" />
<field name="group_ids" widget="many2many_tags" optional="hide" />
<field name="background_color" widget="color" />
</tree>
</field>
Expand All @@ -37,29 +51,44 @@
<form>
<field name="model_name" invisible="1" />
<sheet>
<h1>
<field name="name" />
</h1>
<group col="4" string="Display">
<field name="category_id" colspan="4" />
<field name="background_color" widget="color" />
<field name="font_color" widget="color" />
<div class="oe_title">
<h1 class="d-flex flex-row">
<field name="name" />
</h1>
</div>
<group string="Display">
<group colspan="2">
<field name="category_id" />
</group>
<group>
<field name="background_color" widget="color" />
</group>
<group>
<field name="font_color" widget="color" />
</group>
</group>
<group col="4" string="Technical Informations">
<field name="model_id" />
<field name="action_id" />
<group string="Technical Informations">
<group>
<field name="model_id" />
</group>
<group>
<field name="action_id" />
</group>
</group>
<group string="Domain">
<field
name="domain"
colspan="4"
colspan="2"
nolabel="1"
widget="ace"
option="{'mode': 'python'}"
/>
<field
name="domain_error"
attrs="{'invisible':[('domain_error','=',False)]}"
nolabel="1"
colspan="4"
/>
<div
colspan="2"
class="alert alert-danger"
role="alert"
attrs="{'invisible': [('domain_error', '=', False)]}"
><field nolabel="1" name="domain_error" /></div>
</group>
<notebook>
<page string="Settings">
Expand Down
Loading