diff options
| author | Olivier Dony <odo@openerp.com> | 2011-02-01 12:24:47 +0100 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2011-02-01 12:24:47 +0100 |
| commit | 3ec7a4b2d9180216fcb16019834bd6d4737a31d5 (patch) | |
| tree | 89ba504100cbb5124214f819e7820cb3d87fe178 | |
| parent | 488efd39d90eec8beeb3447608e1cb1641773721 (diff) | |
[FIX] many2one: return (id,name) instead of only id also for osv_memory
By doing this small change we save clients the trouble of explicitly having to call
name_get() for each m2o field in osv_memory objects, which they cannot trivially batch
and represents a large dealy for wizards with possibly large numbers of child o2m records.
An example is the linked bug, where partial picking of several hundred move lines would
lead to as many separate name_get RPC calls, causing a noticeable delay.
lp bug: https://launchpad.net/bugs/709567 fixed
bzr revid: odo@openerp.com-20110201112447-i00sn3ih6qgj3wlh
| -rw-r--r-- | bin/osv/fields.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bin/osv/fields.py b/bin/osv/fields.py index 72df0e925ad..b7874cda8e6 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -339,6 +339,20 @@ class many2one(_column): result = {} for id in ids: result[id] = obj.datas[id].get(name, False) + + # build a dictionary of the form {'id_of_distant_resource': name_of_distant_resource} + # we use uid=1 because the visibility of a many2one field value (just id and name) + # must be the access right of the parent form and not the linked object itself. + obj = obj.pool.get(self._obj) + records = dict(obj.name_get(cr, 1, + list(set([x for x in result.values() if x and isinstance(x, (int,long))])), + context=context)) + for id in ids: + if result[id] in records: + result[id] = (result[id], records[result[id]]) + else: + result[id] = False + return result def get(self, cr, obj, ids, name, user=None, context=None, values=None): |
