details:   https://code.tryton.org/tryton/commit/6f7997affa75
branch:    7.0
user:      Cédric Krier <[email protected]>
date:      Mon Oct 05 18:21:13 2026 +0200
description:
        Allow to create any action from the UI

        The action field must not be used to create the main action and the 
inherited
        fields from the parent action must not be set a second time.

        Closes #15149
        (grafted from 08c5c82cd1e2cb19a8877b706803dd03481863eb)
diffstat:

 trytond/trytond/ir/action.py |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 8714d10f4fad -r 6f7997affa75 trytond/trytond/ir/action.py
--- a/trytond/trytond/ir/action.py      Tue Oct 06 13:12:24 2026 +0200
+++ b/trytond/trytond/ir/action.py      Mon Oct 05 18:21:13 2026 +0200
@@ -319,7 +319,11 @@
 
     action = fields.Many2One(
         'ir.action', "Action",
-        required=True, readonly=True, ondelete='CASCADE')
+        required=True, ondelete='CASCADE',
+        states={
+            'required': Eval('id', -1) >= 0,
+            'readonly': Eval('id', -1) >= 0,
+            })
 
     @classmethod
     def __setup__(cls):
@@ -399,8 +403,9 @@
             values = values.copy()
             for field in values:
                 if field in Action._fields:
-                    action_values[field] = values[field]
-                if hasattr(getattr(cls, field), 'set'):
+                    if field != 'action':
+                        action_values[field] = values[field]
+                elif hasattr(getattr(cls, field), 'set'):
                     later[field] = values[field]
             for field in later:
                 del values[field]
@@ -411,7 +416,7 @@
             if database.nextid(transaction.connection, cls._table):
                 database.setnextid(transaction.connection, cls._table,
                     database.currid(transaction.connection, Action._table))
-            if 'action' not in values:
+            if not values.get('action'):
                 action, = Action.create([action_values])
                 values['action'] = action.id
             else:

Reply via email to