_inherits could not write in duplicate fields
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
New
|
Undecided
|
Unassigned |
Bug Description
Hello OpenERP Team !
For one of my modules, i wanted to do a multiple inheritance by Delegation (_inherits). But both of the inherited objects have a field "name" required.
A model to show my issue (custom module names aren't the real ones):
(Edit : i'm working on OpenERP V6.1 with Web Cient)
class my_child(osv.osv):
_inherits = {'product.
_name="my.child"
_columns = {
....
}
my_child()
note : _columns of my_child class has not field "name".
And when creating a new record of my_child, I have an error saying field "name" of product.template is missing.
In fact, I found that in _inherits_reload method of BaseModel class (at lines 3266 to 3274), only the last object containing the field desired will write the value.
This is because a dict is used here ("res" variable), where each fields name is a dict key. So, in my case, when looping to each _inherits occurence, openerp first associate "name" field to product.template, and then, finding custom.module has also a "name" field, it replaces the value contained at "name" dict key with custom.module values.
Moreover, there is another pb : my custom.module has a field named "type", like product.product and this time, their types are different (many2one (integer) for my module and selection(string) for product.product), but here I think i have to use a prefix on my field name to prevent this collision.
To sum'up, is there a possible fix to inherit from objects having duplicate fields ?
Regards,
description: | updated |