The __init__.py file

The purpose of the _init__.py file is to specify the Python files you wish to include in your module. At a minimum, you will usually have one Python file, but you could have more or fewer depending on the complexity of the module you are developing. If you had a Python file with your code, and that file was named codexample.py, you would have to import codexample inside the __init__.py file. You will notice that you don't have to include the .py extension inside the __init__.py file.

To create the __init__.py file in Ubuntu, make sure you are in the module directory and use the following command:

sudo nano __init__.py

This will bring up the blank text editor.

For our example, the __init__.py file will contain one line ...

Get Working with Odoo 11 - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.