Browse on one2many_v_id_xxx in onchange fails
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Web (MOVED TO GITHUB) |
New
|
Undecided
|
OpenERP Publisher's Warranty Team |
Bug Description
I attached a demo module showing the error.
Content of the module:
The demo module is a drastically simplified version from what we're using. It changes the kanban view of subcontacts in a res.partner form to a tree. It also makes these subcontacts visible all the time (even for non-companies).
The result of this change is that you can define a deeper hierarchy: contacts can be linked to other contacts, which can be linked to other contacts, and so on. Thus, when creating a contact, you can immediately add subcontacts, which can have other subcontacts, ...
To reproduce:
1) Install the attached module
2) Start creating a new contact, let's call him 'Root contact'. (Don't save!)
3) Now, under the tab 'Contacts', click on 'Add an item', this opens another contact form.
4) Enter 'Sub contact' as a name, and click 'Save & Close'. (Don't save the 'Root contact' yet!)
5) Now from the 'Root contact' form, open the 'Sub contact' form again.
6) On the 'Sub contact' form, under the tab 'Contacts', click on 'Add an item'.
This results in the following error:
...
File "C:\...
result['value'] = dict((key, value_or_
File "C:\...
result['value'] = dict((key, value_or_
File "C:\...
return val if isinstance(val, (bool, int, long, float, basestring)) else val.id
AttributeError: 'NoneType' object has no attribute 'id'
As far as I can see, the following is happening:
1) When clicking 'Save & Close' to save the 'Sub Contact' (step 4), the active_id / id of the 'Sub Contact' is saved as 'one2many_v_id_xxx' on the client-side.
2) After re-opening the 'Sub Contact' and clicking on 'Add an item' (step 6), the form that opens is prefilled with some values, defined in the context of the field "child_ids" from the 'Sub Contact'. One of these values is "'parent_id': active_id". As I pointed out in the previous point, this active_id is at this point 'one2many_
3) When prefilling the 'parent_id' value in the form, the onchange method of that field is called, which is onchange_address.
4) In the onchange method, a self.browse() is called on the parent_id. Since it's not a real id but a virtual id, this returns None. Thus, when trying to get one of the fields of the parent (from the browse object), the above exception is thrown, since obviously, the None object doesn't have the attributes we want.
OpenERP version used: 7.0-20130526-231028
Changed in openobject-addons: | |
assignee: | nobody → OpenERP Publisher's Warranty Team (openerp-opw) |
tags: | added: maintenance |
affects: | openobject-addons → openerp-web |