Odoo Help

Welcome!

This community 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.

1

__init__.py python import file

By
omprakash
on 5/20/13, 12:03 PM 5,352 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

1
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

omprakash
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

omprakash
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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