Skip to content

Commit

Permalink
Merge PR #31 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
OCA-git-bot committed May 29, 2024
2 parents 292967c + 5b9316b commit 00657f8
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions spreadsheet_dashboard_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
"data": [
"wizards/spreadsheet_spreadsheet_import.xml",
"views/spreadsheet_dashboard_group_views.xml",
"views/spreadsheet_dashboard.xml",
"data/spreadsheet_spreadsheet_import_mode.xml",
],
Expand Down
12 changes: 12 additions & 0 deletions spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ class SpreadsheetDashboard(models.Model):
_name = "spreadsheet.dashboard"
_inherit = ["spreadsheet.dashboard", "spreadsheet.abstract"]

active = fields.Boolean(default=True)
spreadsheet_raw = fields.Serialized(
inverse="_inverse_spreadsheet_raw", compute="_compute_spreadsheet_raw"
)
can_edit = fields.Boolean(compute="_compute_can_edit")

@api.depends("data")
def _compute_spreadsheet_raw(self):
Expand All @@ -30,3 +32,13 @@ def _inverse_spreadsheet_raw(self):
record.data = base64.encodebytes(
json.dumps(record.spreadsheet_raw).encode("UTF-8")
)

def _compute_can_edit(self):
"""We can edit if the record doesn't have XML-ID, or the XML-ID is noupdate=1"""
self.can_edit = True
for record in self.filtered("id"):
imd = self.env["ir.model.data"].search(
[("model", "=", record._name), ("res_id", "=", record.id)]
)
if imd and imd.module != "__export__":
record.can_edit = imd.noupdate
1 change: 0 additions & 1 deletion spreadsheet_dashboard_oca/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down
21 changes: 21 additions & 0 deletions spreadsheet_dashboard_oca/views/spreadsheet_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,42 @@
<field name="arch" type="xml">
<tree position="attributes">
<attribute name="create">1</attribute>
<attribute name="decoration-muted">not active</attribute>
</tree>
<tree position="inside">
<field name="can_edit" invisible="1" />
<field
name="data"
groups="base.group_no_one"
widget="binary"
filename="name"
/>
<!-- Put the button 2 times for having the edit button explicitly disabled for discoverability -->
<button
name="open_spreadsheet"
type="object"
string="Edit"
icon="fa-pencil"
disabled="1"
groups="base.group_system"
attrs="{'invisible': [('can_edit', '=', True)]}"
/>
<button
name="open_spreadsheet"
type="object"
string="Edit"
icon="fa-pencil"
groups="base.group_system"
attrs="{'invisible': [('can_edit', '=', False)]}"
/>
<button
name="copy"
type="object"
string="Copy"
icon="fa-copy"
groups="base.group_system"
/>
<field name="active" widget="boolean_toggle" />
</tree>
</field>
</record>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 Tecnativa - Pedro M. Baeza
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record
model="ir.actions.act_window"
id="spreadsheet_dashboard.spreadsheet_dashboard_action_configuration_dashboards"
>
<field name="context">{'active_test': False}</field>
</record>
</odoo>

0 comments on commit 00657f8

Please sign in to comment.