Odoo 15 Development Essentials - Fifth Edition

Book description

Become a proficient Odoo developer and increase your productivity while building Odoo business applications

Key Features

  • Set up the Odoo development environment and learn how to test and debug your code
  • Use the ORM framework to work with data and implement business logic supporting business rules
  • Design user interfaces, web pages, and business reports using the Odoo framework's web components

Book Description

Odoo is fast becoming the reference open source platform for business applications thanks to the fact that it provides the infrastructure needed for developers to deliver software solutions for any business process quickly. Odoo's layered module approach makes it particularly effective for combining and extending features. This updated fifth edition is a tutorial-style introduction to essential Odoo development topics.

The book starts by covering the development essentials for building business applications and takes you through Odoo installation and configuration, gradually transitioning from having no specific knowledge of Odoo to being ready for application development. You'll then learn how to develop your first Odoo application, while covering topics such as models and views. Later chapters will get you up to speed with using server APIs to add business logic, helping you lay a solid foundation for advanced topics. As you progress, you’ll get equipped to build and customize your applications and explore the new features available in Odoo 12 and beyond, such as in-memory ORM and computed writable fields. Finally, you’ll gain insights into building business logic and using the Odoo API to integrate with various applications.

By the end of this book, you’ll be able to build business apps from scratch using the latest version of Odoo.

What you will learn

  • Install Odoo from source and organize the development environment
  • Create your first Odoo app from scratch
  • Understand the application components available in Odoo
  • Structure the application’s data model using ORM features
  • Use the ORM API to implement the business logic layer
  • Design a graphical user interface (GUI) for the web client and website
  • Use the Odoo External API to interface with external systems
  • Deploy and maintain your application in production environments

Who this book is for

This book is for developers who want to learn Odoo application development and quickly become productive while creating business applications. Teachers, trainers, and Odoo team managers will also find the book useful for helping their students or trainees to learn Odoo development skills. Basic knowledge of Python programming is required to get started with the book

