Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Odoo 14 Development Cookbook

You're reading from   Odoo 14 Development Cookbook Rapidly build, customize, and manage secure and efficient business apps using Odoo's latest features

Arrow left icon
Product type Paperback
Published in Dec 2020
Publisher Packt
ISBN-13 9781800200319
Length 784 pages
Edition 4th Edition
Languages
Tools
Arrow right icon
Authors (4):
Arrow left icon
Parth Gajjar Parth Gajjar
Author Profile Icon Parth Gajjar
Parth Gajjar
Alexandre Fayolle Alexandre Fayolle
Author Profile Icon Alexandre Fayolle
Alexandre Fayolle
Holger Brunn Holger Brunn
Author Profile Icon Holger Brunn
Holger Brunn
Daniel Reis Daniel Reis
Author Profile Icon Daniel Reis
Daniel Reis
Arrow right icon
View More author details
Toc

Table of Contents (26) Chapters Close

Preface 1. Chapter 1: Installing the Odoo Development Environment 2. Chapter 2: Managing Odoo Server Instances FREE CHAPTER 3. Chapter 3: Creating Odoo Add-On Modules 4. Chapter 4: Application Models 5. Chapter 5: Basic Server-Side Development 6. Chapter 6: Managing Module Data 7. Chapter 7: Debugging Modules 8. Chapter 8: Advanced Server-Side Development Techniques 9. Chapter 9: Backend Views 10. Chapter 10: Security Access 11. Chapter 11: Internationalization 12. Chapter 12: Automation, Workflows, Emails, and Printing 13. Chapter 13: Web Server Development 14. Chapter 14: CMS Website Development 15. Chapter 15: Web Client Development 16. Chapter 16: The Odoo Web Library (OWL) 17. Chapter 17: In-App Purchasing with Odoo 18. Chapter 18: Automated Test Cases 19. Chapter 19: Managing, Deploying, and Testing with Odoo.sh 20. Chapter 20: Remote Procedure Calls in Odoo 21. Chapter 21: Performance Optimization 22. Chapter 22: Point of Sale 23. Chapter 23: Managing Emails in Odoo 24. Chapter 24: Managing the IoT Box 25. Other Books You May Enjoy

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 https://github.com/odoo/odoo.git 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:
    .*
    !.gitignore
    # python compiled files
    *.py[co]
    # emacs backup files
    *~
    # not tracked subdirectories
    /env/
    /src/
    /filestore/
    /logs/
  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"
You have been reading a chapter from
Odoo 14 Development Cookbook - Fourth Edition
Published in: Dec 2020
Publisher: Packt
ISBN-13: 9781800200319
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime