Completed
Models
What are Odoo models?
Odoo models are the building blocks of an Odoo application. They are used to define the structure of the database tables that store your data. Each model corresponds to a table in the database, and each record in the table represents an instance of the model. Odoo models are defined using Python code, and they can be customized to fit your specific needs.
Creating a new Odoo model
To create a new Odoo model, follow these steps:
- Log in to your Odoo backend panel.
- Click on the "Settings" menu and select "Technical" from the dropdown.
- Click on "Database Structure" and select "Models".
- Click on the "Create" button to create a new model.
Now let's take a closer look at each option that is available to us when creating a new model.
Model Name
The model name is the name of the model as it will appear in the Odoo user interface. It should be a short, descriptive name that clearly identifies the purpose of the model. The name should be in camel case, with the first letter of each word capitalized. For example, if you are creating a model to store customer information, you might name it "Customer".
Model Description
The model description is a short description of what the model does. It should provide a brief overview of the purpose of the model and its key features. The description should be clear and concise, and it should be written in plain language that is easy to understand.
Module
The module is the name of the module that the model belongs to. It should be the name of the module that you are working on, or it can be a generic name that describes the purpose of the module. For example, if you are creating a model to store customer information, you might name the module "CRM".
Inherits
The inherits option allows you to inherit fields and methods from an existing model. This is useful if you want to create a new model that is based on an existing model but with some additional fields or methods. To inherit from an existing model, simply select the model from the dropdown list.
Model Fields
The model fields are the fields that are used to store data in the model. They are defined using Python code, and they can be customized to fit your specific needs. To add a new field, click on the "Add an item" button and select the type of field that you want to add.
Here are some of the most common field types:
- Char: A short text field that can contain up to a certain number of characters.
- Text: A long text field that can contain multiple lines of text.
- Integer: A field that stores an integer value.
- Float: A field that stores a floating-point number.
- Boolean: A field that stores a boolean value (True or False).
- Date: A field that stores a date value.
- Datetime: A field that stores a date and time value.
- Many2one: A field that stores a reference to another record in another model.
- One2many: A field that stores multiple references to records in another model.
- Many2many: A field that stores multiple references to records in another model.
Field Name
The field name is the name of the field as it will appear in the Odoo user interface. It should be a short, descriptive name that clearly identifies the purpose of the field. The name should be in snake case, with all letters in lowercase and words separated by underscores
There are no comments for now.