openerp-expert-framework team mailing list archive
-
openerp-expert-framework team
-
Mailing list archive
-
Message #00339
Re: fields.selection - inherit problem
On Saturday 26 June 2010, Ferdinand Gassauer wrote:
> the following scenario creates problems
>
> module (A)
> (A): 'state': fields.selection([('draft','Draft'),('done','Done')],
> (B): 'state': fields.selection([('draft','Draft'),('running','Running'),
> ('done','Done')],
> (C): 'state': fields.selection([('draft','Draft'),('invalid','Invalid'),
> ('done','Done')],
> IMHO OpenERP should provide a solution to allow inheriting selection
> fields.
You are true. the B and C lines will just try to /replace/ the A line, so at
the end you will only have one of B or C, depending on the module loading
order.
In general, a solution would be to use a class variable for the selection
list, that would be appended with each extra state that some module wants to
add to the selection. Or even use a function, that would dynamically make up
the selection.
Note that I do NOT know the exact solution at the moment. But it is a general
issue that I would like to improve on. You see, the OpenERP orm uses a
"simulated inheritance" concept, where classes do dynamically attach to their
inherit parent and get their contents (columns, defaults, functions) merged to
them. And that is a much different approach than inheritance in OO languages,
like the one we were used to in C++.
I will need to perform some tests and get back to you..
Follow ups