Odoo Help


How to show the report in the form view

on 12/21/15, 7:23 AM 1,171 views

Hi, I need to show and save the report in same form page, how to do that.

Axel Mendoza
On 12/22/15, 10:27 PM

You could do it like this example for sale.order report generated as preview when pressing the preview button:

from openerp import models, fields, api

class report_sale_preview(models.Model):

_inherit = 'sale.order'

preview = fields.Html('Report Preview')


def generate_preview(self):

html = self.env['report'].get_html(self, 'sale.report_saleorder')

self.write({'preview': html})

return True

And in the view

<?xml version="1.0" encoding="UTF-8"?>



<record model="ir.ui.view" id="solt_report_preview_form_view">

<field name="name">sale.order.report.preview.form</field>

<field name="model">sale.order</field>

<field name="inherit_id" ref="sale.view_order_form"/>

<field name="arch" type="xml">

<xpath expr="//page[1]" position="after">

<page string="Report Preview">


<button name="generate_preview" type="object" string="Preview"/>



<field name="preview"/>








The result is something like this:

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 12/21/15, 7:23 AM
Seen: 1171 times
Last updated: 8/17/17, 3:34 AM