diff --git a/spreadsheet_dashboard_oca/__manifest__.py b/spreadsheet_dashboard_oca/__manifest__.py index 18f3e49..3440425 100644 --- a/spreadsheet_dashboard_oca/__manifest__.py +++ b/spreadsheet_dashboard_oca/__manifest__.py @@ -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", ], diff --git a/spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py b/spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py index dc0c66f..8752405 100644 --- a/spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py +++ b/spreadsheet_dashboard_oca/models/spreadsheet_dashboard.py @@ -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): @@ -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 diff --git a/spreadsheet_dashboard_oca/static/description/index.html b/spreadsheet_dashboard_oca/static/description/index.html index 6c13472..9da7bca 100644 --- a/spreadsheet_dashboard_oca/static/description/index.html +++ b/spreadsheet_dashboard_oca/static/description/index.html @@ -1,4 +1,3 @@ - diff --git a/spreadsheet_dashboard_oca/views/spreadsheet_dashboard.xml b/spreadsheet_dashboard_oca/views/spreadsheet_dashboard.xml index 683c931..d952792 100644 --- a/spreadsheet_dashboard_oca/views/spreadsheet_dashboard.xml +++ b/spreadsheet_dashboard_oca/views/spreadsheet_dashboard.xml @@ -15,21 +15,42 @@ 1 + not active + +