Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
8741 Widoki

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>

Awatar
Odrzuć
Najlepsza odpowiedź

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


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
kwi 20
3830
3
cze 19
5842
1
sie 18
3510
1
mar 15
7580
0
mar 15
4741