Odoo Help


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.


Pop window for report printing

on 8/5/13, 5:21 AM 3,734 views

I want to create menu like Reporting/Point of sale/Sale Details and print my report while clicking Print Report button. I have created a report which comes under Settings/Technical/Actions/Reports.How can i integrate my report to button click and how to create pop up? Any one please help?


Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
| 5 3 5
--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 8/5/13, 5:57 AM

hello, you can use wizard to achieve this, the wizard is as normal model but it will inherit 'osv.osv_memory'

class print_report_wiz(osv.osv_memory):
    _name = "print.report.wiz"

    _columns = {
        'name': fields.many2one('name.name', 'Name',required = True),

the xml view is also as normal but add:

<field name = "target">new</field>

to the action,

the print button will return a dictionary like:

return {
            'type': 'ir.actions.report.xml',
            'report_name': 'your.report.name',
            'datas': datas,
            'context': context,

also you can see these questions:

print report from wizard

create a wizard


on the print function of the wizard,

first you can fetch the wizard data e.g date_from , date_to, name ....

by using this:

wiz_data = self.read(cr, uid, ids[0], context = context)

now you can access them by using dictionary key e.g : wiz_date[date_from]

after that you can use these values to formulate sql query to fetch the ids you want...

cr.execute('SELECT id '\
                        'FROM table_name ' \
                        "WHERE date BETWEEN %s AND %s", (wiz_data['from_date'], wiz_data['to_date']))

then you have to fetch these ids you can use for e.g:

res_ids = [id for id, in cr.fetchall()]

at this time , you have your desired ids ...

the datas dict will be passed to your report , with three keys: model, ids of this model, and form which contains the wiz_data could be like this:

datas = {
            'ids': res_ids,
            'model': 'model.name',
            'form': wiz_data,

now your report has all information needed,

the "objects" contains a browse record of the given ids on datas dict... also you can use the wizard information in your report like this:

if you want to print e.g this report from date ... to date ...

you can use:

[[ data['form']['from_date'] ]] and [[ data['form']['to_date'] ]]

remember, the form contains your fetched wizard's data ...

also you can filter your data using the report python file by declaring a function to do some filtering...

it depends on your requirements , and it will be a performance issue to filter your data on the wizard function's or in a report's python file [for e.g you'll use the returns values in another function on the python file]....

I hope it'll helps you ....


I changed code but still it didnt create any menu under "Reporting" what is the issue?

on 8/5/13, 8:39 AM
On 8/5/13, 8:38 AM
i created the wizard and my code is (calldetails/wizard/calldata_view.xml)
<?xml version="1.0" encoding="utf-8"?>

<record model="ir.ui.view" id="wizard_with_step_form">

 <field name="model">calldata.print.report.wiz</field>
    <field name="type">form</field>
    <field name="arch" type="xml">
      <form string="Wizard with step" version="7.0">
    <field name="one" />
 <record model="ir.actions.act_window" id="action_calldata_form1">
   <field name="name">Calldetails</field>
   <field name="res_model">calldata.print.report.wiz</field>
<act_window name="Create Combined Picking" res_model="calldata.print.report.wiz" src_model="calldata.print.report.wiz" key2="client_action_multi" multi="True" view_mode="form" view_type="form" target="new" id="action_stock_picking_combined_wizard" />

Object file is(calldetails/wizard/calldata_print.py)
from openerp.osv import fields, osv

class calldata_print_report_wiz(osv.osv_memory):
    _name = "calldata.print.report.wiz"

    _columns = {
        'one':  fields.char('Name 1',),}


i added calldata_print in wizard/__init__.py  ,wizard in calldetails/__init__.py and calldata_view.xml in __openerp__.py stil it didnt create any menu under "Reporting"
 What is the issue. Please help

you didn't add a menuitem to your view, just try to add a menuitem and specify the the action and parent menu,...

Ahmed M.Elmubarak
on 8/5/13, 8:49 AM

also i think you missing: field name = "name" on the form view,..

Ahmed M.Elmubarak
on 8/5/13, 8:50 AM

It worked :). Thanks alot Ahmed

on 8/5/13, 9:17 AM

While clicking print it shoes error "RML is not available at specified location or not enough data to print! (None, None, None)". please help

on 8/6/13, 9:22 AM

Corrected. i was given invalid path for rml

on 8/7/13, 2:04 AM

helo i have created report and while clicking print it prints all data.but filtering not works .can you please help?what is the value i should pass with datas dictionary and with datas['form']?

on 8/28/13, 4:39 AM

Hello, I have updated my answer...Regards..

Ahmed M.Elmubarak
on 8/28/13, 6:06 AM

@Ahmed M.Elmubarak , It worked thanks alot for your help !!

on 8/28/13, 7:17 AM

i want remove repetition from my select box .my code is def _sel_func(self, cr, uid,context=None): cr.execute("select distinct on(caller) id,caller FROM calldata1 order by caller") result = cr.fetchall() lst = [] for r in result: dct = {} dct['id'] = r[o] dct['name'] = r[1] lst.append(dct) res_ids = [(r['id'], r['name']) for r in lst] return res_ids How to achive this?

on 8/29/13, 6:24 AM

hello @Anuradha, I cannot get what is the problem actually, but if your list has a repetition you can simply convert it to a set and then make it list again,

but note it seems it is another question than the title, I suggest to make a new question, or you can send to me a msg via my LinkedIn profile, it is already in my profile!.


Ahmed M.Elmubarak
on 8/29/13, 7:02 AM

I have posted another question http://help.openerp.com/question/29526/how-to-show-distict-data-in-many-to-one-filed/ please check or please send me your email id

on 8/29/13, 7:05 AM

Where do I find the setting for the RML issue? "Corrected. i was given invalid path for rml" I get this trying to print an invoice, and I haven't done any coding in the system??

Erik Wellander
on 1/29/14, 6:33 AM

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)


Asked: 8/5/13, 5:21 AM
Seen: 3734 times
Last updated: 9/16/15, 8:24 AM