Book Image

Odoo 14 Development Cookbook - Fourth Edition

By : Parth Gajjar, Alexandre Fayolle, Holger Brunn, Daniel Reis
5 (2)
Book Image

Odoo 14 Development Cookbook - Fourth Edition

5 (2)
By: Parth Gajjar, Alexandre Fayolle, Holger Brunn, Daniel Reis

Overview of this book

With its latest iteration, the powerful Odoo framework released a wide variety of features for rapid application development. This updated Odoo development cookbook will help you explore the new features in Odoo 14 and learn how to use them to develop Odoo applications from scratch. You'll learn about the new website concepts in Odoo 14 and get a glimpse of Odoo's new web-client framework, the Odoo Web Library (OWL). Once you've completed the installation, you'll begin to explore the Odoo framework with real-world examples. You'll then create a new Odoo module from the ground up and progress to advanced framework concepts. You'll also learn how to modify existing applications, including Point of Sale (POS) applications. This book isn't just limited to backend development; you'll discover advanced JavaScript recipes for creating new views and widgets. As you progress, you'll learn about website development and become a quality Odoo developer by studying performance optimization, debugging, and automated testing. Finally, you'll delve into advanced concepts such as multi-website, In-App Purchasing (IAP),, the IoT Box, and security. By the end of the book, you'll have all the knowledge you need to build impressive Odoo applications and you'll be well versed in development best practices that will come in handy when working with the Odoo framework.
Table of Contents (26 chapters)

How to do it…

To create the proposed instance layout, you need to perform the following steps:

  1. Create one directory per instance:
    $ mkdir ~/odoo-dev/projectname
    $ cd ~/odoo-dev/projectname
  2. Create a Python virtualenv object in a subdirectory called env/:
    $ python3 -m venv env
  3. Create some subdirectories, as follows:
    $ mkdir src local bin filestore logs

    The functions of the subdirectories are as follows:

    • src/: This contains the clone of Odoo itself, as well as the various third-party add-on projects (we have added Odoo source code to the next step in this recipe).
    • local/: This is used to save your instance-specific add-ons.
    • bin/: This includes various helper executable shell scripts.
    • filestore/: This is used as a file store.
    • logs/ (optional): This is used to store the server log files.
  4. Clone Odoo and install the requirements (refer to Chapter 1, Installing the Odoo Development Environment, for details on this):
    $ git clone -b 14.0 --single-branch --depth 1 src/odoo
    $ env/bin/pip3 install -r src/odoo/requirements.txt
  5. Save the following shell script as bin/odoo:
    #!/bin/sh ROOT=$(dirname $0)/..
    PYTHON=$ROOT/env/bin/python3 ODOO=$ROOT/src/odoo/odoo-bin
    $PYTHON $ODOO -c $ROOT/projectname.cfg "$@" exit $?
  6. Make the script executable:
    $ chmod +x bin/odoo
  7. Create an empty dummy local module:
    $ mkdir -p local/dummy
    $ touch local/dummy/  init  .py
    $ echo '{"name": "dummy", "installable": False}' >\ local/dummy/  manifest  .py
  8. Generate a configuration file for your instance:
    $ bin/odoo --stop-after-init --save \
    --addons-path src/odoo/odoo/addons,src/odoo/addons,local \
    --data-dir filestore
  9. Add a .gitignore file, which is used to tell GitHub to exclude given directories so that Git will ignore these directories when you commit the code, for example, filestore/, env/, logs/, and src/:
    # dotfiles, with exceptions:
    # python compiled files
    # emacs backup files
    # not tracked subdirectories
  10. Create a Git repository for this instance and add the files you've added to Git:
    $ git init
    $ git add .
    $ git commit -m "initial version of projectname"