Odoo 11 Development Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

How it works…

We generate a clean directory structure with clearly labeled directories and dedicated roles; especially, we separate the following:

  • The code maintained by other people (in src/)
  • The local specific code
  • The filestore of the instance

By having one virtualenv per project, we are sure that the project's dependencies will not interfere with the dependencies of other projects that can be running a different version of Odoo or use different third-party addon modules, which need different versions of Python dependencies. This comes at the cost of a little disk space.

In a similar way, using separate clones of Odoo and third-party addon modules for our different projects, we are able to let each of these evolve independently and only install updates on the instances that need them, hence reducing the risk of introducing regressions.

The bin/odoo script allows us to run the server without having to remember the various paths or activate the virtualenv. It also sets the configuration file for us. You can add additional scripts in there to help you in your day-to-day work, for instance, a script to check out the different third-party projects that you need to run your instance.

Regarding the configuration file, we only show the bare minimum options to set up here, but you obviously can set more, such as the database name, the database filter, or the port on which the project listens. Refer to Chapter 1, Installing the Odoo Development Environment, for more information on this topic.

Finally, by managing all of this in a Git repository, it becomes quite easy to replicate the setup on a different computer and share the development among a team.

Speedup tip
To ease project creation, you can create a template repository containing the empty structure, and fork that repository for each new project. This will save you from retyping the bin/odoo script and the .gitignore file, and any other template file you need (continuous integration configuration, README.md, ChangeLog, and so on).