From 86e5fdbfb4728ee2d0a51917c7ec42fac4ba7097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 4 Mar 2013 22:21:52 +0100 Subject: [PATCH] Disable main iteration for all RPC request from model/ We can not know if the request is fired during the process of a GTK event. review686002 (transplanted from db672c4e45901a05ce23a669648daa25794c3e9b) --- tryton/gui/window/view_form/model/group.py | 4 +-- tryton/gui/window/view_form/model/record.py | 27 +++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/tryton/gui/window/view_form/model/group.py b/tryton/gui/window/view_form/model/group.py index 089882af9b..ab0a8b06a1 100644 --- a/tryton/gui/window/view_form/model/group.py +++ b/tryton/gui/window/view_form/model/group.py @@ -187,7 +187,7 @@ class Group(SignalEvent, list): for fnct in self.on_write: try: res += RPCExecute('model', self.model_name, fnct, ids, - context=self.context) + main_iteration=False, context=self.context) except RPCException: return [] return list({}.fromkeys(res)) @@ -376,7 +376,7 @@ class Group(SignalEvent, list): ctx.update(self.context) try: values = RPCExecute('model', self.model_name, 'default_get', - to_add.keys(), context=ctx) + to_add.keys(), main_iteration=False, context=ctx) except RPCException: return False for name in to_add: diff --git a/tryton/gui/window/view_form/model/record.py b/tryton/gui/window/view_form/model/record.py index 95e033a80a..0ab86cd8d6 100644 --- a/tryton/gui/window/view_form/model/record.py +++ b/tryton/gui/window/view_form/model/record.py @@ -281,6 +281,7 @@ class Record(SignalEvent): value = self.get(get_readonly=True) try: res = RPCExecute('model', self.model_name, 'create', value, + main_iteration=False, context=self.context_get()) except RPCException: return False @@ -297,7 +298,8 @@ class Record(SignalEvent): context['_timestamp'] = self.get_timestamp() try: if not RPCExecute('model', self.model_name, 'write', - [self.id], value, context=context): + [self.id], value, main_iteration=False, + context=context): return False except RPCException: return False @@ -332,7 +334,7 @@ class Record(SignalEvent): reload_ids = list(reload_ids) try: RPCExecute('model', record.model_name, 'delete', list(record_ids), - context=ctx) + main_iteration=False, context=ctx) except RPCException: return False if reload_ids: @@ -343,7 +345,8 @@ class Record(SignalEvent): if len(self.group.fields): try: vals = RPCExecute('model', self.model_name, 'default_get', - self.group.fields.keys(), context=context) + self.group.fields.keys(), main_iteration=False, + context=context) except RPCException: return if (self.parent @@ -360,7 +363,8 @@ class Record(SignalEvent): def rec_name(self): try: return RPCExecute('model', self.model_name, 'read', self.id, - ['rec_name'], context=self.context_get())['rec_name'] + ['rec_name'], main_iteration=False, + context=self.context_get())['rec_name'] except RPCException: return '' @@ -490,8 +494,9 @@ class Record(SignalEvent): attr = PYSONDecoder().decode(attr) args = self._get_on_change_args(attr) try: - res = RPCExecute('model', self.model_name, - 'on_change_' + fieldname, args, context=self.context_get()) + res = RPCExecute('model', self.model_name, 'on_change_' + + fieldname, args, main_iteration=False, + context=self.context_get()) except RPCException: return later = {} @@ -544,7 +549,8 @@ class Record(SignalEvent): if fieldnames: try: result = RPCExecute('model', self.model_name, 'on_change_with', - list(fieldnames), values, context=self.context_get()) + list(fieldnames), values, main_iteration=False, + context=self.context_get()) except RPCException: return for fieldname, value in result.items(): @@ -556,7 +562,7 @@ class Record(SignalEvent): try: result = RPCExecute('model', self.model_name, 'on_change_with_' + fieldname, values, - context=self.context_get()) + main_iteration=False, context=self.context_get()) except RPCException: return self.group.fields[fieldname].set_on_change(self, result) @@ -574,7 +580,8 @@ class Record(SignalEvent): args = self._get_on_change_args(autocomplete) try: res = RPCExecute('model', self.model_name, 'autocomplete_' + - fieldname, args, context=self.context_get()) + fieldname, args, main_iteration=False, + context=self.context_get()) except RPCException: # ensure res is a list res = [] @@ -589,7 +596,7 @@ class Record(SignalEvent): 'search_count', [ ('resource', '=', '%s,%s' % (self.model_name, self.id)), - ]) + ], main_iteration=False) except RPCException: return 0 return self.attachment_count