From 67f2ae156fa384cfeec21aa44e88e2e4f069f929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 10 Jun 2024 17:17:27 +0200 Subject: [PATCH] Store readonly attribute on Screen with a default value Otherwise the attribute value may be undefined instead of being a boolean. Closes #13324 (grafted from c0feae75063f1daac6b3c8017f165aaca3858922) --HG-- branch : 6.0 --- sao/src/screen.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sao/src/screen.js b/sao/src/screen.js index 9acede54ab..ac94a985a7 100644 --- a/sao/src/screen.js +++ b/sao/src/screen.js @@ -801,9 +801,7 @@ this.views = []; this.views_preload = attributes.views_preload || {}; this.exclude_field = attributes.exclude_field; - this.new_group(attributes.context || {}); this.current_view = null; - this.current_record = null; this.domain = attributes.domain || []; this.context_domain = attributes.context_domain; this.size_limit = null; @@ -814,11 +812,14 @@ } this.offset = 0; this.order = this.default_order = attributes.order; + this.readonly = this.attributes.readonly || false; var access = Sao.common.MODELACCESS.get(model_name); if (!(access.write || access.create)) { - this.attributes.readonly = true; + this.readonly = true; } this.search_count = 0; + this.new_group(attributes.context || {}); + this.current_record = null; this.screen_container = new Sao.ScreenContainer( attributes.tab_domain); this.breadcrumb = attributes.breadcrumb || []; @@ -868,7 +869,10 @@ var readonly_records = this.selected_records.some(function(r) { return r.readonly; }); - return this.attributes.readonly || readonly_records; + return this.__readonly || readonly_records; + }, + set readonly(value) { + this.__readonly = value; }, get deletable() { return this.selected_records.every(function(r) { @@ -1251,7 +1255,7 @@ context = this.context; } var group = new Sao.Group(this.model, context, []); - group.readonly = this.attributes.readonly; + group.readonly = this.__readonly; this.set_group(group); }, get current_record() {