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

How do I print a report AND keep the wizard open?

By
Luis Masuelli
on 9/17/15, 11:12 AM 350 views

This is how I print a report:

def yoursister(self, cr, uid, ids, context=None):
    """
    """
    return {
        'type': 'ir.actions.report.xml',
        'report_name': 'trescloud_ats_2013_report',
        'datas': {
            'model': 'sri.ats.2013',
            'res_ids': ids
        }
}

This method is executed from a wizard. How do I *also* avoid the wizard being closed?

3

Axel Mendoza

--Axel Mendoza--
10205
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 9/18/15, 1:54 AM

That couldn't be done in Odoo without an js extension, specifically you need to extend the js class "instance.web.ActionManager" to add a new action type with the same code of the ir_actions_report_xml. The following code need to be loaded in a js file and does the job by creating the action ir_actions_report_xml_no_close with the close dialog lines removed:

instance.web.ActionManager.include({
ir_actions_report_xml_no_close: function(action, options) {
var self = this;
instance.web.blockUI();
action = _.clone(action);
var eval_contexts = ([instance.session.user_context] || []).concat([action.context]);
action.context = instance.web.pyeval.eval('contexts',eval_contexts);
// iOS devices doesn't allow iframe use the way we do it,
// opening a new window seems the best way to workaround
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
var params = {
action: JSON.stringify(action),
token: new Date().getTime()
};
var url = self.session.url('/web/report', params);
instance.web.unblockUI();
$('<a href="'+url+'" target="_blank"></a>')[0].click();
return;
}
var c = instance.webclient.crashmanager;
return $.Deferred(function (d) {
self.session.get_file({
url: '/web/report',
data: {action: JSON.stringify(action)},
complete: instance.web.unblockUI,
success: function(){
d.resolve();
},
error: function () {
c.rpc_error.apply(c, arguments);
d.reject();
}
});
});
}
});

To use the new action you just need to change a little your return action in your method to return:

return {
'type': 'ir.actions.report.xml_no_close',
'report_name': 'trescloud_ats_2013_report',
'datas': {
'model': 'sri.ats.2013',
'res_ids': ids
}
}

Hope this helps

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: 9/17/15, 11:12 AM
Seen: 350 times
Last updated: 9/18/15, 1:54 AM