Merge lp:~openerp-dev/openobject-server/6.0-bug-745679-xrg into lp:openobject-server/6.0

Proposed by xrg
Status: Rejected
Rejected by: Vo Minh Thu
Proposed branch: lp:~openerp-dev/openobject-server/6.0-bug-745679-xrg
Merge into: lp:openobject-server/6.0
Diff against target: 25 lines (+11/-2)
1 file modified
bin/osv/orm.py (+11/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-bug-745679-xrg
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+55890@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vo Minh Thu (thu) wrote :

Thanks for the patch.

Actually if res2 is None, we should throw a nice exception saying that a particular function field doesn't return the expected result type.

So in the case of the linked bug report, it is really a bug in account.account, not in the orm.

I will reject this patch.

Unmerged revisions

3387. By xrg

ORM: fix function field computation when records are missing

[Bug 745679], reported by: Marco Dieckhoff

When the get() method of some function field fails to return data (in
our case, because active=False prevents search()ing some accounts),
that part of logic for function fields was broken.

Still, we have to decide if missing that data shall be tolerated.

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-03-23 19:20:43 +0000
3+++ bin/osv/orm.py 2011-04-01 09:48:49 +0000
4@@ -3049,10 +3049,19 @@
5 for key, val in todo.items():
6 if key:
7 res2 = self._columns[val[0]].get(cr, self, ids, val, user, context=context, values=res)
8+ if not res2:
9+ logging.getLogger('orm').warning("%s.%s didn't provide us data for %s",
10+ self._name, val[0], get_ids)
11+ res2 = {}
12 for pos in val:
13 for record in res:
14- if isinstance(res2[record['id']], str): res2[record['id']] = eval(res2[record['id']]) #TOCHECK : why got string instend of dict in python2.6
15- multi_fields = res2.get(record['id'],{})
16+ if not (record['id'] in res2):
17+ # Is it right not to have that?
18+ continue
19+ if isinstance(res2[record['id']], str):
20+ res2[record['id']] = eval(res2[record['id']])
21+ #TOCHECK : why got string instend of dict in python2.6
22+ multi_fields = res2[record['id']]
23 if multi_fields:
24 record[pos] = multi_fields.get(pos,[])
25 else: