Odoo Help

0

How can i change the below webkit report code to aero report?

By
samba
on 8/26/14, 11:04 AM 1,180 views

 I am learning how to generate reports in openerp. I am facing problem in changing webkit report in to aero i.e instead open in PDF i want to open in excel. How can i proceed for this?

.py file

....................................................................................

from openerp.osv import fields,osv
from openerp import netsvc
class models_wizard(osv.osv_memory):
    _name='models.wizard'
    _columns={
    'date1':fields.date('From date'),
    'date2':fields.date('To Date')
    }
    def get_data(self,cr,uid,ids,context=None):
        wizard_record=self.browse(cr,uid,ids[0],context)
        domain=[('date','>=',wizard_record.date1)]
        models_models_object=self.pool.get('models.models')
        data_ids=models_models_object.search(cr,uid,domain,context=context)
        if not data_ids:
            raise osv.except_osv('Error!','There are no ids!')
            return False
        else:
            datas={
            'ids':data_ids,
            'model':'models.models',
            }          

return {
                'type':'ir.actions.report.xml',
                'report_name':'models.webkit.report',
                'datas':datas,
                'context':context

        }

...........................................................................................................................

XML file

.....................................................................................................................................

<openerp>
    <data>
        <record model='ir.ui.view' id='models_wizard_form'>
            <field name="name">models.wizard.form</field>
            <field name='model'>models.wizard</field>
            <field name='arch' type='xml'>
                <form string="wizard" version='7.0'>
                    <sheet>
                        <field name="date1"/>
                        <field name='date2'/>  
                    </sheet>
                    <footer>
                        <button special="cancel" string="Cancel"/>
                        <button type="object" name="get_data" string="getdata"/>
                    </footer>
                    
                </form>
                
            </field>
        </record>
        <record id="models_wizard_action" model="ir.actions.act_window">
            <field name="name">models.wizard.action</field>
            <field name="res_model">models.wizard</field>
            <field name="view_mode">form</field>
            <field name="view_type">form</field>
            <field name="target">new</field>
        </record>
        <menuitem id="models_wizard_menu" action="models_wizard_action" parent="models_models_menu_child" />
    </data>
</openerp>

....................................................................................................

Report xnl file

........................................................................................................

<openerp>
    <data>
        <report
                auto="False"
                id="models_webkit"
                model="models.models"
                name="models.webkit.report"
                file="reportgeneration/report/models_webkit_report.mako"
                string="models Webkit Report"
                report_type="webkit" />
    </data>
</openerp>

..............................................................................................................................................................

mako file

............................................................................

<html>
    <body>
    
        <table border="1.0" width="100%">
                <tr>
                    <th>name</th>
                    <th>code</th>
                    <th>date</th>
                </tr>
            %for emp in objects:
                <tr>
                    <td>${emp.code}</td>
                    <td>${emp.name}</td>
                    <td>${emp.date}</td>
                    
                </tr>
                %endfor
            </table>
    </body>
</html>

.......................................................................................................................................................................

I have added properly these files to __openerp__.py and __init__.py. Can any one please help me?

1

Hi,

In your .py file you have to return as like below.

 return {
                'type':'ir.actions.report.xml',
                'report_name':'models.webkit.report',
                'datas':datas,
                'context':context

        }

Note : Here (in return) you have to give the name of the report which you have given into <report> record.

Thank you, This solved my problem....

samba
on 8/27/14, 3:36 AM

Your always welcome :)

Emipro Technologies Pvt. Ltd.
on 8/27/14, 3:50 AM

Is it possible to change this report to aero report. i.e the report should open in excel instead of pdf

samba
on 8/27/14, 5:03 AM

Yes, it is possible.

Emipro Technologies Pvt. Ltd.
on 8/27/14, 6:03 AM

Please Can you tell me how?

samba
on 8/28/14, 2:23 AM

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: 8/26/14, 11:04 AM
Seen: 1180 times
Last updated: 3/16/15, 8:10 AM