return new browse_null() instance if the select argument is False in BaseModel:browse()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Confirmed
|
Medium
|
OpenERP's Framework R&D |
Bug Description
BaseModel:browse() should check if the select argument is False and return browse_null int that case.
The current implementation does check if the argument is an int or long or a list and returns either a browse_record or a list of browse_record or browse_null as fallback.
In Python True and False are instances of bool which is an subclass of int in python 2.
In an on_change_handler if we get the id of an many2one-field (e.g. parent_id) the value is False if the field is not set. Giving this to self.pool.
We could check each and every time the value of the id before passing to browse but it might be easier to to this in browse().
[code]
partner = self.browse(cr, uid, parent_id)
if partner: # browse_
do_something()
[/code]
instead of
[code]
if parent_id is not False:
partner = self.browse(cr, uid, parent_id)
do_something()
[/code]
Related branches
Changed in openobject-server: | |
assignee: | nobody → OpenERP's Framework R&D (openerp-dev-framework) |
importance: | Undecided → Medium |
status: | New → Confirmed |