Odoo Help


What is the use of __init__() and init() in odoo ?When We can use them ?

Shivam Mahajan
on 6/27/16, 4:45 AM 2,057 views

How and when we can use these methods ? Is there any tutorial to find about this?


Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 6/27/16, 5:38 AM

Hi Shivam Mahajan

That's an internal model methods of the ORM and I don't know if you could find info out there about it. I will try to explain it to you so you could get an idea of how to use it

The __init__ method is used like usually in python for object initialization and for Odoo it's mostly used in report parsers to bring more data or custom functions or behaviors to the report templates(apply to those kind of objects that need an initialization to be used latter, report parsers in Odoo match that). You could read more about that here:


The init method is used mostly for model initialization or database operations after the module is installed or updated, it's like a hook that you could use it for example(one of the most used scenario) to create an sql view for an analytic view report, normally used in combination with _auto = False on the model to don't trigger the database table creation for the model. As I said this method is only called(if defined) when the module is installed or updated, if you need a hook to initialize something more of your model you could define the method _register_hook that will be called after the models are loaded on the Odoo registry/pool of models

Thanks a lot Axel for sharing the Knowledge .I am really thankful to you .

Shivam Mahajan
on 6/27/16, 6:26 AM

Happy to help!!

Axel Mendoza
on 6/27/16, 6:30 AM

How can we use the current user id in init() method because it takes only two parameters


Shivam Mahajan
on 6/27/16, 6:52 AM

There is no current user since it's a method called internally by the ORM after the module is installed, normally it's the admin

Axel Mendoza
on 6/27/16, 7:00 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/27/16, 4:45 AM
Seen: 2057 times
Last updated: 6/27/16, 6:26 AM