changeset 3f473b25b5d5 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=3f473b25b5d5
description:
        Update button_action with returned values

        issue8766
        review268241002
diffstat:

 tryton/action/main.py       |  20 +++++++++-----------
 tryton/common/popup_menu.py |   2 +-
 tryton/gui/window/form.py   |   2 +-
 tryton/gui/window/wizard.py |   2 +-
 4 files changed, 12 insertions(+), 14 deletions(-)

diffs (79 lines):

diff -r 0b026afcba63 -r 3f473b25b5d5 tryton/action/main.py
--- a/tryton/action/main.py     Thu Dec 05 21:43:59 2019 +0100
+++ b/tryton/action/main.py     Sat Dec 07 16:03:36 2019 +0100
@@ -48,22 +48,20 @@
         return True
 
     @staticmethod
-    def execute(act_id, data, action_type=None, context=None, keyword=False):
-        # Must be executed synchronously to avoid double execution
-        # on double click.
-        if not action_type:
-            action, = RPCExecute('model', 'ir.action', 'read', [act_id],
-                ['type'], context=context)
-            action_type = action['type']
-        action, = RPCExecute('model', action_type, 'fetch_action', act_id,
-            context=context)
+    def execute(action, data, context=None, keyword=False):
+        if isinstance(action, int):
+            # Must be executed synchronously to avoid double execution
+            # on double click.
+            action = RPCExecute(
+                'model', 'ir.action', 'get_action_value', action,
+                context=context)
         if keyword:
             keywords = {
                 'ir.action.report': 'form_report',
                 'ir.action.wizard': 'form_action',
                 'ir.action.act_window': 'form_relate',
                 }
-            action.setdefault('keyword', keywords.get(action_type, ''))
+            action.setdefault('keyword', keywords.get(action['type'], ''))
         Action._exec_action(action, data, context=context)
 
     @staticmethod
@@ -191,7 +189,7 @@
         res = selection(_('Select your action'), keyact, alwaysask=alwaysask)
         if res:
             (name, action) = res
-            Action._exec_action(action, data, context=context)
+            Action.execute(action, data, context=context)
             return (name, action)
         elif not len(keyact) and warning:
             message(_('No action defined.'))
diff -r 0b026afcba63 -r 3f473b25b5d5 tryton/common/popup_menu.py
--- a/tryton/common/popup_menu.py       Thu Dec 05 21:43:59 2019 +0100
+++ b/tryton/common/popup_menu.py       Sat Dec 07 16:03:36 2019 +0100
@@ -53,7 +53,7 @@
                 or event.state & Gdk.ModifierType.MOD1_MASK):
             allow_similar = True
         with Window(hide_current=True, allow_similar=allow_similar):
-            Action._exec_action(action, data, rec.get_context())
+            Action.execute(action, data, context=rec.get_context())
 
     def attachment(menuitem):
         Attachment(load(record), None)
diff -r 0b026afcba63 -r 3f473b25b5d5 tryton/gui/window/form.py
--- a/tryton/gui/window/form.py Thu Dec 05 21:43:59 2019 +0100
+++ b/tryton/gui/window/form.py Sat Dec 07 16:03:36 2019 +0100
@@ -549,7 +549,7 @@
             'id': record_id,
             'ids': record_ids,
         }
-        Action._exec_action(action, data, self.screen.local_context)
+        Action.execute(action, data, context=self.screen.local_context)
 
     def activate_save(self):
         self.buttons['save'].props.sensitive = self.screen.modified()
diff -r 0b026afcba63 -r 3f473b25b5d5 tryton/gui/window/wizard.py
--- a/tryton/gui/window/wizard.py       Thu Dec 05 21:43:59 2019 +0100
+++ b/tryton/gui/window/wizard.py       Sat Dec 07 16:03:36 2019 +0100
@@ -130,7 +130,7 @@
                     del context['active_ids']
                     del context['active_model']
                     del context['action_id']
-                    Action._exec_action(*action, context=context)
+                    Action.execute(*action, context=context)
 
             if self.state == self.end_state:
                 self.end(lambda *a: execute_actions())

Reply via email to