Some tips when I take time to write them down.

Part 2 - Create an odoo addon and install it

In this post, we'll create on odoo addon, make it a python package installable with pip and we'll upload it to Gitlab.

Generate an odoo addon:

$ cd ~/odoo-docker/addons
$ odoo scaffold my_awesome_addon
$ tree -L 2
├── config.ini
└── my_awesome_addon
    ├── controllers
    ├── demo
    ├── models
    ├── security
    └── views

It's now time to setup a git repository, we'll create gitlab project later:

$ cd my_awesome_addon
$ git init
$ git add --all
$ git commit -m "Initial commit"
$ cd ..

Now, we want to test it with odoo. The fastest way is to edit the addon_path in config.ini and append the parent's path of my_awesome_addon to the list.

But we'll directly make the addon a python package using setuptools-odoo to allow us to install the addon in the python environment and odoo namespace.

setuptools-odoo require a structure for the project, this is well explained here.

Once done, the addon structure should look like this:

$ tree -L 5
├── config.ini
└── my_awesome_addon
    ├── odoo
    │   ├──
    │   └── addons
    │       ├──
    │       └── my_awesome_addon
    │           ├──
    │           ├──
    │           ├── controllers
    │           ├── demo
    │           ├── models
    │           ├── security
    │           └── views

Change the version of your addon to to meet odoo requirements. Then you can add this addon to the odoo namespace like this:

$ cd my_awesome_addon
$ python develop
$ odoo -c ../config.ini

Activate the developer mode on odoo and refresh the module list, you should see my_awesome_addon present and could install it.

Ok, now with have a module usable with odoo, let's upload it to gitlab.

We need to ignore some new generated files:

$ echo ".eggs/\n*.egg-info/\n*.pyc\n" >> .gitignore

Create a project on Gitlab, then commit all changes and upload them:

$ git add --all
$ git commit -m "Make the addon a python package"
$ git remote add origin
$ git push --set-upstream origin master

That's all for now.