Odoo Help

Welcome!

This community 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.

0

Return the PDF on wizard

By
Javier Batres Velásquez
on 1/27/15, 12:21 PM 1,323 views

Hello I have my rwizard with a field Many2one for product.product, after ther is my function that is in the same idea like the documentation, All is ok, the Wizard load ok, show the selection widget and make the submit, but y dont get my report on my screen.

Somehting interesting is that if I load the report by a url, this works pefectly

Here is the code of all:

wizard.py

# -*- coding: utf-8 -*-

from openerp import models, fields, api

class Wizard(models.AbstractModel):
    _name = 'velfasa.wizard'
    product_id = fields.Many2one('product.product', string='Producto', widget='selection', store=False)

    @api.multi
    def render_html(self, data=None):
        report_obj = self.env['report']
        report = report_obj._get_report_from_name('velfasa.utilities')
        docargs = {
            'doc_ids' : self._ids,
            'doc_model' : report.model,
            'docs' : self.product_id,
        }
        return report_obj.render('velfasa.utilities', docargs)

reports.xml

 

   

<openerp>
<data>
    <report
        id="report_sale_utilities"
        model="product.product"
        string="Reporte de utilidad"
        name="velfasa.utilities"
        file="velfasa.utilities"
        report_type="qweb-pdf" />

    <template id="utilities">
        <t t-call="report.html_container">
            <t t-foreach="docs" t-as="doc">
                <t t-call="report.external_layout">
                    <div class="page">
                        <p><h2>Producto:</h2> <span t-field="doc.name"/></p>
                        <separator/>
                    </div>
                </t>
            </t>
        </t>
    </template>

</data>
</openerp>

 

sale.xml

   

<?xml version="1.0" encoding="UTF-8"?>
 <openerp>
    <data>
        <menuitem id="sale_reports" name="Informes" parent="base.menu_base_partner" />

        <menuitem id="sale_reports_utilities" name="Utilidades" parent="sale_reports"
                 action="launch_vel_utilities_wizard"  />

        <record model="ir.ui.view" id="wizard_form_view">
            <field name="name">wizard.form</field>
            <field name="model">velfasa.wizard</field>
            <field name="arch" type="xml">
                <form string="Informe de utilidades">
                    <group>
                        <field name="product_id" widget="selection"/>
                    </group>
                    <footer>
                        <button name="render_html" type="object" string="Imprimir" class="oe_highlight" target="_blank" />
                        <button special="cancel" string="Cancelar" />
                    </footer>
                </form>
            </field>
        </record>

        <act_window id="launch_vel_utilities_wizard"
                    name="Informe de utilidades"
                    src_model="product.product"
                    res_model="velfasa.wizard"
                    view_mode="form"
                    target="new"/>
    </data>
</openerp>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/27/15, 12:21 PM
Seen: 1323 times
Last updated: 3/16/15, 8:10 AM