You are previewing Odoo Development Cookbook.
O'Reilly logo
Odoo Development Cookbook

Book Description

Build effective applications by applying Odoo development best practices

About This Book

  • Each recipe stands by itself as much as possible, so that you can jump straight into the topics you prefer

  • The recipes included cover all the major development areas of Odoo and the most important techniques explained through real-life projects

  • From seasoned authors, learn the tricks of becoming a productive developer with the Odoo framework

  • Who This Book Is For

    If you are a Python developer who wants to learn or consolidate your Odoo development skills, then this book is for you! Some experience with the JavaScript programming language and web development is required to fully benefit from the front-end chapters.

    What You Will Learn

  • Install and manage Odoo environments and instances

  • Use Models to define your application's data structures

  • Add business logic to your applications

  • Implement automated tests and debug Odoo apps

  • Use back-end views to create a user interface

  • Get to know about the access security model and internationalization features

  • Develop front-end website features

  • Extend the web client with new widgets and features

  • In Detail

    Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites.

    The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.

    Style and Approach

    These practical and easy-to-follow recipes are presented step-by-step, with dozens of hands-on recipes to boost your Odoo skills. This book can also be used as a reference guide for your daily work.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Odoo Development Cookbook
      1. Table of Contents
      2. Odoo Development Cookbook
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. What this book covers
        2. Who this book is for
        3. What you need for this book
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Installing the Odoo Development Environment
        1. Introduction
        2. Easy installation of Odoo from source
          1. Getting ready
          2. How to do it...
          3. How it works...
            1. Virtual environments
            2. PostgreSQL configuration
            3. Git configuration
            4. Downloading the Odoo source code
            5. Starting the instance
          4. There is more…
        3. Managing Odoo environments using the start command
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more
        4. Managing Odoo server databases
          1. Getting ready
          2. How to do it...
            1. Access the Database Management interface
            2. Set or change the master password
            3. Creating a new database
            4. Duplicating a database
            5. Removing a database
            6. Backing up a database
            7. Restoring a database backup
          3. How it works...
          4. There is more...
        5. Storing the instance configuration in a file
          1. How to do it...
          2. How it works...
          3. There is more...
        6. Activating the Odoo developer tools
          1. How to do it...
          2. How it works...
        7. Updating Odoo from source
          1. Getting ready
          2. How to do it...
          3. How it works...
      9. 2. Managing Odoo Server Instances
        1. Introduction
        2. Configuring the addons path
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Updating the addon modules list
          1. Getting ready
          2. How to do it…
          3. How it works…
        4. Standardizing your instance directory layout
          1. How to do it…
          2. How it works…
          3. See also
        5. Installing and upgrading local addon modules
          1. Getting ready
          2. How to do it…
            1. From the web interface
            2. From the command line
          3. How it works…
            1. Addon installation
            2. Addon update
          4. There's more…
        6. Installing addon modules from GitHub
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Applying changes to addons
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        8. Applying and trying proposed pull requests
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
      10. 3. Creating Odoo Modules
        1. Introduction
        2. Creating and installing a new addon module
          1. Getting ready
          2. How to do it…
          3. How it works…
        3. Completing the addon module manifest
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more
        4. Organizing the addon module file structure
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Adding models
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. Adding Menu Items and Views
          1. Getting ready
          2. How to do it…
          3. How it works…
        7. Using scaffold to create a module
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
      11. 4. Application Models
        1. Introduction
        2. Defining the Model representation and order
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Adding data fields to a model
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Using a float field with configurable precision
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Adding a monetary field to a Model
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. Adding relational fields to a Model
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Adding a hierarchy to a Model
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        8. Adding constraint validations to a Model
          1. Getting ready
          2. How to do it…
          3. How it works…
        9. Adding computed fields to a Model
          1. Getting ready
          2. How to do it…
          3. How it works…
        10. Exposing Related fields stored in other models
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        11. Adding dynamic relations using Reference fields
          1. Getting ready
          2. How to do it…
          3. How it works…
        12. Adding features to a Model using inheritance
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        13. Using Abstract Models for reusable Model features
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        14. Using Delegation inheritance to copy features to another Model
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
      12. 5. Basic Server Side Development
        1. Introduction
        2. Defining model methods and use the API decorators
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Hiding methods from the RPC interface
            2. The @api.one decorator
          5. See also
        3. Reporting errors to the user
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Obtaining an empty recordset for a different model
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. Creating new records
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more
        6. Updating values of recordset records
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Searching for records
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        8. Combining recordsets
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        9. Filtering recordsets
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        10. Traversing recordset relations
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        11. Extending the business logic defined in a Model
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        12. Extending write() and create()
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        13. Customizing how records are searched
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      13. 6. Advanced Server Side Development Techniques
        1. Introduction
        2. Change the user performing an action
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There is more…
          5. See also
        3. Call a method with a modified context
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Execute raw SQL queries
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Write a wizard to guide the user
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Using the context to compute default values
            2. Wizards and code reuse
            3. Redirecting the user
        6. Define onchange methods
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Call onchange methods on the server side
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Port old API code to the new API
          1. Getting ready
          2. How to do it…
          3. How it works
      14. 7. Debugging and Automated Testing
        1. Introduction
        2. Producing server logs to help debug methods
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Using the Odoo shell to interactively call methods
          1. Getting ready
          2. How to do it…
          3. How it works…
        4. Using the Python debugger to trace method execution
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Writing tests for your module using YAML
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        6. Writing tests for your module using Python unit tests
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Running server tests
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        8. Using the Odoo Community Association maintainer quality tools
          1. Getting ready
          2. How to do it…
          3. How it works…
      15. 8. Backend Views
        1. Introduction
        2. Adding a menu item and window action
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Having an action open a specific view
          1. How to do it...
          2. How it works...
            1. ir.actions.act_window.view
        4. Adding content and widgets to a form view
          1. How to do it...
          2. How it works...
            1. Form
            2. Header
            3. Button
            4. Group
            5. Field
            6. General attributes
            7. Other tags
          3. There's more...
          4. See also
        5. Adding buttons to forms
          1. How to do it...
          2. How it works...
          3. There's more...
        6. Passing parameters to forms and actions: Context
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Defining filters on record lists: Domain
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Operators
            2. Pitfalls
          4. See also
        8. List views
          1. How to do it...
          2. How it works...
          3. There's more...
        9. Search views
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Changing existing views: View inheritance
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Order of evaluation in view inheritance
          4. See also
        11. Document-style forms
          1. How to do it...
          2. How it works...
        12. Dynamic form elements using attrs
          1. How to do it...
          2. How it works...
          3. There's more...
        13. Embedded views
          1. How to do it...
          2. How it works...
          3. There's more...
        14. Kanban views
          1. How to do it...
          2. How it works...
          3. There's more...
        15. Show kanban cards in columns according to their state
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        16. Calendar views
          1. How to do it...
          2. How it works...
          3. There's more...
        17. Graph and pivot views
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        18. QWeb reports
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      16. 9. Module Data
        1. Introduction
        2. Using external IDs and namespaces
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Loading data using XML files
          1. How to do it...
          2. How it works...
          3. There's more...
        4. Using the noupdate and forcecreate flags
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Loading data using CSV files
          1. How to do it...
          2. How it works...
          3. There's more...
        6. Loading data using YAML files
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Addon updates and data migration
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      17. 10. Access Security
        1. Create security groups and assign them to users
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        2. Add security access to models
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Limit access to fields in models
          1. How to do it...
          2. How it works...
          3. There's more...
        4. Limit record access using record rules
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Using security group to activate features
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      18. 11. Internationalization
        1. Installing a language and configure user preferences
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        2. Configure language-related settings
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Translate texts through the web client user interface
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Exporting translation strings to a file
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Use gettext tools to ease translations
          1. How to do it...
          2. How it works...
          3. There's more...
        6. Import translation files
          1. Getting ready
          2. How to do it...
          3. How it works...
      19. 12. Automation and Workflows
        1. Introduction
        2. Using Kanban stages and features
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Creating server actions
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Adding messaging and tracking features
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Using Python code server actions
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Using automated actions on time conditions
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Using automated actions on event conditions
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        8. Inspecting built-in workflows
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      20. 13. Web Server Development
        1. Introduction
        2. Make a path accessible from the network
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. openerp.http.route
            2. Return values
            3. openerp.http.request
          4. There's more…
          5. See also
        3. Restrict access to web accessible paths
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Consume parameters passed to your handlers
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        5. Modify an existing handler
          1. Getting ready
          2. How to do it…
          3. How it works
          4. There's more…
          5. See also
        6. Using the RPC API
          1. How to do it…
          2. How it works…
            1. XMLRPC
            2. JSONRPC
          3. There's more…
          4. See also
      21. 14. CMS Website Development
        1. Introduction
        2. Extending CSS and JavaScript for the website
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Creating or modifying templates - QWeb
          1. Getting ready
          2. How to do it...
          3. How it works...
            1. Loops
            2. Attributes
            3. Fields
            4. Conditionals
            5. Inline editing
          4. There's more...
          5. See also
        4. Offering snippets to the user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      22. 15. Web Client Development
        1. Introduction
        2. Creating custom widgets
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Using client-side QWeb templates
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Making RPC calls to the server
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Writing tests for client side code
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Debugging your client side code
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      23. 16. Server Deployment
        1. Introduction
        2. Installing Odoo for production
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Server dimensioning
            2. PostgreSQL tuning
            3. Source code version
            4. Backups
          5. See also
        3. Adapting the configuration file for production
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Set up Odoo as a system service
          1. Getting ready
          2. How to do it…
            1. Configuring systemd to start Odoo
            2. Configuring sysvinit or upstart to start Odoo
          3. How it works…
          4. There's more…
        5. Configure a reverse proxy and SSL
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Use buildout for repeatable builds
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Temporary merges
            2. Freezing a buildout
          5. See also
      24. Index