Table of contents

  1. Odoo 15 Development Essentials Fifth Edition
  2. Foreword
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  7. Section 1: Introduction to Odoo Development
  8. Chapter 1: Quick Start Using the Developer Mode
    1. Technical requirements
    2. Introducing the to-do list project
    3. Understanding basic Odoo concepts
      1. About Odoo and the Odoo community
      2. Odoo product versions
      3. The Odoo architecture
    4. Using an Odoo SaaS trial database
    5. Installing Odoo in your workstation
      1. Installing on Windows using the all-in-one installer
      2. Installing on Linux using a pre-packaged installer
      3. Installing Odoo using Docker containers
    6. Enabling the developer tools
      1. Enabling the developer mode
      2. Using the developer mode with assets
      3. About Odoo Studio
    7. Adding a custom field to a model
      1. Adding a field to a model
      2. Adding a field to a form view
      3. Understanding view types
    8. Creating a new model
    9. Creating menu items and actions
    10. Configuring access control security
      1. Security groups
      2. Security access control lists
      3. Assigning security groups to users
      4. Security record rules
      5. Understanding the superuser account
    11. Creating views
      1. Creating a list view
      2. Creating a form view
      3. Creating search views
      4. Enabling default filters on views
    12. Summary
  9. Chapter 2: Preparing the Development Environment
    1. Technical requirements
    2. Setting up a host for the Odoo server
      1. Installing the Windows Subsystem for Linux
    3. Installing Odoo from source
      1. Installing the PostgreSQL database
      2. Installing the Odoo system dependencies
      3. Installing Odoo from source
      4. Running Odoo
      5. Creating a new database from the web client
      6. Creating a new database from the command line
    4. Managing Odoo databases
    5. Configuring the Odoo server options
      1. Odoo server configuration files
      2. Changing the listening port
      3. Filtering the list of accessible databases
      4. Managing server log messages
    6. Finding and installing additional modules
      1. Finding community modules
      2. Configuring the add-ons path
    7. Using the server development options
    8. Odoo commands quick reference
    9. Summary
  10. Chapter 3: Your First Odoo Application
    1. Technical requirements
    2. Overview of the library project
    3. Step 1 – Creating a new addon module
      1. Preparing the addons path
      2. Creating a module directory
      3. Creating a manifest file
      4. Setting the module category
      5. Choosing a license
      6. Adding a description
      7. Adding an icon
      8. Installing a new module
      9. Upgrading modules
    4. Step 2 – Creating a new application
      1. Adding a top menu item
      2. Adding security groups
    5. Step 3 – Adding automated tests
      1. Adding test cases
      2. Running tests
      3. Testing business logic
      4. Testing access security
    6. Step 4 – Implementing the model layer
      1. Creating a data model
    7. Step 5 – Setting up access security
      1. Adding access control security
      2. Row-level access rules
    8. Step 6 – Implementing the backend view layer
      1. Adding menu items
      2. Creating a form view
      3. Business document form views
      4. Adding action buttons
      5. Using groups to organize forms
      6. The complete form view
      7. Adding list and search views
    9. Step 7 – Implementing the business logic layer
      1. Adding business logic
    10. Step 8 – Implementing the website UI
      1. Adding the endpoint controller
      2. Adding a QWeb template
    11. Quick reference
      1. Access security
    12. Summary
  11. Chapter 4: Extending Modules
    1. Technical requirements
    2. Learning project – extending the Library app
      1. Books
      2. Members
    3. Adding a new field to an existing model
      1. Adding new fields with the in-place model extension
      2. Adding a field to the Form view
    4. Extending models using classic in-place extension
      1. Incrementally modifying existing fields
      2. Extending Python methods to add features to the business logic
    5. More model inheritance mechanisms
      1. Embedding models using delegation inheritance
      2. Copying models with prototype inheritance
      3. Reusing model features using mixin classes
      4. Adding message chatter and activities to a model
    6. Extending views and data
      1. Extending views
      2. Moving XML nodes to a different location
      3. Using XPath to select XML extension points
      4. Modifying existing data
    7. Extending web pages
      1. Extending the web controllers
      2. Extending QWeb templates
    8. Summary
    9. Further reading
  12. Section 2: Models
  13. Chapter 5: Importing, Exporting, and Module Data
    1. Technical requirements
    2. Understanding the external identifier concept
      1. How external identifiers work
      2. Finding external identifiers
    3. Exporting and importing CSV data files
      1. Exporting data
      2. Importing data
      3. Related records in CSV data files
    4. Adding module data
      1. Demonstration data
    5. Using XML data files
      1. The noupdate data attribute
      2. Defining records in XML
      3. Shortcuts for frequently used models
      4. Using other actions in XML data files
    6. Summary
    7. Further reading
  14. Chapter 6: Models – Structuring the Application Data
    1. Technical requirements
    2. Learning project – improving the Library app
    3. Creating models
      1. Model attributes
      2. Models and Python classes
      3. Transient and abstract models
      4. Inspecting existing models
    4. Creating fields
      1. Basic field types
      2. Common field attributes
      3. Setting default values
      4. Automatic field names
      5. Reserved field names
    5. Relationships between models
      1. Many-to-one relationships
      2. One-to-many inverse relationships
      3. Many-to-many relationships
      4. Hierarchical relationships
      5. Flexible relationships using Reference fields
    6. Computed fields
      1. Searching and writing on computed fields
      2. Related fields
    7. Model constraints
      1. SQL model constraints
      2. Python model constraints
    8. Overview of the Odoo base models
    9. Summary
    10. Further reading
  15. Section 3: Business Logic
  16. Chapter 7: Recordsets – Working with Model Data
    1. Technical requirements
    2. Using the shell command
    3. The execution environment
      1. Environment attributes
      2. The environment context
      3. Modifying the recordset execution environment and context
    4. Querying data with recordsets and domains
      1. Creating recordsets
      2. Domain expressions
      3. Grouping by fields and aggregate data
    5. Accessing data in recordsets
      1. Accessing individual record data
      2. Accessing relational fields
      3. Accessing date and time values
    6. Writing to records
      1. Using object-style value assignments
      2. Using the write() method
      3. Creating and deleting records
    7. Working with date and time fields
      1. Adding and subtracting time
      2. Converting date and time objects to text representations
      3. Converting text-represented dates and times
    8. Working with recordsets
      1. Recordset operations
      2. The composition of a recordset
      3. Recordset accumulation
      4. Recordset comparisons
    9. Transactions and low-level SQL
      1. Controlling database transactions
      2. Executing raw SQL
    10. Summary
    11. Further reading
  17. Chapter 8: Business Logic – Supporting Business Processes
    1. Technical requirements
    2. Learning project – the book checkout module
      1. Preparing the data model
      2. Creating the module
    3. Exploring ways to trigger business logic
    4. Understanding ORM method decorators for recordsets
      1. Decorators for computed fields and validation methods
      2. Decorators that affect the self recordset
    5. Exploring useful data model patterns
      1. Using header and lines models
      2. Using stages and states for document-centered workflows
      3. Adding stage workflow support to models
      4. Methods to support the user interface
    6. Using the ORM built-in methods
      1. Methods for writing model data
      2. Methods for data import and export
    7. Adding onchange user interface logic
      1. Classic onchange methods
      2. The new onchange, with computed writable fields
    8. The message and activity features
      1. Adding message and activity features
      2. Message and activity fields and models
      3. Message subtypes
      4. Posting messages
      5. Adding followers
    9. Creating a wizard
      1. The wizard model
      2. The wizard's access security
      3. The wizard form
      4. The wizard business logic
    10. Raising exceptions
    11. Writing unit tests
      1. Adding unit tests
      2. Running tests
      3. Setting up tests
      4. Writing test cases
      5. Testing exceptions
    12. Using log messages
    13. Learning about the available developer tools
      1. Server development options
      2. Debugging
      3. Inspecting and killing running processes
    14. Summary
    15. Further reading
  18. Chapter 9: External API – Integrating with Other Systems
    1. Technical requirements
    2. Introducing the learning project – a client app to catalog books
    3. Setting up Python on the client machine
    4. Exploring the Odoo external API
      1. Using XML-RPC to connect to the Odoo external API
      2. Using XML-RPC to run server methods
      3. Using the search and read API methods
      4. Calling other API methods
    5. Implementing the client app XML-RPC interface
    6. Implementing the client app user interface
    7. Using the OdooRPC library
    8. Summary
    9. Further reading
  19. Section 4: Views
  20. Chapter 10: Backend Views – Designing the User Interface
    1. Technical requirements
    2. Adding menu items
    3. Understanding window actions
    4. Adding options to the Action context menu
    5. Exploring the form view structure
      1. Using business document views
      2. Adding a header section
      3. Designing the document sheet
      4. Adding a header title
      5. Organizing the form content using groups
      6. Adding tabbed notebooks
    6. Using fields
      1. Modifying field labels
      2. Choosing field widgets
      3. Relation fields
    7. Using buttons
      1. Using smart buttons
    8. Adding dynamic view elements
      1. Using onchange events
      2. Using dynamic attributes
    9. Exploring list views
      1. Adding a list view header section
      2. Using line decoration
      3. Other list view attributes
      4. Adding column totals
    10. Exploring search views
      1. Understanding the <field> element
      2. Understanding the <filter> element
      3. Adding a search panel
    11. Understanding the other available view types
      1. Exploring the activity view
      2. Exploring the calendar view
      3. Exploring the pivot view
      4. Exploring the graph view
    12. Summary
    13. Further reading
  21. Chapter 11: Kanban Views and Client-Side QWeb
    1. Technical requirements
    2. Introducing kanban boards
      1. Supporting kanban boards in Odoo
      2. Understanding kanban states
    3. Designing kanban views
      1. Creating a minimal viable kanban view
      2. Presenting kanban board columns
      3. Understanding kanban view attributes and elements
      4. Adding a progress bar to group columns
    4. Designing kanban cards
      1. Organizing the kanban card layout
      2. Adding a title and other content fields
      3. Adding the drop-down options menu
      4. Adding a kanban card color indicator
      5. Adding priority and activity widgets
      6. Adding kanban state and user avatar widgets
      7. Using actions in kanban view elements
    5. Exploring the QWeb template language
      1. Understanding the QWeb JavaScript evaluation context
      2. Using t-out to render values
      3. Using t-set to assign values to variables
      4. Using t-attf- for string substitution of dynamic attributes
      5. Using t-att- for expressions calculated by dynamic attributes
      6. Using t-foreach for loops
      7. Using t-if to apply conditions
      8. Using t-call to call and reuse templates
      9. Using dictionaries and lists to dynamically set attributes
    6. Extending kanban views
    7. Adding CSS and JavaScript assets
      1. Adding assets before Odoo 15
    8. Summary
    9. Further reading
  22. Chapter 12: Creating Printable PDF Reports with Server-Side QWeb
    1. Technical requirements
    2. Installing wkhtmltopdf
    3. Creating business reports
      1. Adding the report action
      2. Using a QWeb report template for per-record documents
      3. Using a QWeb report template for record listings
      4. Choosing a report layout
      5. Setting a paper format
    4. Designing report content
      1. Understanding the report rendering context
      2. Adding the report content
      3. Using field widgets
      4. Rendering images
      5. Calculating totals
      6. Calculating running totals
      7. Enabling language translation in reports
    5. Creating custom reports
      1. Preparing custom report data
      2. Adding the report template
    6. Further reading
  23. Chapter 13: Creating Web and Portal Frontend Features
    1. Technical requirements
    2. Introducing the library portal learning project
    3. Creating a frontend web page
      1. Adding a web controller
      2. Adding a QWeb template
      3. Adding CSS and JavaScript assets
    4. Understanding web controllers
      1. Declaring routes
      2. Extracting argument values from the route string
      3. Using the request object
      4. Using the response object
    5. Adding portal features
      1. Configuring access security for the portal users
      2. Adding a portal document type to the main list
      3. Adding a portal document list page
      4. Adding a portal document detail page
      5. Adding a portal breadcrumb
    6. Summary
    7. Further reading
  24. Section 5: Deployment and Maintenance
  25. Chapter 14: Understanding Odoo Built-In Models
    1. Technical requirements
    2. Understanding the contacts data model
    3. Understanding the users and companies data model
    4. Understanding the security-related information repository
    5. Understanding the database structure models
    6. Understanding the UI-related information repository
    7. Understanding the configuration properties and company parameters
    8. Understanding messaging data models
    9. Summary
  26. Chapter 15: Deploying and Maintaining Production Instances
    1. Technical requirements
    2. Preparing the host system
      1. Installing the system dependencies
      2. Preparing a dedicated system user
    3. Installing Odoo from source code
      1. Downloading the Odoo source code
      2. Installing the Python dependencies
    4. Configuring Odoo
      1. Setting up the configuration file
      2. Understanding multiprocessing workers
    5. Setting up Odoo as a system service
      1. Creating a systemd service
      2. Checking the Odoo service from the command line
    6. Setting up an Nginx reverse proxy
    7. Configuring and enforcing HTTPS
      1. Creating a self-signed SSL certificate
      2. Configuring HTTPS access on Nginx
      3. Caching static content
    8. Maintaining the Odoo service and modules
      1. Creating a staging environment
      2. Updating Odoo source code
    9. Summary
    10. Further reading
    11. Why subscribe?
  27. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Odoo 15 Development Essentials - Fifth Edition
  • Author(s): Daniel Reis
  • Release date: February 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781800200067