From 9557984b3fe012d35923d418f64c9977c4a2bc26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 15 Mar 2025 15:47:29 +0100 Subject: [PATCH] Set readonly Screen of One2Many when parent group is readonly The user must not be allowed to modify records of a One2Many if the parent record can not be saved. Closes #13923 --- sao/src/screen.js | 1 + sao/src/view/form.js | 1 + tryton/tryton/gui/window/view_form/screen/screen.py | 1 + tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py | 1 + 4 files changed, 4 insertions(+) diff --git a/sao/src/screen.js b/sao/src/screen.js index 50ce97279e..c9d3bc87d1 100644 --- a/sao/src/screen.js +++ b/sao/src/screen.js @@ -1249,6 +1249,7 @@ } } this.group.exclude_field = this.exclude_field; + this.group.readonly = this.__readonly; }, new_group: function(context) { if (!context) { diff --git a/sao/src/view/form.js b/sao/src/view/form.js index 409488a855..892df05589 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -3442,6 +3442,7 @@ function eval_pyson(value){ order: attributes.order, row_activate: this.activate.bind(this), exclude_field: attributes.relation_field || null, + readonly: this.view.screen.group.readonly, limit: null, context: this.view.screen.context, pre_validate: attributes.pre_validate, diff --git a/tryton/tryton/gui/window/view_form/screen/screen.py b/tryton/tryton/gui/window/view_form/screen/screen.py index 464fc83aed..5d6429b159 100644 --- a/tryton/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/tryton/gui/window/view_form/screen/screen.py @@ -429,6 +429,7 @@ class Screen: for name, views in fields_views.items(): self.__group.fields[name].views.update(views) self.__group.exclude_field = self.exclude_field + self.__group.readonly = self.__readonly group = property(__get_group, __set_group) diff --git a/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py b/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py index ef6a4098ba..64ddf70d24 100644 --- a/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py +++ b/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py @@ -166,6 +166,7 @@ class One2Many(Widget): order=attrs.get('order'), row_activate=self._on_activate, exclude_field=attrs.get('relation_field', None), + readonly=self.view.screen.group.readonly, limit=None, context=self.view.screen.context, breadcrumb=breadcrumb)