Odoo Help

1

How to show the report in the form view

By
sridhar
on 12/21/15, 7:23 AM 985 views

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

1
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')

@api.multi

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"?>

<openerp>

<data>

<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">

<header>

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

</header>

<sheet>

<field name="preview"/>

</sheet>

</page>

</xpath>

</field>

</record>

</data>

</openerp>

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.

Register

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)

Stats

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