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)

--HG--
branch : 8.0
This commit is contained in:
Cédric Krier committed 2026-10-05 18:21:13 +02:00
1 parent ca1a608c13
commit fa125204a7
1 file changed
+9 -4
+9 -4
View File
@@ -345,7 +345,11 @@ class ActionMixin(ModelSQL):
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):
@@ -456,8 +460,9 @@ class ActionMixin(ModelSQL):
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]
@@ -468,7 +473,7 @@ class ActionMixin(ModelSQL):
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: