Skip to Content
Menu
This question has been flagged
1 Reply
5772 Views

While installing a module I want to call function automatically for creating records like demo data. How can we do that?

Avatar
Discard
Best Answer

Hi,

There are 3 methods, the pre init hook helps to execute some python code before calling the init methods, the post init hook helps to execute a function immediately after completing the installation.The 3rd option is overriding the init method of any class so that it will be executed while the class is being initialised.
And you can also use the function tag for this purpose.
For example:

<odoo>
<data noupdate="1">
<function
id="id"
model="your.model"
name="your_function_name"/>
</data>
</odoo>

Update this as a data file.

Avatar
Discard