# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)


from odoo.addons.web.controllers import main as report
from odoo.http import request, route


class ReportController(report.ReportController):
    @route()
    def report_routes(self, reportname, docids=None, converter=None, **data):
        if converter == "reportlab_pdf":
            report_slip = request.env.ref(
                'l10n_ch_payment_slip.one_slip_per_page_from_invoice')
            if docids:
                docids = [int(i) for i in docids.split(',')]
            data, format = report_slip.render(docids)
            pdfhttpheaders = [
                    ('Content-Type', 'application/pdf'),
                    ('Content-Disposition', 'attachment'),
                    ('Content-Length', len(data)),
            ]
            return request.make_response(data, headers=pdfhttpheaders)
        return super(ReportController, self).report_routes(
            reportname, docids, converter, **data)

@@ -94,16 +94,42 @@
 html)%0A%0A%0A
+from odoo.models import _%0A
 from odo
@@ -196,16 +196,37 @@
 p import
+ content_disposition,
  request
@@ -530,16 +530,48 @@
 voice')%0A
+            filename = _('ISR')%0A
         
@@ -601,22 +601,26 @@
         
-doc
+invoice_
 id
-s
  = %5Bint(
@@ -649,16 +649,168 @@
 it(',')%5D
+%5B0%5D%0A                filename = ''.join(%5B%0A                    _('ISR'), '_',%0A                    '%7B0:05d%7D'.format(invoice_id), '.pdf',%0A                %5D)
 %0A       
@@ -848,22 +848,26 @@
 .render(
-doc
+invoice_
 id
-s
 )%0A      
@@ -891,20 +891,16 @@
 ers = %5B%0A
-    
         
@@ -952,36 +952,32 @@
                 
-  
-  
 ('Content-Dispos
@@ -988,27 +988,40 @@
 n', 
-'attachment'),%0A    
+content_disposition(filename)),%0A
     

Improve ISR file name