From c60ec7e621fab5c64007e95a5b6eafd2be585c95 Mon Sep 17 00:00:00 2001 From: Nicolas Mac Rouillon Date: Tue, 29 Nov 2016 17:17:24 -0300 Subject: [PATCH] [9.0] MIG Custom Report Filenames --- report_custom_filename/README.rst | 68 ++++++++++++++----- report_custom_filename/__openerp__.py | 6 +- .../controllers/report_controller.py | 4 +- report_custom_filename/controllers/reports.py | 4 +- 4 files changed, 59 insertions(+), 23 deletions(-) diff --git a/report_custom_filename/README.rst b/report_custom_filename/README.rst index ca2d8b61..cff8617e 100644 --- a/report_custom_filename/README.rst +++ b/report_custom_filename/README.rst @@ -1,12 +1,49 @@ -Custom report filenames +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================= +Custom Report Filenames ======================= -This addon allows for custom filenames for reports. +This module allows for custom filenames for reports. + +Installation +============ + +To install this module, you need to: + +#. Just install the module. Configuration ============= -To configure this module, open the report whose filename you want to change and fill in the `Download filename` field. This field is evaluated as jinja2 template with `objects` being a list of browse records of the records to print, and `o` the first record. If your model contains a name field, you might write something like `${o.name}_report.pdf` as filename. +To configure this module, you need to: + +#. Open the report whose filename you want to change and fill in the `Download filename` field. This field is evaluated as jinja2 template with `objects` being a list of browse records of the records to print, and `o` the first record. If your model contains a name field, you might write something like `${o.name}_report.pdf` as filename. + +.. figure:: path/to/local/image.png + :alt: alternative description + :width: 600 px + +Usage +===== + +To use this module, you need to: + +#. Just print a report. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/205/9.0 + +.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt +.. branch is "9.0" for example + +Known issues / Roadmap +====================== + +* ... Bug Tracker =========== @@ -14,34 +51,33 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/143/8.0 +`here Credits ======= +Images +------ + +* Odoo Community Association: `Icon `_. + Contributors ------------ * Holger Brunn -Icon ----- - -Icon courtesy of http://www.picol.org/ (download_settings.svg) Maintainer ---------- -.. image:: http://odoo-community.org/logo.png +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :target: https://odoo-community.org This module is maintained by the OCA. -OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/report_custom_filename/__openerp__.py b/report_custom_filename/__openerp__.py index 1b78fd7e..fe8a8ddc 100644 --- a/report_custom_filename/__openerp__.py +++ b/report_custom_filename/__openerp__.py @@ -21,14 +21,14 @@ { "name": "Custom report filenames", "summary": "Configure the filename to use when downloading a report", - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", "author": "Therp BV,Odoo Community Association (OCA)", "license": "AGPL-3", "complexity": "normal", "category": "Reporting", "depends": [ 'web', - 'email_template', + 'mail', ], "data": [ "view/ir_actions_report_xml.xml", @@ -36,7 +36,7 @@ "test": [ ], "auto_install": False, - 'installable': False, + 'installable': True, "application": False, "external_dependencies": { 'python': ['jinja2'], diff --git a/report_custom_filename/controllers/report_controller.py b/report_custom_filename/controllers/report_controller.py index 536d2d69..2fcc4966 100644 --- a/report_custom_filename/controllers/report_controller.py +++ b/report_custom_filename/controllers/report_controller.py @@ -19,7 +19,7 @@ # ############################################################################## from openerp import http -from openerp.addons.email_template import email_template +from openerp.addons.mail.models import mail_template from openerp.addons.report.controllers.main import ReportController from openerp.addons.web.controllers.main import content_disposition @@ -42,7 +42,7 @@ class ReportController(ReportController): continue objects = http.request.session.model(report.model)\ .browse(docids or []) - generated_filename = email_template.mako_template_env\ + generated_filename = mail_template.mako_template_env\ .from_string(report.download_filename)\ .render({ 'objects': objects, diff --git a/report_custom_filename/controllers/reports.py b/report_custom_filename/controllers/reports.py index 1ff58ed0..b61efd07 100644 --- a/report_custom_filename/controllers/reports.py +++ b/report_custom_filename/controllers/reports.py @@ -21,7 +21,7 @@ import simplejson from openerp import http from openerp.addons.web.controllers import main -from openerp.addons.email_template import email_template +from openerp.addons.mail.models import mail_template class Reports(main.Reports): @@ -41,7 +41,7 @@ class Reports(main.Reports): continue objects = http.request.session.model(context['active_model'])\ .browse(context['active_ids']) - generated_filename = email_template.mako_template_env\ + generated_filename = mail_template.mako_template_env\ .from_string(report.download_filename)\ .render({ 'objects': objects,