diff --git a/tryton/gui/window/view_form/model/record.py b/tryton/gui/window/view_form/model/record.py index 70db9d3f20..a69076d9e6 100644 --- a/tryton/gui/window/view_form/model/record.py +++ b/tryton/gui/window/view_form/model/record.py @@ -91,6 +91,8 @@ class Record(SignalEvent): fnames.extend(('%s.rec_name' % fname for fname in fnames[:] if self.group.fields[fname].attrs['type'] in ('many2one', 'one2one', 'reference'))) + if 'rec_name' not in fnames: + fnames.append('rec_name') fnames.append('_timestamp') ctx = rpc.CONTEXT.copy() ctx.update(record_context) @@ -428,6 +430,8 @@ class Record(SignalEvent): self._timestamp = value continue if fieldname not in self.group.fields: + if fieldname == 'rec_name': + self.value['rec_name'] = value continue if isinstance(self.group.fields[fieldname], fields.O2MField): later[fieldname] = value diff --git a/tryton/gui/window/view_form/view/form_gtk/many2many.py b/tryton/gui/window/view_form/view/form_gtk/many2many.py index b26edfecc9..537cb18e98 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2many.py @@ -140,10 +140,10 @@ class Many2Many(WidgetInterface): self.focus_out = True return False - def callback(ids): + def callback(result): res_id = None - if ids: - res_id = ids[0] + if result: + res_id, _ = result[0] self.focus_out = True self.screen.load(ids, modified=True) self.screen.display(res_id=res_id) @@ -155,7 +155,7 @@ class Many2Many(WidgetInterface): view_ids=self.attrs.get('view_ids', '').split(','), views_preload=self.attrs.get('views', {})) else: - callback(ids) + callback([(i, None) for i in ids]) def _sig_remove(self, *args): self.screen.remove(remove=True) diff --git a/tryton/gui/window/view_form/view/form_gtk/many2one.py b/tryton/gui/window/view_form/view/form_gtk/many2one.py index ffb7f4d790..0a6ee2378b 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2one.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py @@ -150,10 +150,10 @@ class Many2One(WidgetInterface): self.changed = True return - def callback(ids): - if ids: + def callback(result): + if result: self.field.set_client(self.record, - self.value_from_id(ids[0]), force_change=True) + self.value_from_id(*result[0]), force_change=True) self.focus_out = True self.display(self.record, self.field) self.changed = True @@ -241,10 +241,10 @@ class Many2One(WidgetInterface): self.display(self.record, self.field) return True - def callback(ids): - if ids: + def callback(result): + if result: self.field.set_client(self.record, - self.value_from_id(ids[0]), force_change=True) + self.value_from_id(*result[0]), force_change=True) self.focus_out = True self.display(self.record, self.field) self.changed = True diff --git a/tryton/gui/window/view_form/view/form_gtk/one2many.py b/tryton/gui/window/view_form/view/form_gtk/one2many.py index 0454fed857..06b60f63ce 100644 --- a/tryton/gui/window/view_form/view/form_gtk/one2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py @@ -322,10 +322,10 @@ class One2Many(WidgetInterface): common.process_exception(exception) return False - def callback(ids): + def callback(result): res_id = None - if ids: - res_id = ids[0] + if result: + res_id, = result[0] self.screen.load(ids, modified=True) self.screen.display(res_id=res_id) self.screen.set_cursor() @@ -336,7 +336,7 @@ class One2Many(WidgetInterface): view_ids=self.attrs.get('view_ids', '').split(','), views_preload=self.attrs.get('views', {})) else: - callback(ids) + callback([(i, None) for i in ids]) def _sig_label(self, screen, signal_data): name = '_' diff --git a/tryton/gui/window/view_form/view/list_gtk/parser.py b/tryton/gui/window/view_form/view/list_gtk/parser.py index 454f900418..e7ffb76bd6 100644 --- a/tryton/gui/window/view_form/view/list_gtk/parser.py +++ b/tryton/gui/window/view_form/view/list_gtk/parser.py @@ -658,14 +658,7 @@ class M2O(Char): def search_callback(found): value = None if found: - args = ('model', relation, 'read', found[0], ['rec_name'], - context) - try: - res = rpc.execute(*args) - except TrytonServerError, exception: - res = common.process_exception(exception, *args) - if res: - value = (found[0], res['rec_name']) + value = found[0] field.set_client(record, value) if callback: callback() @@ -760,7 +753,11 @@ class M2M(Char): return def winsearch_callback(result): - field.set_client(record, result or []) + if result: + result = [i for i, _ in result] + else: + result = [] + field.set_client(record, result) if callback: callback() WinSearch(relation, winsearch_callback, sel_multi=True, ids=ids, @@ -795,7 +792,7 @@ class M2M(Char): def open_callback(result): if result: - field.set_client(record, result) + field.set_client(record, [i for i, _ in result]) if callback: callback() WinSearch(relation, open_callback, sel_multi=True, ids=ids, diff --git a/tryton/gui/window/win_form.py b/tryton/gui/window/win_form.py index 0b1c23e376..95e85fcbbb 100644 --- a/tryton/gui/window/win_form.py +++ b/tryton/gui/window/win_form.py @@ -270,10 +270,10 @@ class WinForm(NoModal): common.process_exception(exception) return False - def callback(ids): + def callback(result): res_id = None - if ids: - res_id = ids[0] + if result: + res_id, _ = result[0] self.screen.load(ids, modified=True) self.screen.display(res_id=res_id) self.screen.set_cursor() diff --git a/tryton/gui/window/win_search.py b/tryton/gui/window/win_search.py index 1ee69d4830..229a2ac7ee 100644 --- a/tryton/gui/window/win_search.py +++ b/tryton/gui/window/win_search.py @@ -121,10 +121,15 @@ class WinSearch(NoModal): def callback(result): if result and screen.save_current(): - res = [screen.current_record.id] + record = screen.current_record + res = [(record.id, record.value.get('rec_name', ''))] self.destroy() self.callback(res) WinForm(screen, callback, new=True) return + if res: + group = self.screen.group + res = [(id_, group.get(id_).value.get('rec_name', '')) + for id_ in res] self.destroy() return self.callback(res)