SlideShare a Scribd company logo
How to use grouped()
method in Odoo 18
Enterprise
Enterprise
Introduction
The grouped() method in Odoo is used to group records in a
recordset based on the values of a specific field or set of fields. It
simplifies the process of grouping records and iterating over the
resulting groups, which is especially useful for operations like
reporting, aggregations, or categorizing records.
Let’s discuss the various details of grouped() in Odoo 18 in the
coming slides.
Enterprise
Odoo uses grouped() method with the syntax
Model.grouped(key)
Here, key specifies the field(s) to group by.’
The method returns a dictionary where:
● Keys are the values of the grouping field(s).
● Values are recordsets of the grouped records.
Enterprise
Let’s demonstrate with an example:
Suppose we have the records from the ‘sale.order’ model and we need
to group the record set with the ‘Customer’ field(partner_id).
orders = self.env['sale.order'].search([]) # Fetch all sale orders
grouped_orders = orders.grouped('partner_id')
Here, the variable ‘orders’ contains all the sale orders created so far.
Then, the variable ‘grouped_orders’ contains the grouped data based
on the partner_id field.
Enterprise
grouped() method can be used when
● When you need to categorize or group records based on field
values.
● For performing operations on grouped records, like reporting or
aggregations.
● To simplify and clean up grouping logic in your code.
Always keep in mind that, the fields used in grouped() must be
relational fields or stored fields, as the grouping relies on ORM
lookups. The grouped() method does not support grouping by
computed fields unless they are stored in the database.
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

More from Celine George (20)

PPTX
How to Configure Storno Accounting in Odoo 18 Accounting
Celine George
 
PPTX
Blanket Order in Odoo 17 Purchase App - Odoo Slides
Celine George
 
PPTX
Latest Features in Odoo 18 - Odoo slides
Celine George
 
PPTX
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PPTX
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
PPTX
How to Manage Promotions in Odoo 18 Sales
Celine George
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PPTX
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
PPTX
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
How to Configure Storno Accounting in Odoo 18 Accounting
Celine George
 
Blanket Order in Odoo 17 Purchase App - Odoo Slides
Celine George
 
Latest Features in Odoo 18 - Odoo slides
Celine George
 
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
How to Manage Promotions in Odoo 18 Sales
Celine George
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Controller Request and Response in Odoo18
Celine George
 

Recently uploaded (20)

PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
PPT on the Development of Education in the Victorian England
Beena E S
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPT on the Development of Education in the Victorian England
Beena E S
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
Ad

How to use grouped() method in Odoo 18 - Odoo Slides

  • 1. How to use grouped() method in Odoo 18 Enterprise
  • 2. Enterprise Introduction The grouped() method in Odoo is used to group records in a recordset based on the values of a specific field or set of fields. It simplifies the process of grouping records and iterating over the resulting groups, which is especially useful for operations like reporting, aggregations, or categorizing records. Let’s discuss the various details of grouped() in Odoo 18 in the coming slides.
  • 3. Enterprise Odoo uses grouped() method with the syntax Model.grouped(key) Here, key specifies the field(s) to group by.’ The method returns a dictionary where: ● Keys are the values of the grouping field(s). ● Values are recordsets of the grouped records.
  • 4. Enterprise Let’s demonstrate with an example: Suppose we have the records from the ‘sale.order’ model and we need to group the record set with the ‘Customer’ field(partner_id). orders = self.env['sale.order'].search([]) # Fetch all sale orders grouped_orders = orders.grouped('partner_id') Here, the variable ‘orders’ contains all the sale orders created so far. Then, the variable ‘grouped_orders’ contains the grouped data based on the partner_id field.
  • 5. Enterprise grouped() method can be used when ● When you need to categorize or group records based on field values. ● For performing operations on grouped records, like reporting or aggregations. ● To simplify and clean up grouping logic in your code. Always keep in mind that, the fields used in grouped() must be relational fields or stored fields, as the grouping relies on ORM lookups. The grouped() method does not support grouping by computed fields unless they are stored in the database.
  • 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