Module Question

Asked by Mederic Roy F. Beldia

Hi,

I'm creating a module, I want to initialize the object after installation but I don't want to use installer. I wanted to insert a record in the module after installation. Can anybody give a hint on how to do this?

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Mederic Roy F. Beldia
Solved:
Last query:
Last reply:
Revision history for this message
Numérigraphe (numerigraphe) said :
#1

You can put the data in a CSV or XML file and reference it in 'init_xml' in your __openerp__.py or __terp__.py file.
Lionel Sausin.

Revision history for this message
Mederic Roy F. Beldia (twocngdagz) said :
#2

What I need is to insert the name of database after installing the module. That's why can't use csv or xml.

________________________________
From: Numérigraphe <email address hidden>
To: <email address hidden>
Sent: Wednesday, October 12, 2011 10:41 PM
Subject: Re: [Question #174035]: Module Question

Your question #174035 on OpenERP Server changed:
https://answers.launchpad.net/openobject-server/+question/174035

    Status: Open => Answered

Numérigraphe proposed the following answer:
You can put the data in a CSV or XML file and reference it in 'init_xml' in your __openerp__.py or __terp__.py file.
Lionel Sausin.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/openobject-server/+question/174035/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/openobject-server/+question/174035

You received this question notification because you asked the question.

Revision history for this message
Numérigraphe (numerigraphe) said :
#3

Then I suggest you redefine the init() method in your object, and insert the data from there.
Lionel Sausin

Revision history for this message
Mederic Roy F. Beldia (twocngdagz) said :
#4

I also tried doing that but it seems that the init() method is being called first before the table is created. Cause I got error when I tried installing the module.

________________________________
From: Numérigraphe <email address hidden>
To: <email address hidden>
Sent: Thursday, October 13, 2011 12:05 AM
Subject: Re: [Question #174035]: Module Question

Your question #174035 on OpenERP Server changed:
https://answers.launchpad.net/openobject-server/+question/174035

    Status: Open => Answered

Numérigraphe proposed the following answer:
Then I suggest you redefine the init() method in your object, and insert the data from there.
Lionel Sausin

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/openobject-server/+question/174035/+confirm?answer_id=2

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/openobject-server/+question/174035

You received this question notification because you asked the question.

Revision history for this message
Numérigraphe (numerigraphe) said :
#5

init() is responsible for creating the table, so you should call super().init() before inserting values.
Lionel.

Revision history for this message
Mederic Roy F. Beldia (twocngdagz) said :
#6

that make sense. ok i'm gonna try this. thanks!

________________________________
From: Numérigraphe <email address hidden>
To: <email address hidden>
Sent: Thursday, October 13, 2011 3:05 PM
Subject: Re: [Question #174035]: Module Question

Your question #174035 on OpenERP Server changed:
https://answers.launchpad.net/openobject-server/+question/174035

    Status: Open => Answered

Numérigraphe proposed the following answer:
init() is responsible for creating the table, so you should call super().init() before inserting values.
Lionel.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/openobject-server/+question/174035/+confirm?answer_id=4

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/openobject-server/+question/174035

You received this question notification because you asked the question.

Revision history for this message
Mederic Roy F. Beldia (twocngdagz) said :
#7

I've tried it but I got an error. Are you sure that __init__() is responsible for creating a table or is it the _auto_init() function? Besides I also tried to override both the __init___ and _auto_init() but I still got an error.

Revision history for this message
Mederic Roy F. Beldia (twocngdagz) said :
#8

I know I got an error in _auto_init because declared context=None. Right now its working. thanks

Revision history for this message
Numérigraphe (numerigraphe) said :
#9

Right, that was __auto_init(), sorry. Only used it once but it's a nice feature.
Glad it worked for you.
Lionel.