Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Odoo 15 Development Essentials - Fifth Edition

You're reading from  Odoo 15 Development Essentials - Fifth Edition

Product type Book
Published in Feb 2022
Publisher Packt
ISBN-13 9781800200067
Pages 548 pages
Edition 5th Edition
Languages
Author (1):
Daniel Reis Daniel Reis
Profile icon Daniel Reis

Table of Contents (22) Chapters

Preface 1. Section 1: Introduction to Odoo Development
2. Chapter 1: Quick Start Using the Developer Mode 3. Chapter 2: Preparing the Development Environment 4. Chapter 3: Your First Odoo Application 5. Chapter 4: Extending Modules 6. Section 2: Models
7. Chapter 5: Importing, Exporting, and Module Data 8. Chapter 6: Models – Structuring the Application Data 9. Section 3: Business Logic
10. Chapter 7: Recordsets – Working with Model Data 11. Chapter 8: Business Logic – Supporting Business Processes 12. Chapter 9: External API – Integrating with Other Systems 13. Section 4: Views
14. Chapter 10: Backend Views – Designing the User Interface 15. Chapter 11: Kanban Views and Client-Side QWeb 16. Chapter 12: Creating Printable PDF Reports with Server-Side QWeb 17. Chapter 13: Creating Web and Portal Frontend Features 18. Section 5: Deployment and Maintenance
19. Chapter 14: Understanding Odoo Built-In Models 20. Chapter 15: Deploying and Maintaining Production Instances 21. Other Books You May Enjoy

Chapter 14: Understanding Odoo Built-In Models

When a new database is created, an initial data model is populated, providing basic entities that can be used for Odoo Apps. This chapter identifies the most relevant basic entities and explains how to inspect them from the user interface (UI), as well as what their role is.

While this understanding is not indispensable for you to be able to develop Odoo apps, it will provide a solid base to understand the Odoo framework core concepts and help to leverage the technical menu to address more complex requirements or issues.

The following topics are discussed in this chapter:

  • Understanding the contacts data model
  • Understanding the users and companies data model
  • Understanding the security-related information repository
  • Understanding the database structure models
  • Understanding the UI-related repository
  • Understanding the configuration properties and company parameters
  • Understanding the messaging data model...

Technical requirements

To follow this chapter, you will only need admin access to an Odoo 15 instance and to enable the developer mode in the Settings | Technical menu. To follow the contacts data model section, the Contacts app must be installed, and to follow the messaging data model section, the Discuss app must be installed.

Understanding the contacts data model

Resource models carry the res. prefix on their technical identifiers (IDs). They hold Odoo's basic master data, such as users, companies, and currencies.

A central model for Odoo is the Partner model, also called Contact, with a technical name of res.partner. It is used anywhere an address, person, or organization needs to be represented. Examples are customers, suppliers, contact persons, invoicing or shipping addresses, employees, and applicants. It is also used to complement the contact data for users and configured companies.

While the res.partner model is provided by the Odoo base module and requires no specific app to be installed, to have the corresponding menus available, the Contacts app needs to be installed. These are the relevant Contact related models:

  • Bank, or res.bank, holds bank identification data, as it turns out to be hard to do business without having a bank involved somehow. Bank data can be browsed from...

Understanding the users and companies data model

Users and companies are central elements of the Odoo data model. They can be accessed in the Settings | Users & Companies menu. The menu options available are listed here:

  • User, or res.users, stores the system users. These have an implicit partner record in the partner_id field, where the name, email, image, and other contact details are stored.
  • Access Group, or res.group, stores the security access groups. This menu is only available with the developer mode enabled. Users belonging to a group will be granted that group's privileges. Groups can inherit other groups, meaning that they will also provide the privileges from these inherited groups.
  • Company, or res.company, stores the organization's details and the company-specific configurations. It has an implicit partner record, holding the address and contact details, stored in the partner_id field. A default company is provided on new databases, with the...

Understanding the security-related information repository

Odoo users are granted access to features through access groups. These access groups hold the definitions of the privileges access they provide. The most relevant access models are listed here:

  • User, or res.users, are the Odoo system users.
  • Access Group, or res.group, are the access groups. Users belong to one or more groups, and each group grants certain privileges.
  • Model Access, or ir.model.access, grants a group create-read-update-delete (CRUD) privileges on a model.
  • Rule, or ir.rule, grants a group CRUD privileges on a subset of the model records, defined by a domain expression. For example, with regular access rights, you can grant write access, and then a record rule can limit certain records to be read-only.

