Browse Source

[9.0] MIG Custom Report Filenames

pull/84/head
Nicolas Mac Rouillon 8 years ago
parent
commit
c60ec7e621
  1. 68
      report_custom_filename/README.rst
  2. 6
      report_custom_filename/__openerp__.py
  3. 4
      report_custom_filename/controllers/report_controller.py
  4. 4
      report_custom_filename/controllers/reports.py

68
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 <https://github.com/OCA/reporting-engine/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 <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_custom_filename%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
.. 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 <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_custom_filename%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Holger Brunn <hbrunn@therp.nl>
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.

6
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'],

4
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,

4
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,

Loading…
Cancel
Save