changeset fbc3437a2dbe in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=fbc3437a2dbe
description:
        Decode board action the same way as window action

        The evaluation code should be the same to ensure same behavior.

        issue9275
        review303761007
diffstat:

 tryton/gui/window/view_board/action.py |  59 ++++++++++++++++++++-------------
 1 files changed, 36 insertions(+), 23 deletions(-)

diffs (108 lines):

diff -r 57e0e3a871c1 -r fbc3437a2dbe tryton/gui/window/view_board/action.py
--- a/tryton/gui/window/view_board/action.py    Fri Jun 19 00:18:04 2020 +0200
+++ b/tryton/gui/window/view_board/action.py    Fri Jun 19 00:20:27 2020 +0200
@@ -8,6 +8,7 @@
 from tryton.gui.window.view_form.screen import Screen
 import tryton.rpc as rpc
 import tryton.common as common
+from tryton.config import CONFIG
 from tryton.pyson import PYSONDecoder
 from tryton.signal_event import SignalEvent
 from tryton.gui.window.win_form import WinForm
@@ -23,7 +24,6 @@
             context = {}
         super(Action, self).__init__()
         self.name = attrs['name']
-        self.context = context.copy()
 
         try:
             self.action = RPCExecute('model', 'ir.action.act_window', 'get',
@@ -32,35 +32,40 @@
             raise
 
         view_ids = []
-        self.action['view_mode'] = None
+        view_mode = None
         if self.action.get('views', []):
             view_ids = [x[0] for x in self.action['views']]
-            self.action['view_mode'] = [x[1] for x in self.action['views']]
+            view_mode = [x[1] for x in self.action['views']]
         elif self.action.get('view_id', False):
             view_ids = [self.action['view_id'][0]]
 
-        if 'view_mode' in attrs:
-            self.action['view_mode'] = attrs['view_mode']
+        self.action.setdefault('pyson_domain', '[]')
+        ctx = {}
+        ctx.update(rpc.CONTEXT)
+        ctx['_user'] = rpc._USER
+        decoder = PYSONDecoder(ctx)
+        action_ctx = context.copy()
+        action_ctx.update(
+            decoder.decode(self.action.get('pyson_context') or '{}'))
+        ctx.update(action_ctx)
 
-        self.action.setdefault('pyson_domain', '[]')
-        self.context.update(rpc.CONTEXT)
-        self.context['_user'] = rpc._USER
-        self.context.update(PYSONDecoder(self.context).decode(
-            self.action.get('pyson_context', '{}')))
+        ctx['context'] = ctx
+        decoder = PYSONDecoder(ctx)
+        self.domain = decoder.decode(self.action['pyson_domain'])
+        order = decoder.decode(self.action['pyson_order'])
+        search_value = decoder.decode(
+            self.action['pyson_search_value'] or '[]')
+        tab_domain = [(n, decoder.decode(d), c)
+            for n, d, c in self.action['domains']]
 
-        eval_ctx = self.context.copy()
-        self.context.update(PYSONDecoder(eval_ctx).decode(
-            self.action.get('pyson_context', '{}')))
+        limit = self.action.get('limit')
+        if limit is None:
+            limit = CONFIG['client.limit']
 
+        self.context = ctx
         self.domain = []
         self.update_domain([])
 
-        search_context = self.context.copy()
-        search_context['context'] = self.context
-        search_context['_user'] = rpc._USER
-        search_value = PYSONDecoder(search_context).decode(
-            self.action['pyson_search_value'] or '[]')
-
         self.widget = Gtk.Frame()
         self.widget.set_border_width(0)
 
@@ -73,9 +78,17 @@
         self.widget.show_all()
 
         self.screen = Screen(self.action['res_model'],
-            mode=self.action['view_mode'], context=self.context,
-            view_ids=view_ids, domain=self.domain,
-            search_value=search_value, row_activate=self.row_activate)
+            view_ids=view_ids,
+            domain=self.domain,
+            context=action_ctx,
+            order=order,
+            mode=view_mode,
+            limit=limit,
+            search_value=search_value,
+            tab_domain=tab_domain,
+            context_model=self.action['context_model'],
+            context_domain=self.action['context_domain'],
+            row_activate=self.row_activate)
         vbox.pack_start(
             self.screen.widget, expand=True, fill=True, padding=0)
         self.screen.signal_connect(self, 'record-message',
@@ -111,7 +124,7 @@
                     self.screen.current_record.save()
                 else:
                     self.screen.current_record.cancel()
-            WinForm(self.screen, callback)
+            WinForm(self.screen, callback, title=self.title.get_text())
 
     def set_value(self, mode, model_field):
         self.screen.current_view.set_value()

Reply via email to