From 3042288aa97c15b27c684dfd9949aad5c58f4f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 30 Sep 2026 09:35:55 +0200 Subject: [PATCH] Make type and action fields readonly only after creation The user needs to be allowed to set those fields when creating or copying an action. --- trytond/trytond/ir/action.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/trytond/trytond/ir/action.py b/trytond/trytond/ir/action.py index 6ed796b8f7..7df14f9153 100644 --- a/trytond/trytond/ir/action.py +++ b/trytond/trytond/ir/action.py @@ -54,7 +54,10 @@ class Action(DeactivableMixin, ModelSQL, ModelView): __name__ = 'ir.action' name = fields.Char('Name', required=True, translate=True) type = fields.Selection( - ACTION_SELECTION, "Type", required=True, readonly=True) + ACTION_SELECTION, "Type", required=True, + states={ + 'readonly': Eval('id', -1) >= 0, + }) action = fields.Function( fields.Reference("Action", selection=ACTION_SELECTION), 'get_action') @@ -345,7 +348,10 @@ class ActionMixin(ModelSQL): action = fields.Many2One( 'ir.action', "Action", - required=True, readonly=True, ondelete='CASCADE') + required=True, ondelete='CASCADE', + states={ + 'readonly': Eval('id', -1) >= 0, + }) @classmethod def __setup__(cls):