The following diagram provides a simplified view of this part of the data model:

Figure 14.3 – Security-related data model

You have learned about the data...

Understanding the database structure models

The information repository (ir.) models describe the Odoo internal configuration, such as models, fields, and UI. These definitions can be accessed under the Settings | Technical menu.

The data models-related information repository can be found using the Settings | Technical | Database Structure menu. Following the most relevant option in that menu, we have these settings:

  • Decimal Accuracy, or decimal.precision, is used to configure the number of precision digits for different use cases, such as product prices.
  • Model, or ir.model, describes the Odoo installed data models that most of the time map to a database table where the data is stored. It is useful to find the model's XML ID, using the developer menu View Metadata option. The In Apps field is also useful for finding out the modules involved in the model data structure definition.
  • Field, or ir.model.field, stores the model fields defined in the database. This...

Understanding the UI-related information repository

UI elements, such as menus and views, are stored in information repository models. The corresponding data can be accessed through the Settings | Technical | User Interface menu. The most relevant options found there are listed here:

  • Menu, or ir.ui.menu, defines the menu options. These form a hierarchy tree, and the leaf items can trigger an Action, then often provide instructions to display the composition of views.
  • Views, or ir.ui.view, stores the view definitions and their extensions. View types include form, list, Kanban, and QWeb (both for reports and for web page templates).

Under the Settings | Technical | Actions menu, you can find a definition for these UI elements. The most relevant options are listed here:

  • Action, or ir.actions.actions, is the base model that other action types derive from. Usually, you won't need to deal with it directly.
  • Reports, or ir.actions.report, are actions to...

Understanding the configuration properties and company parameters

Another important menu in the technical options is Settings | Technical | User Parameters. You can find two options there: System Parameters and Company Properties.

System Parameters, or ir.config_parameter, stores global configuration options. Some are defaults that can be adjusted, while others are set when some options are selected in the General Settings option. It is a simple key/value list—for example, the web.base.url option stores the Odoo server Uniform Resource Locator (URL) and can be used to create links in email templates.

Company Properties, or ir.property, is where data for multi-company fields is stored. Some fields can have different values depending on the active company. These are also known as property fields.

For example, the partner fields Account Receivable (property_account_receivable_id), relevant for customers, and Account Payable (property_account_payable_id), relevant for suppliers...

Understanding messaging data models

A relevant technical area you might need to work with is the messaging-related models used by the Chatter widget found in many forms. These features are provided by the Discuss module with a technical name of mail, so it needs to be installed before the following menu items are available.

The relevant technical models can be found in the Settings | Technical | Discuss menu. The most important options found there are listed here:

  • Message, or mail.message, stores each message. It is related to a resource, a particular record in a model, through the Mail Thread abstract model.
  • Message Subtype, or mail.message.subtype, is used for each message. The basic subtypes are Note, for internal discussions, Discussion, for outside messages, and Activities, for scheduled activities. These are available for any model. Other subtypes, usually model-specific, can be added to identify different events. This allows the configuring of default subscriptions...

Summary

In this chapter, you learned about the internal structures of the Odoo framework, provided by information repository (ir) and resource (res) models.

The Contacts model is central for storing all people and address data in Odoo, and installing the Contacts app adds the UI for this model and related data. Understanding how company contacts can have child contacts and addresses is important to effectively use Odoo. The Users & Companies menu, from the Settings app, was also discussed, to introduce Users, Access Groups, and Companies. The role of Access Groups to grant access privileges to Users is a key idea here. The remaining relevant elements are exposed in the Technical menu of the Settings app. Let's review some key ideas here addressed in the chapter.

Starting from the top of the menu, the Discuss submenu holds the message and activities data model, and a key idea is how subtypes are used to control automatic notifications. The Actions menu exposes the actions...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Odoo 15 Development Essentials - Fifth Edition
Published in: Feb 2022 Publisher: Packt ISBN-13: 9781800200067
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 $15.99/month. Cancel anytime}