summaryrefslogtreecommitdiff
path: root/addons/report/controllers/main.py
diff options
context:
space:
mode:
authorMohammed Shekha <msh@openerp.com>2015-04-08 12:20:36 +0530
committerYannick Tivisse <yti@odoo.com>2016-05-27 09:44:01 +0200
commitda3d2fb1dc76654e630fba27ca3dcf03002d9431 (patch)
tree7983c7821a47add2982cf0f7ae88e86eadade49b /addons/report/controllers/main.py
parent0b52d097ea4e1fba9f84c988eae8975ef5a831a8 (diff)
[IMP] report: Printed Report names customization
PURPOSE ======= I've seen this new improvement regarding the naming of the printed reports: https://www.odoo.com/web?#id=10870&view_type=form&model=project.task&menu_id=3942&action=327 This makes the report have the pdf name being the name instead of the report_name of the ir.actions.report.xml, which is already an improvement. But why don't we allow the users to have their own naming conventions? I mean, we could allow our client to create and name their pdf the way they want, as they do regarding the attachment. Not only when it's about saving it as an attachment on the record, but also when downloading directly the pdf, such that the modification in the previous screenshot, would give the following result when downloaded: People need to have their pdf named automatically according to a convention. When you print 10 sales order during an hour, you don't want to get lost in having the following: Devis / Commande.pdf Devis / Commande(1).pdf Devis / Commande(2).pdf Devis / Commande(3).pdf Devis / Commande(4).pdf Devis / Commande(5).pdf Devis / Commande(6).pdf Devis / Commande(7).pdf especially when those are for different partners.
Diffstat (limited to 'addons/report/controllers/main.py')
-rw-r--r--addons/report/controllers/main.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/addons/report/controllers/main.py b/addons/report/controllers/main.py
index 57e4eaab38b..3672cba8020 100644
--- a/addons/report/controllers/main.py
+++ b/addons/report/controllers/main.py
@@ -4,8 +4,10 @@
from openerp.addons.web.http import Controller, route, request
from openerp.addons.web.controllers.main import _serialize_exception, content_disposition
from openerp.tools import html_escape
+from openerp.tools.safe_eval import safe_eval as eval
import json
+import time
from werkzeug import exceptions, url_decode
from werkzeug.test import Client
from werkzeug.wrappers import BaseResponse
@@ -102,6 +104,10 @@ class ReportController(Controller):
cr, uid = request.cr, request.uid
report = request.registry['report']._get_report_from_name(cr, uid, reportname)
filename = "%s.%s" % (report.name, "pdf")
+ ids = [int(x) for x in docids.split(",")]
+ obj = request.env[report.model].browse(ids)
+ if report.print_report_name and not len(obj) > 1:
+ filename = eval(report.print_report_name, {'object': obj, 'time': time})
response.headers.add('Content-Disposition', content_disposition(filename))
response.set_cookie('fileToken', token)
return response