summaryrefslogtreecommitdiff
path: root/addons/analytic_user_function/analytic_user_function_view.xml
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-10-05 13:24:44 +0200
committerXavier Morel <xmo@openerp.com>2011-10-05 13:24:44 +0200
commit5eeeb67e6dafa2e53a5af520d7a3ae77bfbe3b12 (patch)
treed61e2f569e3629c0afe49d83c48f38824f93f58c /addons/analytic_user_function/analytic_user_function_view.xml
parent072bb3d8ec4de14db4cef6335d0f4c95f83c2a93 (diff)
[IMP] raise error when iterating over browse_record
Python has an iteration fallback protocol: when iterating over an object which does not define __iter__, if the object defines __getitem__ it considers that it's a list, and invokes __getitem__ from index `0`. This can be a problem in openerp in methods which expect an list of ids but are only given a single id (not a singleton list), in that case self.browse() will return a single browse_record (instea of a list) and the method tries to iterate over it by calling browse_record.__getitem__. Problem is that browse_record.__getitem__ is pretty deep and does little validation, so the error appears 3 frames below where the actual issue is with a completely cryptic message of "KeyError: 0", which makes the actual harder to track. By raising an error immediately in browse_record.__iter__, this kind of issues is much easier to handle, the stack points precisely to the frame in error with a clearer message. bzr revid: xmo@openerp.com-20111005112444-jcp9fw6pa36ahpsd
Diffstat (limited to 'addons/analytic_user_function/analytic_user_function_view.xml')
0 files changed, 0 insertions, 0 deletions