Always read rec_name and return it in WinSearch
review250002
This commit is contained in:
1 parent
54737c0df0
commit
178d2637d7
7 files changed
+34
-28
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = '_'
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user