SlideShare a Scribd company logo
10
Most read
13
Most read
14
Most read
Report Actions In Odoo
17
Enterprise
Introduction
Enterprise
In Odoo 17, report actions allow us to define and manage various
reports within the system. These reports can be generated in
different formats such as PDF, Excel, and HTML, and can be triggered
from different parts of the application.
That is, Report actions are basically used for triggering the printing
of a report.
Enterprise
Let’s create a module named sale_report_custom which simply
creates a new sub menu in Sales module’s Reporting menu, opens a
wizard which asks for the customer and a sale amount. With the
entered details, a PDF report will be generated for the selected
customer’s all Sale orders which has the sale value above the amount
we enter. The module structure is as
Enterprise
First, to create a menu, type the xml code in the file sale_order_form.xml
under views directory.
<menuitem id="menu_show_wizard" sequence="5"
action="sale_report_wizard_action"
name="Sale Report PDF" parent="sale.menu_sale_report"/>
The menu can be seen as
Enterprise
For defining the action sale_report_wizard_action for the menu, create a
wizard using Transient model, define its views and make the wizard open
on this menu button click. All the python and xml codes for the wizard is
saved in the wizards directory and the python files must be imported
inside the __init__ under it. The python file for defining the class can be as
from odoo import fields, models
class SaleReportWizard(models.TransientModel):
_name = 'sale.report.wizard'
sale_amount = fields.Float("Sale Amount Above")
partner_id = fields.Many2one('res.partner', "Customer")
Enterprise
Now, create the basic form view for the wizard which displays those two
fields sale_amount and partner_id. Also give this form view’s id as the
view_id for the action that we have given for the previous menu added in
the Sale module. The xml code for the action can be as
<record id="sale_report_wizard_action" model="ir.actions.act_window">
<field name="name">Custom Wizard</field>
<field name="res_model">sale.report.wizard</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="sale_report_wizard_view_form"/>
<field name="context">{}</field>
<field name="target">new</field>
</record>
The id of the form view is sale_report_wizard_view_form here. This will
make the wizard to open.
Enterprise
On clicking the menu, the wizard will be shown as
We need to select the marked two fields and click on the Print PDF
button. For that button, we set the type as object, just name it as
print_report and define a python method with the same name which will
generate the PDF report.
Enterprise
In Odoo, ir.actions.report is used to define and manage reports. This
model allows us to create, configure, and customize reports that can be
rendered in various formats such as PDF, HTML, and XLSX. The
parameters for ir.actions.report include several fields that define the
behavior and appearance of the reports.
For a PDF report to function, the report action we created in xml code is
as
<record id="action_custom_report_saleorder" model="ir.actions.report">
<field name="name">Sale Details Custom Report</field>
<field name="model">sale.order</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">sale_report_custom.custom_sale_report</field>
<field name="report_file">sale_report_customcustom_sale_report</field>
<field name="print_report_name">'Custom Sale Report'</field>
</record>
Enterprise
Here are the key parameters:
● id give a unique id for the record
● name specifies the name of the report action. It is of char type.
● model is the Odoo model on which the report is based.
● report_type is the type of the report. Common types include "qweb-
pdf" for PDF reports, "qweb-html" for HTML reports and "qweb-text" for
plain text reports
● report_name is the technical name of the report template.
● print_report_name can be set which is a Python expression to
dynamically set the report's file name when printed. Or simply we can set
its value of char type in single quote.
● binding_model_id is the model to which the report is bound
● binding_type determines where the report action will appear.
● paperformat_id can also be set which specifies the paper format for the
report, such as A4, A5, etc
● attachment uses A Python expression for the report attachment file
name. If set, the report will be stored as an attachment.
Enterprise
Now, define the method print_report in the wizard’s model as
def print_report(self):
vals = []
sale_order = self.env['sale.order'].search([(
'partner_id', '=',self.partner_id.id),('amount_total','>=',self.sale_amount)])
for order in sale_order:
vals.append({'name': order.name,'date': order.date_order,
'amount_total': order.amount_total,'sales_person':order.user_id.name,
})
data = {
'ids': self.ids,
'model': self._name,
'vals': vals,
'sale_amount': self.sale_amount,
'partner_id': self.partner_id.name
}
return self.env.ref('sale_report_custom.
action_custom_report_saleorder').report_action(self, data=data)
Enterprise
Here what we are doing is:
● Set up a list vals as blank initially
● Searched all the orders with the condition matched with the values
given in wizard for the Customer and Amount
● Then appended all those order’s details to vals using append() with the
key details name, date, amount_total and sales_person.
● Added the data dictionary with vals as one key and other details such
as the model, sale_amount, etc
● At last, we took the reference of the xml report action using
self.env.ref() with the parameter
sale_report_custom.action_custom_report_saleorder where the first
part before dot(.) is the module name and the second part after it is the
xml id of the report action. This will check for the report_name
custom_sale_report specified in the action.
● Then using the report_action() method, we passed the data dictionary
Enterprise
Next, we need to create a Qweb Template which designs the PDF
report content. For that, start typing the template content using
<template id="custom_sale_report">
<t t-call="web.html_container">
<t t-call="web.external_layout">
A unique id is needed for the template. Then call the
web.html_container to handle and render HTML content within
QWeb templates securely and efficiently.
web.external_layout serves as a standard layout for reports.
This layout typically includes elements like the company logo, header,
footer, and general styling that should be consistent across all
documents.
Enterprise
Give the heading for the Report using any of the heading tags as
<center>
<h4><u>Customized Sale Report</u></h4>
</center>
Now, give the Customer Name and Sale Amount we gave in wizard to
the left as
<div style="text-align: left;">
<strong><p>Customer Name: <span t-esc="partner_id"/></p></strong>
</div>
<div style="text-align: left;">
<strong><p>Sale Amount Greater than
<span t-esc="sale_amount"/></p></strong></div>
</div>
Enterprise
And design a table with Headings and Body part as
<table class="table table-sm o_main_table table-striped mt-4">
<thead style="display: table-row-group">
<tr>
<th name="th_order_no" class="text-start">Order No</th>
<th name="th_brand" class="text-start">Order Date</th>
<th name="th_brand" class="text-start">Amount</th>
<th name="th_quantity" class="text-end">Sales person</th>
</tr>
</thead>
<tbody class="sale_tbody">
<t t-foreach="vals" t-as="order">
<tr t-att-class="'bg-200 fw-bold o_line_section'">
<td name="order_name"><span t-att-style="style" t-esc="order['name']"/></td>
<td name="order_date"><span t-att-style="style" t-esc="order['date']"/></td>
<td name="order_total"><span t-att-style="style" t-esc="order['amount_total']"/></td>
<td name="order_salesperson"><span t-att-style="style"
t-esc="order['sales_person']"/></td>
</tr>
</t></tbody>
</table>
Enterprise
Now, when we fill the wizard as below and click on Print PDF button,
Enterprise
The PDF Report will get downloaded/ printed as
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

PDF
Linux Presentation
PPTX
Lateral Movement with PowerShell
PPTX
AtoM's Command Line Tasks - An Introduction
PPTX
File permissions
PPTX
(Ab)Using GPOs for Active Directory Pwnage
PPTX
Flask – Python
PDF
The Unintended Risks of Trusting Active Directory
PDF
LDAP Injection
Linux Presentation
Lateral Movement with PowerShell
AtoM's Command Line Tasks - An Introduction
File permissions
(Ab)Using GPOs for Active Directory Pwnage
Flask – Python
The Unintended Risks of Trusting Active Directory
LDAP Injection

What's hot (20)

ODP
Java EE Pattern: Entity Control Boundary Pattern and Java EE
PDF
Automated Discovery of Deserialization Gadget Chains
PDF
Secure coding presentation Oct 3 2020
PDF
스프링 시큐리티 구조 이해
PPT
Linux file system
PPTX
Proxy Design Patterns
PPTX
Sonatype nexus 로 docker registry 관리하기
PPTX
Elementor - WordPress WYSIWYG Page Builder
DOC
Comandos Ms Dos.Doc
PDF
Regular Expression Injection
PPT
Dynamic HTML Event Model
PPTX
XSS - Do you know EVERYTHING?
PDF
Understanding Windows Access Token Manipulation
PPT
BP204 - Take a REST and put your data to work with APIs!
PDF
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
PPTX
Infrastructure as Code with Terraform.pptx
PDF
Linux: LVM
PDF
Integrating React.js Into a PHP Application
ODP
Logical Volume Manager. An Introduction
Java EE Pattern: Entity Control Boundary Pattern and Java EE
Automated Discovery of Deserialization Gadget Chains
Secure coding presentation Oct 3 2020
스프링 시큐리티 구조 이해
Linux file system
Proxy Design Patterns
Sonatype nexus 로 docker registry 관리하기
Elementor - WordPress WYSIWYG Page Builder
Comandos Ms Dos.Doc
Regular Expression Injection
Dynamic HTML Event Model
XSS - Do you know EVERYTHING?
Understanding Windows Access Token Manipulation
BP204 - Take a REST and put your data to work with APIs!
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
Infrastructure as Code with Terraform.pptx
Linux: LVM
Integrating React.js Into a PHP Application
Logical Volume Manager. An Introduction
Ad

Similar to Report Actions In Odoo 17 - Odoo 17 Slides (20)

PPTX
How to Customize POS Receipts in the Odoo 17
PPTX
How to Add Barcode on PDF Report in Odoo 17
PPTX
Customization of Odoo 17 Periodic Digest parameters from backend
PDF
Check printing in_r12
PPTX
How to Create & Manage a Dashboard Using OWL in Odoo 17
PPTX
How To Extend Odoo Form View using js_class_
PPTX
How to Add Button in Chatter in Odoo 18 - Odoo Slides
PPTX
How to Create a Dynamic Snippet in Odoo 17
PPTX
URLs and Routing in the Odoo 17 Website App
PPTX
Client Actions In Odoo 17 - Odoo 17 Slides
PPTX
Types of Actions in Odoo 18 - Odoo Slides
PPTX
SAP SD Training in Chennai
PPTX
Odoo (OpenERP) - Creating a module
PPTX
Qweb Templates and Operations in Odoo 18
PPTX
Reporting - Printed (Pdf) Reports
PDF
S4 HANA Business Partner Configuration@Ganesh Tarlana
PPTX
Odoo (open erp) creating a module
PPTX
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
PPTX
How to modify_create components control buttons in Pos odoo.pptx
PPTX
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
How to Customize POS Receipts in the Odoo 17
How to Add Barcode on PDF Report in Odoo 17
Customization of Odoo 17 Periodic Digest parameters from backend
Check printing in_r12
How to Create & Manage a Dashboard Using OWL in Odoo 17
How To Extend Odoo Form View using js_class_
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Create a Dynamic Snippet in Odoo 17
URLs and Routing in the Odoo 17 Website App
Client Actions In Odoo 17 - Odoo 17 Slides
Types of Actions in Odoo 18 - Odoo Slides
SAP SD Training in Chennai
Odoo (OpenERP) - Creating a module
Qweb Templates and Operations in Odoo 18
Reporting - Printed (Pdf) Reports
S4 HANA Business Partner Configuration@Ganesh Tarlana
Odoo (open erp) creating a module
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to modify_create components control buttons in Pos odoo.pptx
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
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

Recently uploaded (20)

PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Computing-Curriculum for Schools in Ghana
PPTX
master seminar digital applications in india
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Pharma ospi slides which help in ospi learning
PDF
Basic Mud Logging Guide for educational purpose
PDF
Complications of Minimal Access Surgery at WLH
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Cell Structure & Organelles in detailed.
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
GDM (1) (1).pptx small presentation for students
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Computing-Curriculum for Schools in Ghana
master seminar digital applications in india
Microbial diseases, their pathogenesis and prophylaxis
Pharma ospi slides which help in ospi learning
Basic Mud Logging Guide for educational purpose
Complications of Minimal Access Surgery at WLH
102 student loan defaulters named and shamed – Is someone you know on the list?
Final Presentation General Medicine 03-08-2024.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Institutional Correction lecture only . . .
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Cell Structure & Organelles in detailed.
Anesthesia in Laparoscopic Surgery in India
Microbial disease of the cardiovascular and lymphatic systems
GDM (1) (1).pptx small presentation for students

Report Actions In Odoo 17 - Odoo 17 Slides

  • 1. Report Actions In Odoo 17 Enterprise
  • 2. Introduction Enterprise In Odoo 17, report actions allow us to define and manage various reports within the system. These reports can be generated in different formats such as PDF, Excel, and HTML, and can be triggered from different parts of the application. That is, Report actions are basically used for triggering the printing of a report.
  • 3. Enterprise Let’s create a module named sale_report_custom which simply creates a new sub menu in Sales module’s Reporting menu, opens a wizard which asks for the customer and a sale amount. With the entered details, a PDF report will be generated for the selected customer’s all Sale orders which has the sale value above the amount we enter. The module structure is as
  • 4. Enterprise First, to create a menu, type the xml code in the file sale_order_form.xml under views directory. <menuitem id="menu_show_wizard" sequence="5" action="sale_report_wizard_action" name="Sale Report PDF" parent="sale.menu_sale_report"/> The menu can be seen as
  • 5. Enterprise For defining the action sale_report_wizard_action for the menu, create a wizard using Transient model, define its views and make the wizard open on this menu button click. All the python and xml codes for the wizard is saved in the wizards directory and the python files must be imported inside the __init__ under it. The python file for defining the class can be as from odoo import fields, models class SaleReportWizard(models.TransientModel): _name = 'sale.report.wizard' sale_amount = fields.Float("Sale Amount Above") partner_id = fields.Many2one('res.partner', "Customer")
  • 6. Enterprise Now, create the basic form view for the wizard which displays those two fields sale_amount and partner_id. Also give this form view’s id as the view_id for the action that we have given for the previous menu added in the Sale module. The xml code for the action can be as <record id="sale_report_wizard_action" model="ir.actions.act_window"> <field name="name">Custom Wizard</field> <field name="res_model">sale.report.wizard</field> <field name="type">ir.actions.act_window</field> <field name="view_mode">tree,form</field> <field name="view_id" ref="sale_report_wizard_view_form"/> <field name="context">{}</field> <field name="target">new</field> </record> The id of the form view is sale_report_wizard_view_form here. This will make the wizard to open.
  • 7. Enterprise On clicking the menu, the wizard will be shown as We need to select the marked two fields and click on the Print PDF button. For that button, we set the type as object, just name it as print_report and define a python method with the same name which will generate the PDF report.
  • 8. Enterprise In Odoo, ir.actions.report is used to define and manage reports. This model allows us to create, configure, and customize reports that can be rendered in various formats such as PDF, HTML, and XLSX. The parameters for ir.actions.report include several fields that define the behavior and appearance of the reports. For a PDF report to function, the report action we created in xml code is as <record id="action_custom_report_saleorder" model="ir.actions.report"> <field name="name">Sale Details Custom Report</field> <field name="model">sale.order</field> <field name="report_type">qweb-pdf</field> <field name="report_name">sale_report_custom.custom_sale_report</field> <field name="report_file">sale_report_customcustom_sale_report</field> <field name="print_report_name">'Custom Sale Report'</field> </record>
  • 9. Enterprise Here are the key parameters: ● id give a unique id for the record ● name specifies the name of the report action. It is of char type. ● model is the Odoo model on which the report is based. ● report_type is the type of the report. Common types include "qweb- pdf" for PDF reports, "qweb-html" for HTML reports and "qweb-text" for plain text reports ● report_name is the technical name of the report template. ● print_report_name can be set which is a Python expression to dynamically set the report's file name when printed. Or simply we can set its value of char type in single quote. ● binding_model_id is the model to which the report is bound ● binding_type determines where the report action will appear. ● paperformat_id can also be set which specifies the paper format for the report, such as A4, A5, etc ● attachment uses A Python expression for the report attachment file name. If set, the report will be stored as an attachment.
  • 10. Enterprise Now, define the method print_report in the wizard’s model as def print_report(self): vals = [] sale_order = self.env['sale.order'].search([( 'partner_id', '=',self.partner_id.id),('amount_total','>=',self.sale_amount)]) for order in sale_order: vals.append({'name': order.name,'date': order.date_order, 'amount_total': order.amount_total,'sales_person':order.user_id.name, }) data = { 'ids': self.ids, 'model': self._name, 'vals': vals, 'sale_amount': self.sale_amount, 'partner_id': self.partner_id.name } return self.env.ref('sale_report_custom. action_custom_report_saleorder').report_action(self, data=data)
  • 11. Enterprise Here what we are doing is: ● Set up a list vals as blank initially ● Searched all the orders with the condition matched with the values given in wizard for the Customer and Amount ● Then appended all those order’s details to vals using append() with the key details name, date, amount_total and sales_person. ● Added the data dictionary with vals as one key and other details such as the model, sale_amount, etc ● At last, we took the reference of the xml report action using self.env.ref() with the parameter sale_report_custom.action_custom_report_saleorder where the first part before dot(.) is the module name and the second part after it is the xml id of the report action. This will check for the report_name custom_sale_report specified in the action. ● Then using the report_action() method, we passed the data dictionary
  • 12. Enterprise Next, we need to create a Qweb Template which designs the PDF report content. For that, start typing the template content using <template id="custom_sale_report"> <t t-call="web.html_container"> <t t-call="web.external_layout"> A unique id is needed for the template. Then call the web.html_container to handle and render HTML content within QWeb templates securely and efficiently. web.external_layout serves as a standard layout for reports. This layout typically includes elements like the company logo, header, footer, and general styling that should be consistent across all documents.
  • 13. Enterprise Give the heading for the Report using any of the heading tags as <center> <h4><u>Customized Sale Report</u></h4> </center> Now, give the Customer Name and Sale Amount we gave in wizard to the left as <div style="text-align: left;"> <strong><p>Customer Name: <span t-esc="partner_id"/></p></strong> </div> <div style="text-align: left;"> <strong><p>Sale Amount Greater than <span t-esc="sale_amount"/></p></strong></div> </div>
  • 14. Enterprise And design a table with Headings and Body part as <table class="table table-sm o_main_table table-striped mt-4"> <thead style="display: table-row-group"> <tr> <th name="th_order_no" class="text-start">Order No</th> <th name="th_brand" class="text-start">Order Date</th> <th name="th_brand" class="text-start">Amount</th> <th name="th_quantity" class="text-end">Sales person</th> </tr> </thead> <tbody class="sale_tbody"> <t t-foreach="vals" t-as="order"> <tr t-att-class="'bg-200 fw-bold o_line_section'"> <td name="order_name"><span t-att-style="style" t-esc="order['name']"/></td> <td name="order_date"><span t-att-style="style" t-esc="order['date']"/></td> <td name="order_total"><span t-att-style="style" t-esc="order['amount_total']"/></td> <td name="order_salesperson"><span t-att-style="style" t-esc="order['sales_person']"/></td> </tr> </t></tbody> </table>
  • 15. Enterprise Now, when we fill the wizard as below and click on Print PDF button,
  • 16. Enterprise The PDF Report will get downloaded/ printed as
  • 17. 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