← Back to team overview

openerp-expert-framework team mailing list archive

Re: Module init method

 

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