orm: xml field location method for inheritance is flawed
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Confirmed
|
Wishlist
|
OpenERP's Framework R&D |
Bug Description
description:
In orm.py (2074):
def locate(source, spec):
...
elif spec.tag == 'field':
# Only compare the field name: a field can be only once in a given view
# at a given level (and for multilevel expressions, we should use xpath
# inheritance spec anyway).
for node in source.
...
when doing applying inheritance mechanism,
eg. :
Only the first node matching the field name is returned. getiterator() parses the xml depth first, so the first field matching the field name will be the top-most in the file. If you have defined subviews (form,tree on one2many field for example) before the targetted field, and one of their field name matches the searched parent field name, *the replacement will miss its original target* and this will produce unexpected bugs. These are very difficult to trace, especially if subviews came from inheritance mechanism.
Version: OpenERP 7.0 runbot (and probably others)
How to demonstrate this thanks to a direct bug in runbot:
- launch runbot
- in setting>project, check "allow task delegation"
- In task view, sale_order_id should appear after state located in Extra info page
code: (project_
<record id="view_
<field name="name"
<field name="model"
<field name="inherit_id" ref="project.
<field name="arch" type="xml">
</record>
but due to the presence of 2 occurrences of "state" labeled fields in the project.task form, inheritance apply only to the first one, which happens to be the wrong. With chance (or bad luck), this bug won't cause exceptions, because the subview happens to support the addition of "sale_line_id". Nevertheless, this causes a silent bug in the replacement of the field. This is what is shown in the video.
project.
<field name="arch" type="xml">
affects: | openobject-addons → openobject-server |
summary: |
- [7.0] orm: xml field location method for inheritance is flawed + orm: xml field location method for inheritance is flawed |
See this https:/ /bugs.launchpad .net/openobject -addons/ +bug/1097808 to see consequence