Odoo Help


How can I prevent the base "print invoice button" from downloading

Sascha Pfeiffer
on 12/23/14, 2:52 AM 841 views


Im using right now webkit_report engine and managed together with base_report_to_printer to install a printer. Now I defined a second report, that prints directly. The only problem I struggle right now is, that when I push this print invoice button then in addition to printing the invoice I download the invoice. So how can I tell openerp, that I dont want the download?

If someone could point me to the right module / line of code, then im pretty sure I can code a workaround.

Thats how it looks:


I defined my second report like this:

            string="Print Invoices"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/',''))"
    <data noupdate="1">
        <record id="account_invoices" model="ir.actions.report.xml">
            <field name="webkit_header" ref="base_headers_webkit.base_reports_portrait_header"></field>

Thanks in advance and Merry Xmas!


Sascha Pfeiffer
On 12/23/14, 8:07 AM

I found a solution myself, so for further reference:

I used web-pdf-preview-print, which can be found here https://github.com/buke/odoo-web-pdf-preview-print

modified the javascript like this:

openerp.web_pdf_preview = function(instance) {
    instance.web.ActionManager = instance.web.ActionManager.extend({
        ir_actions_report_xml: function(action, options) {
            var self = this;
            return instance.web.pyeval.eval_domains_and_contexts({
                contexts: [action.context],
                domains: []
            }).then(function(res) {
                action = _.clone(action);
                action.context = res.context;
                //var os = navigator.platform || "Unknown OS";
                //linux = os.indexOf("Linux") > -1;
                var targeturl = '/web/report/pdf?action=' + encodeURIComponent(JSON.stringify(action)) + '&token=' + new Date().getTime() + '&session_id=' + self.session.session_id;
                if (!action.hasOwnProperty('nodownload') || action['nodownload'] !== true) {
                    window.open(targeturl, 'report', '');
                } else {
                    $.get( targeturl, function( data ) {});



In addition I added a field to ir_actions_report_xml

from openerp.osv import fields, osv
from openerp.tools.translate import _

class new_ir_actions_report_xml(osv.osv):
    _name = 'ir.actions.report.xml'
    _inherit = 'ir.actions.report.xml'
    _columns = {
        'nodownload': fields.boolean('No Download', help="Deaktivates the download")

    _defaults = {
        'nodownload': False,



and the xml:

        <record id="act_report_xml_view_update" model="ir.ui.view">
            <field name="name">ir.actions.report.xml.update</field>
            <field name="model">ir.actions.report.xml</field>
            <field name="inherit_id" ref="report_webkit.act_report_xml_view"/>
            <field name="arch" type="xml">
                <field name="webkit_debug" position="after">
                    <field name="nodownload"/>

So for every report I dont want a download, I can mark the report now and get no download. If someone dislikes this "open pdf in browser" thing, he can simply remove the result.headers['Content-Disposition'] = result.headers['Content-Disposition'].replace('attachment', 'inline') line from web_pdf_preview/controllers/__init__.py



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 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.


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)


Asked: 12/23/14, 2:52 AM
Seen: 841 times
Last updated: 3/16/15, 8:10 AM