Odoo is basically a web-based open source & modular-based framework/software which include multiple business solutions like “CRM”, “POS”, “E-Commerce”, “ERP”, “Manufacturing”, “Inventory Management”, “Billing & Accounting” and “Project Management”.
Also it follows the ORM structure.
In our last blog we studied how to create a new module in Odoo.
As we mentioned above, Odoo follows the ORM(“Object Relational Mapping”) structure which manipulates data from the database into Object-Oriented form.
Classes are represented as tables and fields are represented as columns in Odoo.
now. Read More
So in this article we will talk about Odoo fields.
What is the Odoo field?
Odoo is a modular based framework.
So everything is managed by modules and classes.
Odoo Fields are managed by field class.
Attributes of Odoo Fields
- string: It represents the label of Odoo fields eg: string=” Webkul”
- help: It represents the description of Odoo fields eg: help=” This is Webkul type field”
- readonly: If true then the Odoo fields not editable eg: readonly=True/False
- invisible: If true then the Odoo fields not visible to the user eg: invisible=True/False
- required: If true then the Odoo fields compulsory for the user eg: required=True/False
- copy: If true then the record will be copied if any record is duplicate eg: copy=True/False
- index: If true then the field is indexed in database eg: index=True/False
- store: If true then the field is stored in the database(For computed/related fields only) eg: store=True/False
- default: It is used to set the value of the field, If a value is passed inside this attribute then during record create that value will be set inside the record.
- group: If the comma-separated list of groups XML ids passed then it will restrict the users of these groups to access these fields.
And there are many other attributes which are present with the Odoo fields.
Where are these fields stored in Odoo?
In Odoo fields are also stored in an object form. All the fields of Odoo are stored inside the “ir.model.fields” and you can also find the list of fields associated with the models which are also present as records in Odoo inside the “ir.model” model.
How many types of fields in Odoo?
In Odoo data is stored in the simple, relational, and computed form.
Currently, in Odoo, there are three major types of fields which are given below,
It contains the fields which are stored in the simplified form.
This field stores value in 0/1(False/True) and represented by class Boolean.
If false then it stores 0 and if true then value will be 1.
This field stores value in string form and represented by class Char.
This field stores value in numeric form and represented by class Integer.
This field stores value in decimal form and represented by class Float.
This field stores value in binary form.
It store the attachments like file, images, musical files, etc, and represented by class Binary.
This field stores value in string form and it is used to present the data in html form. HTML field is represented by class HTML. Parameters like sanitize, sanitize_tags, sanitize_style etc, are used inside the html fields,
This field stores value in binary form and used to present the data in image form. The image field is inherited by binary class and represented by class Image. Parameters like max_width, max_height etc, are used inside the image fields,
This field stores value in decimal form and used to present the money along with the currency and represented by class Monetary. Parameters currency field(a many2one field of res.currency object) etc and used inside the monetary fields,
This field stores value in string form and this field helps to provide the selection to the user. Selection field is represented by class Selection. It uses the below attribute to represent the selection to the user,
- selection = [(‘a’, ‘A’), (‘b’, ‘B’)]
- selection_add = [(‘c’, ‘C’), (‘b’,)]
This field stores value in string form. Basically this field helps to store the long text at Odoo end and represented by class Text.
This field stores value in object form and used to present the date view to the user. Which helps the user to select the date and represented by class Date.
This field stores value in object form. It present the datetime view to the user. This helps the user to select the date and time as well and represented by class Datetime.
It contains the fields which provide the relation between the two tables and represented by the Relational class.
This field stores recordset(0 or 1 record for the related table). The “comodel_name” attribute helps to define the target model and represented by class Many2one.
These field store recordsets (0 or 1 or more records for the related table). “comodel_name” attribute helps to define the target model and represented by class Many2many.
These field store recordsets (0 or 1 or more records for the related table). “comodel_name” attribute helps to define the target model and represented by class One2many.
Dynamically typed field.
It stores the subfield of tables. It uses the related attribute.
This field helps to store value as per the requirement. This field uses the compute attribute.
We Would Love to Hear From You!
Hope you find the blog informative! Please feel free to share your feedback in the comments below.
Also, check our store page to go through our other modules.
If you still have any issues/queries then please raise a ticket at https://webkul.uvdesk.com/en/customer/create-ticket/
For any doubt contact us at [email protected].
Thanks for paying attention!!