Merge lp:~unifield-team/unifield-server/fix_osv_memory_fields_function_multi into lp:unifield-server

Proposed by Quentin THEURET @Amaris
Status: Merged
Merged at revision: 3374
Proposed branch: lp:~unifield-team/unifield-server/fix_osv_memory_fields_function_multi
Merge into: lp:unifield-server
Diff against target: 37 lines (+27/-0)
1 file modified
bin/osv/orm.py (+27/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/fix_osv_memory_fields_function_multi
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+72047@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/osv/orm.py'
2--- bin/osv/orm.py 2011-07-26 16:02:06 +0000
3+++ bin/osv/orm.py 2011-08-18 14:51:36 +0000
4@@ -1967,6 +1967,33 @@
5 res2 = self._columns[f].get_memory(cr, self, ids, f, user, context=context, values=result)
6 for record in result:
7 record[f] = res2[record['id']]
8+
9+ # all non inherited fields for which the attribute whose name is in load is False
10+ fields_post = filter(lambda x: x in self._columns and not getattr(self._columns[x], load), fields_to_read)
11+
12+ # Compute POST fields
13+ todo = {}
14+ for f in fields_post:
15+ todo.setdefault(self._columns[f]._multi, [])
16+ todo[self._columns[f]._multi].append(f)
17+ for key, val in todo.items():
18+ if key:
19+ res2 = self._columns[val[0]].get_memory(cr, self, ids, val, user, context=context, values=result)
20+ for pos in val:
21+ for record in result:
22+ if isinstance(res2[record['id']], str): res2[record['id']] = eval(res2[record['id']]) #TOCHECK : why got string instend of dict in python2.6
23+ multi_fields = res2.get(record['id'],{})
24+ if multi_fields:
25+ record[pos] = multi_fields.get(pos,[])
26+ else:
27+ for f in val:
28+ res2 = self._columns[f].get_memory(cr, self, ids, f, user, context=context, values=result)
29+ for record in result:
30+ if res2:
31+ record[f] = res2[record['id']]
32+ else:
33+ record[f] = []
34+
35 if isinstance(ids_orig, (int, long)):
36 return result[0]
37 return result

Subscribers

People subscribed via source and target branches

to all changes: