SlideShare a Scribd company logo
4
Most read
How to define Related
field in Odoo 17
Enterprise
Introduction
Enterprise
In Odoo, the fields can be made as related using the ‘related’
keyword.
The related attribute is used in field definitions to establish a
relationship between models and automatically fetch the value
from a related model's field.
It provides a way to reference and display fields from related
models without having to create a separate field and write
code to synchronize the values manually.
Enterprise
The basic syntax for defining a related field is
related_field = fields.FieldType(related='related.field.path',
string='Field Label')
where
● FieldType: The type of the field you are referencing
● related.field.path: The dot-separated path to the related
field. Ie, it will be of the syntax
related_model_id.field_name. This path’s first part
related_model_id will be usually a Many2one field name in
the same model. And field_name is the field name defined
in that comodel.
● string: The label for the field in the user interface.
Enterprise
To illustrate the usage of related fields, let’s create a simple model
to store the details of an Student Exam Registration. The basic
details are added in the model including a Many2one relational
field student_id.
class ExamRegister(models.Model):
_name = ‘exam.register'
_description = Exam Register’
student_id = fields.Many2one(string="Student Name",
required=True)
student_mobile =
fields.Char(string="Mobile",related=’student_id.mobile’)
Enterprise
Usually, related fields are set to read only because they are
intended to reflect data from another model and not be edited
directly.
The related fields are not stored in the database. To improve read
performance, it can be forced to save in the database by using the
attribute store = True while defining the field.
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
How to Define One2Many Field in Odoo 15
PPTX
How to Add a many2many Relational Field in Odoo 17
DOCX
Excel analysis assignment this is an independent assignment me
PPTX
What are the Basic Fields in the Odoo 17 ERP
PPTX
Many2One Fields in Odoo 16
PDF
Python Strings Format
PPTX
How to Show Sample Data in Tree and Kanban View in Odoo 17
PPTX
Relations Between Models - many2one
How to Define One2Many Field in Odoo 15
How to Add a many2many Relational Field in Odoo 17
Excel analysis assignment this is an independent assignment me
What are the Basic Fields in the Odoo 17 ERP
Many2One Fields in Odoo 16
Python Strings Format
How to Show Sample Data in Tree and Kanban View in Odoo 17
Relations Between Models - many2one

Similar to How to define Related field in Odoo 17 - Odoo 17 Slides (20)

PPTX
How to use _name_search() method in Odoo 18
PPTX
Many2Many in Odoo 16
PDF
How to Build Dynamic Forms in Angular Directive with a Backend
PPT
Lec2_Information Integration.ppt
PPTX
Relations Between Models-many2many
PPTX
C# XML documentation
PPTX
What is Property Fields in Odoo 17 ERP Module
DOCX
csharp.docx
PDF
Detecting Aspect Intertype Declaration Interference at Aspect Oriented Design...
PDF
An effective citation metadata extraction process based on BibPro parser
PPTX
Field Parameters in Odoo 18 - Odoo 18 Slides
PPT
CSharp_03_ClassesStructs_and_introduction
PDF
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
PPTX
Name Search() Function in Odoo 16
PPTX
Python Constraints & Model Constraints in Odoo 15
PPTX
Chapter 2 c#
PDF
AUTOMATED SHORT ANSWER GRADER USING FRIENDSHIP GRAPHS
PDF
AUTOMATED SHORT ANSWER GRADER USING FRIENDSHIP GRAPHS
PPTX
Sitecore Knowledge Transfer 2018 (Template) day-2
PPT
How to use _name_search() method in Odoo 18
Many2Many in Odoo 16
How to Build Dynamic Forms in Angular Directive with a Backend
Lec2_Information Integration.ppt
Relations Between Models-many2many
C# XML documentation
What is Property Fields in Odoo 17 ERP Module
csharp.docx
Detecting Aspect Intertype Declaration Interference at Aspect Oriented Design...
An effective citation metadata extraction process based on BibPro parser
Field Parameters in Odoo 18 - Odoo 18 Slides
CSharp_03_ClassesStructs_and_introduction
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Name Search() Function in Odoo 16
Python Constraints & Model Constraints in Odoo 15
Chapter 2 c#
AUTOMATED SHORT ANSWER GRADER USING FRIENDSHIP GRAPHS
AUTOMATED SHORT ANSWER GRADER USING FRIENDSHIP GRAPHS
Sitecore Knowledge Transfer 2018 (Template) day-2
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
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Institutional Correction lecture only . . .
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Lesson notes of climatology university.
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Cell Types and Its function , kingdom of life
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Pharma ospi slides which help in ospi learning
PDF
RMMM.pdf make it easy to upload and study
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
01-Introduction-to-Information-Management.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
Module 4: Burden of Disease Tutorial Slides S2 2025
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Institutional Correction lecture only . . .
Microbial diseases, their pathogenesis and prophylaxis
O5-L3 Freight Transport Ops (International) V1.pdf
Lesson notes of climatology university.
O7-L3 Supply Chain Operations - ICLT Program
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Cell Types and Its function , kingdom of life
Sports Quiz easy sports quiz sports quiz
Pharma ospi slides which help in ospi learning
RMMM.pdf make it easy to upload and study
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
PPH.pptx obstetrics and gynecology in nursing
Microbial disease of the cardiovascular and lymphatic systems
01-Introduction-to-Information-Management.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?

How to define Related field in Odoo 17 - Odoo 17 Slides

  • 1. How to define Related field in Odoo 17 Enterprise
  • 2. Introduction Enterprise In Odoo, the fields can be made as related using the ‘related’ keyword. The related attribute is used in field definitions to establish a relationship between models and automatically fetch the value from a related model's field. It provides a way to reference and display fields from related models without having to create a separate field and write code to synchronize the values manually.
  • 3. Enterprise The basic syntax for defining a related field is related_field = fields.FieldType(related='related.field.path', string='Field Label') where ● FieldType: The type of the field you are referencing ● related.field.path: The dot-separated path to the related field. Ie, it will be of the syntax related_model_id.field_name. This path’s first part related_model_id will be usually a Many2one field name in the same model. And field_name is the field name defined in that comodel. ● string: The label for the field in the user interface.
  • 4. Enterprise To illustrate the usage of related fields, let’s create a simple model to store the details of an Student Exam Registration. The basic details are added in the model including a Many2one relational field student_id. class ExamRegister(models.Model): _name = ‘exam.register' _description = Exam Register’ student_id = fields.Many2one(string="Student Name", required=True) student_mobile = fields.Char(string="Mobile",related=’student_id.mobile’)
  • 5. Enterprise Usually, related fields are set to read only because they are intended to reflect data from another model and not be edited directly. The related fields are not stored in the database. To improve read performance, it can be forced to save in the database by using the attribute store = True while defining the field.
  • 6. 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