changeset 36ce819e336a in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=36ce819e336a
description:
        Make action window on singleton load the unique id

        issue1505
        review361611003
diffstat:

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

diffs (36 lines):

diff -r 75d7473e8dd6 -r 36ce819e336a trytond/ir/action.py
--- a/trytond/ir/action.py      Mon Apr 12 20:15:13 2021 +0200
+++ b/trytond/ir/action.py      Mon Apr 12 20:16:41 2021 +0200
@@ -12,7 +12,7 @@
 from trytond.i18n import gettext
 from trytond.model import (
     ModelView, ModelStorage, ModelSQL, DeactivableMixin, fields,
-    sequence_ordered)
+    sequence_ordered, ModelSingleton)
 from trytond.model.exceptions import ValidationError
 from trytond.pool import Pool
 from trytond.pyson import PYSONDecoder, PYSON, Eval
@@ -109,7 +109,8 @@
 
     @classmethod
     def get_action_values(cls, type_, action_ids, columns=None):
-        Action = Pool().get(type_)
+        pool = Pool()
+        Action = pool.get(type_)
         if columns is None:
             columns = []
         columns += ['id', 'name', 'type', 'records', 'icon.rec_name']
@@ -125,7 +126,12 @@
             columns += ['wiz_name', 'window']
         elif type_ == 'ir.action.url':
             columns += ['url']
-        return Action.read(action_ids, columns)
+        actions = Action.read(action_ids, columns)
+        if type_ == 'ir.action.act_window':
+            for values in actions:
+                if issubclass(pool.get(values['res_model']), ModelSingleton):
+                    values['res_id'] = 1
+        return actions
 
     def get_action_value(self):
         return self.get_action_values(

Reply via email to