Odoo Help


__init__.py python import file

on 5/20/13, 12:03 PM 7,124 views

Hai Friends ,

First I thank everyone , who give such support for newbie . When I started learning about creating custom module . Some Question raised in my mind .
  1. In __init__.py , what are the module (or) sub-module to be imported ?

  2. If my module _inherit another module , should i import the _inherit module in __init__.py ?

  3. What is purpose of declaring the module in __init__.py ?

Please clarify my doubt & once again thanks for everyone .

Thanks & Regards OMPRAKASH.A

mihir shah
On 5/20/13, 12:08 PM

n __init__.py file the modules which u going to import are ...the business logic files, having extension .py , for sales.py .

There is no need of _inheriting the module in __init__.py file.

__init__.py is used to initialize your module and its mandatory in each and every module u create

Hi mihir shah , Thanks for your immediate reply . I can understand your points . If you explain with some example it make more useful for me .. And once again thanks for your reply ... OMPRAKASH.A

on 5/21/13, 2:36 AM

Hi omprakash , for eg. If you are creating a customized module name school_management. in that first you create __init__.py file in that you import stu_reg ,after that __openerp_.py in this file you declare about all the views , dependencies ,(if any ) else always base. then you create stu_reg.py file name should be same as which is import in __init_.py file. In stu_reg.py file import fields ,osv and declare all the object models with there fields and data types . also you can define function if needed in stu_reg.py file

mihir shah
on 5/21/13, 3:20 AM

now create stu_reg.xml file for the view purpose.the structure of the xml view is given in documentation . so now when add this custom module to addons folder and try to install it , openerp by default first calls __init__.py file then __openerp__.py for initializing your module . hope my ans satisfying

mihir shah
on 5/21/13, 3:31 AM

Hi mihir shah , Thanks for your reply .Now i have idea about __init__.py file . But need more clarification please help me ... 1.) except import stu_reg , whether we will import another module ? If we import when ? And once again thanks for your reply ....OMPRAKASH.A

on 5/22/13, 1:19 PM

Hi omprakash, yes you can import n number of py files in __init__.py. after importing stu_reg i want to register teacher so i made tech_reg.py file. then i just have to import tech_reg in __init__.py file. But i would suggest that ..if you have different module for different business logic ,so as to use modular structure of openerp. and makes it more usable

mihir shah
on 5/23/13, 3:11 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

2 follower(s)


Asked: 5/20/13, 12:03 PM
Seen: 7124 times
Last updated: 4/11/16, 3:51 AM