Reader small image

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

Product typeBook
Published inFeb 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781800200067
Edition5th Edition
Languages
Tools
Right arrow
Author (1)
Daniel Reis
Daniel Reis
author image
Daniel Reis

Daniel Reis has a degree in applied mathematics and an MBA. He has had a long career in the IT industry, mostly as a consultant implementing business applications in a variety of sectors. He has been working with Odoo (OpenERP at the time) since 2010 and is an active contributor to the Odoo Community Association (OCA), where he also serves as a board member. He is the managing director of Open Source Integrators, a leading open source and Odoo consultancy firm.
Read more about Daniel Reis

Right arrow

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 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 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 2022Publisher: PacktISBN-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.
undefined
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 €14.99/month. Cancel anytime

Author (1)

author image
Daniel Reis

Daniel Reis has a degree in applied mathematics and an MBA. He has had a long career in the IT industry, mostly as a consultant implementing business applications in a variety of sectors. He has been working with Odoo (OpenERP at the time) since 2010 and is an active contributor to the Odoo Community Association (OCA), where he also serves as a board member. He is the managing director of Open Source Integrators, a leading open source and Odoo consultancy firm.
Read more about Daniel Reis