diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-12-13 14:05:48 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-12-13 14:05:48 +0100 |
| commit | 7acadc00c66bf8166f023b4eec662bf956799faa (patch) | |
| tree | 03b4c313b48ecc5fcd3f03610abe6a53d80052db /addons/web/controllers/main.py | |
| parent | d63781bf5c2bc8b7f3a22817173f238da8af8608 (diff) | |
[FIX] unwarranted assumption that name_get(ids) and read(ids) will return the same records in the same order
There is actually no such guarantee, neither name_get nor read
guarantee they'll return records in input order, let alone in the same
order as one another, and both are free to skip records as they see
fit (kinda).
=> convert the name_get result to a dict, and then fill in the
display_name for each record returned by read() using get()
bzr revid: xmo@openerp.com-20121213130548-x1h6czyru5nc6wwm
Diffstat (limited to 'addons/web/controllers/main.py')
| -rw-r--r-- | addons/web/controllers/main.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index fe23e99a5a1..d4fe2d79acc 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1059,14 +1059,15 @@ class DataSet(openerpweb.Controller): def _call_kw(self, req, model, method, args, kwargs): # Temporary implements future display_name special field for model#read() - if method == 'read' and kwargs.get('context') and kwargs['context'].get('future_display_name'): + if method == 'read' and kwargs.get('context', {}).get('future_display_name'): if 'display_name' in args[1]: - names = req.session.model(model).name_get(args[0], **kwargs) + names = dict(req.session.model(model).name_get(args[0], **kwargs)) args[1].remove('display_name') - r = getattr(req.session.model(model), method)(*args, **kwargs) - for i in range(len(r)): - r[i]['display_name'] = names[i][1] or "%s#%d" % (model, names[i][0]) - return r + records = req.session.model(model).read(*args, **kwargs) + for record in records: + record['display_name'] = \ + names.get(record['id']) or "%s#%d" % (model, (record['id'])) + return records return getattr(req.session.model(model), method)(*args, **kwargs) |
