SlideShare a Scribd company logo
6
Most read
10
Most read
13
Most read
Basic Fields in Odoo 17
Enterprise
Introduction
Enterprise
Odoo supports several fields for better data handling with
specific options for each type. Some of the basic field in Odoo
are Integers , float , char , Selection , Many2one, One2many
,Many2many , Date , Datetime etc...
Enterprise
Types of Fields
● Simple Types
● Relation Types
● Functional Types
Enterprise
● Simple Types are Integer, Char, String, etc.
● Relation Types represent the relations between objects
like Many2one, One2many, and Many2many.
● Functional fields are not stored in the database. They are
special fields because the fields are calculated in real-
time based on other fields of the view.
Enterprise
Firstly, we need to import package fields.
from odoo import models, fields
For example:
Enterprise
Boolean: Store boolean values True and False
bool = fields.Boolean()
bool = fields.Boolean(string="Active", default=True)
Enterprise
Char: Store string or characters with length.
● Parameter:
size: Data will be trimmed into the specified size.
name = fields.Char()
name = fields.Char(string="Name", required=True)
proxy_ip = fields.Char(string='IP Address', size=45)
Enterprise
Text: Used to store long texts.
text = fields.Text()
notes = fields.Text(string='Terms and Conditions')
Enterprise
Integer: Fields to store integer values. Null value is not
allowed. If there is no value then it returns zero.
num = fields.Integer()
Enterprise
Float: Used to store float values. Null value is not supported. If
there is no value, it returns 0.0.
● Parameter:
digits: it defines the precision and scale of the
number. Scale is the number of digits after the decimal
point and precision is the total number of significant
digits in the number.
float_num = fields.Float()
amount = fields.Float(string="Amount", digits=(6, 2))
Enterprise
Date: Date field stores date. The field has some helpers
● context_today: Returns current day date string based on
timezone
● today: Returns current system date string
● from_string: Returns datetime.date() from string
● to_string: Returns date string from datetime.date
today = fields.Date.today()
fields.Date.context_today(self)
fields.Date.context_today(self,timestamp=datetime.datetime.now())
fields.Date.from_string(fields.Date.today())
fields.Date.to_string(datetime.datetime.today())
Enterprise
DateTime: It stores date and time in the same field. The field
has some helpers.
● context_timestamp: Returns current day date string
based on timezone
● now: Returns current system date string
● From_string: Returns datetime.date() from string
● to_string: Returns date string from datetime.date
fields.Datetime.context_timestamp(self,timestamp=datetime.datetime.now()
fields.Datetime.now()
fields.Datetime.from_string(fields.Datetime.now())
fields.Datetime.to_string(datetime.datetime.now())
Enterprise
Binary: field stores the encoded file in base64 in column bytea.
file = fields.Binary()
Enterprise
Selection: Field stores text but the purpose is a selection
widget.
● selection: a list of tuple or a callable name that take
recordset as input
● size: the option size=1 is mandatory when using indexes
that are integers.
select = fields.Selection([('a', 'A')])
select = fields.Selection(selection=[('a', 'A')])
select = fields.Selection(selection='_function_name')
Enterprise
Selection_add: when you are trying to extend a model if you
want to add more possible values to an existing selection field
you may use the selection_add keyword argument:
class TestModel(models.Model):
_inherit = 'test.model'
type = fields.Selection(selection_add=[('b', 'B'),
('c', 'C')])
Enterprise
Reference: Store an arbitrary reference to a model and a row.
● selection: a list of tuple or a callable name that take
recordset as input.
refer = fields.Reference([('model.name','String_string')])
refer = fields.Reference(selection=[('model.name','String_string')])
Enterprise
Html: Stores HTML and used as HTML Widget.
html_wid = fields.Html()
Enterprise
Many2one: Associates this object to a parent object via this
field.
● comodel_name: name of the related model
● Delegate: if it is True, then it will make fields of the target
model accessible from the current model.
user = fields.Many2one('res.users')
user = fields.Many2one(comodel_name='res.users')
user = fields.Many2one(comodel_name='res.partner',
delegate=True)
Enterprise
One2many: Stores a relation against many rows of co-model
● comodel_name: name of the related model.
● inverse_name: the relational column of the related
model.
mod_ids = fields.One2many('res.users', 'rel_id')
mod_ids = fields.One2many(comodel_name='res.users',
inverse_name='rel_id')
Enterprise
Many2many: Field stores multiple rows of a relation.
● comodel_name: name of the related model.
● relation: name of the relational table.
● columns1: left column name of the relational table.
● columns2: right column name of the relational table.
mod_ids = fields.Many2many('res.partner’)
mod_ids = fields.Many2many(comodel_name='res.partner',
relation='table_name',
column1='col_name',
column2='other_col_name')
Enterprise
The common parameters:
● help: Provide a description of how the field should be
used.
● ondelete: To handle deletions in a related record.
Values are: 'restrict', 'no action', 'cascade', 'set null', and
'set default'.
● readonly: If value = True, then the user cannot edit the
field.
● required: The value of this argument is True, then the
field can’t be empty before saving.
Enterprise
● size: The size of the field in the database can specify as a
character or integer.
● string: Set label for the field.
● translate: If the value is True, then the content of the
field should be translated.
● invisible: Hide fields from view if the value is 1.
● relation: Used to refer another table. Most commonly
used in related and function field types.
● compute: used to call a function to get the value of the
field. The value of the compute will be the name of a
function
For More Info.
Check our company website for related
blogs and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com

More Related Content

PPTX
Field Parameters in Odoo 18 - Odoo 18 Slides
PPTX
Automatic and Reserved Fields in odoo - Odoo Slides
PDF
Odoo Technical Concepts Summary
PPTX
Automatic and Reserved Fields in Odoo 18
PDF
Impact of the New ORM on Your Modules
PPTX
Model Fields in Odoo 15
PPTX
How to Convert Many2One Field into Selection field In Odoo 17
PDF
PyCon 2010 SQLAlchemy tutorial
Field Parameters in Odoo 18 - Odoo 18 Slides
Automatic and Reserved Fields in odoo - Odoo Slides
Odoo Technical Concepts Summary
Automatic and Reserved Fields in Odoo 18
Impact of the New ORM on Your Modules
Model Fields in Odoo 15
How to Convert Many2One Field into Selection field In Odoo 17
PyCon 2010 SQLAlchemy tutorial

Similar to What are the Basic Fields in the Odoo 17 ERP (20)

PDF
Odoo - From v7 to v8: the new api
PDF
Odoo from 7.0 to 8.0 API
PPT
database1
PPTX
How to Make a Field Storable in Odoo 17 - Odoo Slides
PPTX
Many2One Fields in Odoo 16
PPTX
Difference between write and update in odoo 18
PDF
PPT. Introduction & Views - Documentation.pdf
PPTX
How to Add a many2many Relational Field in Odoo 17
PDF
ORM in Django
PDF
Database madness with_mongoengine_and_sql_alchemy
PPTX
Model Attributes in Odoo 18 - Odoo 18 Slides
PPT
Spsl vi unit final
PPT
Spsl v unit - final
PPTX
What is Property Fields in Odoo 17 ERP Module
PPTX
Django: Advanced Models
PDF
Presentation of the new OpenERP API. Raphael Collet, OpenERP
PPTX
Django - sql alchemy - jquery
PPT
Django Models
PDF
The State of NoSQL
PPTX
Lets code classes_python
Odoo - From v7 to v8: the new api
Odoo from 7.0 to 8.0 API
database1
How to Make a Field Storable in Odoo 17 - Odoo Slides
Many2One Fields in Odoo 16
Difference between write and update in odoo 18
PPT. Introduction & Views - Documentation.pdf
How to Add a many2many Relational Field in Odoo 17
ORM in Django
Database madness with_mongoengine_and_sql_alchemy
Model Attributes in Odoo 18 - Odoo 18 Slides
Spsl vi unit final
Spsl v unit - final
What is Property Fields in Odoo 17 ERP Module
Django: Advanced Models
Presentation of the new OpenERP API. Raphael Collet, OpenERP
Django - sql alchemy - jquery
Django Models
The State of NoSQL
Lets code classes_python
Ad

More from Celine George (20)

PPTX
How to Implement OWL Notification Service in Odoo 18
PPTX
Tracking Profit Margins in Sales Orders with Odoo 18
PPTX
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
PPTX
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
PPTX
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
PPTX
How to Add New Applicants in Odoo 18 Recruitment
PPTX
How to Analyze the Recruitment Process in Odoo 18 Recruitment
PPTX
How to Manage Referral Reporting in Odoo 18 Referrals
PPTX
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PPTX
Odoo 18 Sales_ Managing Quotation Validity
PPTX
How to Manage Global Discount in Odoo 18 POS
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
How to Implement OWL Notification Service in Odoo 18
Tracking Profit Margins in Sales Orders with Odoo 18
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
How to Add New Applicants in Odoo 18 Recruitment
How to Analyze the Recruitment Process in Odoo 18 Recruitment
How to Manage Referral Reporting in Odoo 18 Referrals
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
Revamp in MTO Odoo 18 Inventory - Odoo Slides
How to Manage Starshipit in Odoo 18 - Odoo Slides
How to Manage Bill Control Policy in Odoo 18
How to Manage Loyalty Points in Odoo 18 Sales
Odoo 18 Sales_ Managing Quotation Validity
How to Manage Global Discount in Odoo 18 POS
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Tips Management in Odoo 18 POS - Odoo Slides
How to Close Subscription in Odoo 18 - Odoo Slides
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
How to Track Skills & Contracts Using Odoo 18 Employee
Ad

Recently uploaded (20)

PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Computing-Curriculum for Schools in Ghana
PDF
Sports Quiz easy sports quiz sports quiz
PDF
RMMM.pdf make it easy to upload and study
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
01-Introduction-to-Information-Management.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Complications of Minimal Access Surgery at WLH
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Final Presentation General Medicine 03-08-2024.pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Anesthesia in Laparoscopic Surgery in India
VCE English Exam - Section C Student Revision Booklet
Computing-Curriculum for Schools in Ghana
Sports Quiz easy sports quiz sports quiz
RMMM.pdf make it easy to upload and study
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPH.pptx obstetrics and gynecology in nursing
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Supply Chain Operations Speaking Notes -ICLT Program
01-Introduction-to-Information-Management.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Complications of Minimal Access Surgery at WLH
O7-L3 Supply Chain Operations - ICLT Program
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
GDM (1) (1).pptx small presentation for students
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Microbial disease of the cardiovascular and lymphatic systems
Final Presentation General Medicine 03-08-2024.pptx

What are the Basic Fields in the Odoo 17 ERP

  • 1. Basic Fields in Odoo 17 Enterprise
  • 2. Introduction Enterprise Odoo supports several fields for better data handling with specific options for each type. Some of the basic field in Odoo are Integers , float , char , Selection , Many2one, One2many ,Many2many , Date , Datetime etc...
  • 3. Enterprise Types of Fields ● Simple Types ● Relation Types ● Functional Types
  • 4. Enterprise ● Simple Types are Integer, Char, String, etc. ● Relation Types represent the relations between objects like Many2one, One2many, and Many2many. ● Functional fields are not stored in the database. They are special fields because the fields are calculated in real- time based on other fields of the view.
  • 5. Enterprise Firstly, we need to import package fields. from odoo import models, fields For example:
  • 6. Enterprise Boolean: Store boolean values True and False bool = fields.Boolean() bool = fields.Boolean(string="Active", default=True)
  • 7. Enterprise Char: Store string or characters with length. ● Parameter: size: Data will be trimmed into the specified size. name = fields.Char() name = fields.Char(string="Name", required=True) proxy_ip = fields.Char(string='IP Address', size=45)
  • 8. Enterprise Text: Used to store long texts. text = fields.Text() notes = fields.Text(string='Terms and Conditions')
  • 9. Enterprise Integer: Fields to store integer values. Null value is not allowed. If there is no value then it returns zero. num = fields.Integer()
  • 10. Enterprise Float: Used to store float values. Null value is not supported. If there is no value, it returns 0.0. ● Parameter: digits: it defines the precision and scale of the number. Scale is the number of digits after the decimal point and precision is the total number of significant digits in the number. float_num = fields.Float() amount = fields.Float(string="Amount", digits=(6, 2))
  • 11. Enterprise Date: Date field stores date. The field has some helpers ● context_today: Returns current day date string based on timezone ● today: Returns current system date string ● from_string: Returns datetime.date() from string ● to_string: Returns date string from datetime.date today = fields.Date.today() fields.Date.context_today(self) fields.Date.context_today(self,timestamp=datetime.datetime.now()) fields.Date.from_string(fields.Date.today()) fields.Date.to_string(datetime.datetime.today())
  • 12. Enterprise DateTime: It stores date and time in the same field. The field has some helpers. ● context_timestamp: Returns current day date string based on timezone ● now: Returns current system date string ● From_string: Returns datetime.date() from string ● to_string: Returns date string from datetime.date fields.Datetime.context_timestamp(self,timestamp=datetime.datetime.now() fields.Datetime.now() fields.Datetime.from_string(fields.Datetime.now()) fields.Datetime.to_string(datetime.datetime.now())
  • 13. Enterprise Binary: field stores the encoded file in base64 in column bytea. file = fields.Binary()
  • 14. Enterprise Selection: Field stores text but the purpose is a selection widget. ● selection: a list of tuple or a callable name that take recordset as input ● size: the option size=1 is mandatory when using indexes that are integers. select = fields.Selection([('a', 'A')]) select = fields.Selection(selection=[('a', 'A')]) select = fields.Selection(selection='_function_name')
  • 15. Enterprise Selection_add: when you are trying to extend a model if you want to add more possible values to an existing selection field you may use the selection_add keyword argument: class TestModel(models.Model): _inherit = 'test.model' type = fields.Selection(selection_add=[('b', 'B'), ('c', 'C')])
  • 16. Enterprise Reference: Store an arbitrary reference to a model and a row. ● selection: a list of tuple or a callable name that take recordset as input. refer = fields.Reference([('model.name','String_string')]) refer = fields.Reference(selection=[('model.name','String_string')])
  • 17. Enterprise Html: Stores HTML and used as HTML Widget. html_wid = fields.Html()
  • 18. Enterprise Many2one: Associates this object to a parent object via this field. ● comodel_name: name of the related model ● Delegate: if it is True, then it will make fields of the target model accessible from the current model. user = fields.Many2one('res.users') user = fields.Many2one(comodel_name='res.users') user = fields.Many2one(comodel_name='res.partner', delegate=True)
  • 19. Enterprise One2many: Stores a relation against many rows of co-model ● comodel_name: name of the related model. ● inverse_name: the relational column of the related model. mod_ids = fields.One2many('res.users', 'rel_id') mod_ids = fields.One2many(comodel_name='res.users', inverse_name='rel_id')
  • 20. Enterprise Many2many: Field stores multiple rows of a relation. ● comodel_name: name of the related model. ● relation: name of the relational table. ● columns1: left column name of the relational table. ● columns2: right column name of the relational table. mod_ids = fields.Many2many('res.partner’) mod_ids = fields.Many2many(comodel_name='res.partner', relation='table_name', column1='col_name', column2='other_col_name')
  • 21. Enterprise The common parameters: ● help: Provide a description of how the field should be used. ● ondelete: To handle deletions in a related record. Values are: 'restrict', 'no action', 'cascade', 'set null', and 'set default'. ● readonly: If value = True, then the user cannot edit the field. ● required: The value of this argument is True, then the field can’t be empty before saving.
  • 22. Enterprise ● size: The size of the field in the database can specify as a character or integer. ● string: Set label for the field. ● translate: If the value is True, then the content of the field should be translated. ● invisible: Hide fields from view if the value is 1. ● relation: Used to refer another table. Most commonly used in related and function field types. ● compute: used to call a function to get the value of the field. The value of the compute will be the name of a function
  • 23. For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com