openerp-expert-framework team mailing list archive
-
openerp-expert-framework team
-
Mailing list archive
-
Message #00555
Re: _inherits and new objets
On Tuesday 02 August 2011, Thibaut DIRLIK wrote:
> Hi everybody,
>
> I would like to talk of _inheritS. Currently, I would like to know what's
> the best way to "propose" to the user, in the creation form, if he wants to
> create a new "parent" automatically, or use an existing one.
>
> Example :
>
> Imagine an fake.address object which inheritS of res.partner.address. When
> you create a new fake.address object, you could pick one existing
> res.partner.address or automatically create a new one. All this must be
> done from the same form view.
>
> What do you think?
>
Well, MHO is a bit radical on that:
I see the "_inherits" feature as an OO equivalent of subclasses to a base
class (and their objects, respectively). That's where its true value, IMHO
always, would show up.
In the OO paradigm, you only create an object once, with the right class that
will follow it forever. You never 'migrate' an object from a baseclass to a
different subclass instance. But you would be allowed to copy the base "simple"
one to a more elaborate subclass.
I think that the "_inherits" feature is under-documented and much under-used,
so far. Its clear purpose and API implementation live in a greyish area, yet
to be defined better.
Or, else, you could think of your 'fake.address' class just having a many2one
to a 'res.partner.address' (and perhaps use a few related fields to make the
res.partner.address data appear directly in fake.address) . What would be the
difference between that and an "_inherits" implementation?
Note: I'm currently using the 'virtual' feature, which makes good use of the
"_inherits" API and lets my modules have real OO structure/behaviour. So far,
this is the best exploit for the under-used "_inherits", but also sets a more
specific set of rules about the "_inherits" usage.
OO = Object Oriented
--
Say NO to spam and viruses. Stop using Microsoft Windows!
Follow ups
References