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

Sending more parameter to report

By
Javier Batres Velásquez
on 2/3/15, 1:14 PM 553 views

Hello I am making a report and I need send some variables tat I have created while I was calculating everything. He is my code.

     

_name = 'model.wizard'

    product_id = fields.Many2one('product.product', string='Producto', widget='selection', required=True)
    @api.multi
    def imprimir(self):
        self.ventas = self.env['pos.order.line'].search([('product_id', '=', self.product_id.id)])
        self.costos = self.env['product.price.history'].search([('product_template_id', '=', self.product_id.product_tmpl_id.id)])
        record = self.read()

        datas = {
            'model' : 'model.wizard',
            'ids' : self.ids,
            'form' : record,

        }
        print(datas)
        return{
            'type' : 'ir.actions.report.xml',
            'report_name' : 'model.utilities',
            'datas' : datas,
            'nodestroy' : True,
        }

    def print_report(self, cr, uid, ids,context=None):
        record = self.read(cr, uid, ids[0], context=context)
        print(record)
        datas = {
            'model' : 'product.produdct',
            'ids' : ids,
            'form' : record
        }
        return{
            'type' : 'ir.actions.report.xml',
            'report_name' : 'model.utilities',
            'datas' : datas,
            'nodestroy' : True
        }

 

report.xml:

 

        

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

    <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.product_id.name"/></p>
                        <separator/>
                    </div>
                </t>
            </t>
        </t>
    </template>

</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: 2/3/15, 1:14 PM
Seen: 553 times
Last updated: 3/16/15, 8:10 AM