Odoo Help

0

Return the PDF on wizard

By
Javier Batres Velásquez
on 1/27/15, 12:21 PM 1,784 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>

0
Adnier Rosello
On 10/19/17, 6:59 PM

Hi javier, maybe this code can help you

@api.multi

def render_html(self):

    return self.env['report'].get_action(self, 'your_module_name.utilities')


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: 1/27/15, 12:21 PM
Seen: 1784 times
Last updated: 10/19/17, 6:59 PM