Merge lp:~thibaut-dirlik/openobject-server/fix-inherits-bug-303455 into lp:openobject-server
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 3841 | ||||
Proposed branch: | lp:~thibaut-dirlik/openobject-server/fix-inherits-bug-303455 | ||||
Merge into: | lp:openobject-server | ||||
Diff against target: |
12 lines (+1/-1) 1 file modified
openerp/osv/orm.py (+1/-1) |
||||
To merge this branch: | bzr merge lp:~thibaut-dirlik/openobject-server/fix-inherits-bug-303455 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Olivier Dony (Odoo) | (patch review, not tested) | Approve | |
OpenERP Community (OBSOLETE) | review test | Pending | |
Review via email: mp+72914@code.launchpad.net |
Description of the change
The _inherits problem is complicated to solve with the current implementation. Because of the multiple-
When you create a new objects which uses _inherits, OpenERP will fill ONE of its parent field with the value specified in a field. For example,n if "active" = True, OpenERP will create the parent and set active to True for it. But if the object have a "active" field too, it won't be defined.
This small patch make OpenERP sets the value for the current object first, and, if the current object does not have a column, but the parent does, for its parent.
Their are implementation choices to do :
- What do to in case of multiple parents ? Currently, self._inherit_
- Unless this implementation change, it won't be possible to modify all the parent at once.
I wanted to set the value for all parents + the current object, but it's not possible unless we change the current _inherits implementation. So, I just did that.
Thibaut,
Great job with the merge proposal and the explanation!
So in fact the issue was only with create() and not with write(), as I understood previously.
After looking at the patch and reviewing the ORM code, it seems all good for me. The behavior will now be consistent between all operations: read-write-create: all will get/set the field value at the child level and not the parent(s), if the child defines it. This is correct wrt to the semantics of 'inherits'.
And in case the child does not redefine the field but has multiple parents that have it, the one that will be read/written is the first one according to the "natural order" of the _inherit_fields dict. Not a very smart algorithm, but at least it will be consistent across multiple operations, once the server is started and the columns aren't modified - good enough until we change the _inherits implementation.
BTW I have not had time to actually test this patch with a real use case. As this is the ORM code, it would be great if someone could confirm the fix works for them in a real case? (I'm assigning review to community for that purpose)
Thanks a lot!