openerp-expert-framework team mailing list archive
-
openerp-expert-framework team
-
Mailing list archive
-
Message #00861
Re: Module init method
-
To:
openerp-expert-framework@xxxxxxxxxxxxxxxxxxx
-
From:
Stefan Rijnhart <stefan@xxxxxxxx>
-
Date:
Thu, 14 Jun 2012 12:05:43 +0200
-
In-reply-to:
<CAJ=p=Oj=_1c1py1P2y963XOma1EBtXWFJAL+coWsSAh7x_8D6A@mail.gmail.com>
-
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1
On 06/14/2012 10:42 AM, Thibaut DIRLIK wrote:
Good morning everyone,
I've got a simple question here, is there a way to execute some code
when "initializing" a module.
I mean, I can put some code in the .py file, but I don't have access
to any cursor. Unless there is a way to get the cursor ?
Is there a way to define for example an init method which would be
called when module is loaded,
in which we could use the pool and a cursor ?
Hi Thibaut,
You can override the __init__() method of your model, which gets called
at module load time.
class res_partner(osv.osv):
_inherit = 'res.partner'
def __init__(self, pool, cr):
res = super(res_partner, self).__init__(pool, cr)
# put funky stuff here
return res
Btw. if I understand correctly, this mailing list is more for discussing
API changes etc., not for development questions. Maybe you could use
Launchpad Answers next time?
Cheers,
Stefan.
--
Therp - Maatwerk in open ontwikkeling
Stefan Rijnhart - Ontwerp en implementatie
mail: stefan@xxxxxxxx
tel: +31 (0) 614478606
http://therp.nl
https://twitter.com/therp_stefan
References