-
-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by gurneyalex
- Loading branch information
Showing
23 changed files
with
710 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
==================== | ||
Base report fill PDF | ||
==================== | ||
|
||
This module provides a basic report class that fills pdfs. | ||
|
||
Installation | ||
============ | ||
|
||
Make sure you have ``fdfgen`` Python module installed:: | ||
|
||
$ pip install fdfgen | ||
|
||
For testing it is also necessary ``pdftk`` app installed: | ||
|
||
Ubuntu :: | ||
|
||
apt-get install pdftk | ||
|
||
OSX :: | ||
|
||
* Install pdftk (https://www.pdflabs.com/tools/pdftk-server/). | ||
|
||
Windows :: | ||
|
||
* Install pdftk (https://www.pdflabs.com/tools/pdftk-server/). | ||
|
||
Usage | ||
===== | ||
|
||
An example of Fill PDF report for partners on a module called `module_name`: | ||
|
||
A python class :: | ||
|
||
from odoo import models | ||
|
||
class PartnerFillPDF(models.AbstractModel): | ||
_name = 'report.module_name.report_name' | ||
_inherit = 'report.report_fillpdf.abstract' | ||
@api.model | ||
def get_original_document_path(self, data, objs): | ||
return get_resource_path( | ||
'report_fillpdf', 'static/src/pdf', 'partner_pdf.pdf') | ||
|
||
@api.model | ||
def get_document_values(self, data, objs): | ||
objs.ensure_one() | ||
return {'name': objs.name} | ||
|
||
A computed form can be executed modifying the computing function :: | ||
|
||
from odoo import models | ||
|
||
class PartnerFillPDF(models.AbstractModel): | ||
_name = 'report.module_name.report_name' | ||
_inherit = 'report.report_fillpdf.abstract' | ||
|
||
@api.model | ||
def get_form(self, data, objs): | ||
return self.env['ir.attachment'].search([], limit=1) | ||
|
||
@api.model | ||
def get_document_values(self, data, objs): | ||
objs.ensure_one() | ||
return {'name': objs.name} | ||
|
||
|
||
A report XML record :: | ||
|
||
<report | ||
id="partner_fillpdf" | ||
model="res.partner" | ||
string="Fill PDF" | ||
report_type="fillpdf" | ||
name="report_fillpdf.partner_fillpdf" | ||
file="res_partner" | ||
attachment_use="False" | ||
/> | ||
|
||
.. 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/11.0 | ||
|
||
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. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Enric Tobella <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
: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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import controllers | ||
from . import models | ||
from . import report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2017 Creu Blanca | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Base report PDF Filler", | ||
"summary": """ | ||
Base module that fills PDFs""", | ||
"author": "Creu Blanca," "Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/reporting-engine", | ||
"category": "Reporting", | ||
"version": "14.0.1.0.1", | ||
"license": "AGPL-3", | ||
"external_dependencies": { | ||
"python": [ | ||
"fdfgen", | ||
], | ||
"deb": [ | ||
"pdftk", | ||
], | ||
}, | ||
"depends": [ | ||
"base", | ||
"web", | ||
], | ||
"data": [ | ||
"views/webclient_templates.xml", | ||
], | ||
"demo": [ | ||
"demo/report.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (C) 2017 Creu Blanca | ||
# License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html). | ||
|
||
import json | ||
|
||
from odoo.http import content_disposition, request, route | ||
|
||
from odoo.addons.web.controllers import main as report | ||
|
||
|
||
class ReportController(report.ReportController): | ||
@route() | ||
def report_routes(self, reportname, docids=None, converter=None, **data): | ||
if converter == "fillpdf": | ||
report = request.env["ir.actions.report"]._get_report_from_name(reportname) | ||
context = dict(request.env.context) | ||
if docids: | ||
docids = [int(i) for i in docids.split(",")] | ||
if data.get("options"): | ||
data.update(json.loads(data.pop("options"))) | ||
if data.get("context"): | ||
# Ignore 'lang' here, because the context in data is the one | ||
# from the webclient *but* if the user explicitely wants to | ||
# change the lang, this mechanism overwrites it. | ||
data["context"] = json.loads(data["context"]) | ||
if data["context"].get("lang"): | ||
del data["context"]["lang"] | ||
context.update(data["context"]) | ||
pdf = report.with_context(context).render_fillpdf(docids, data=data)[0] | ||
pdfhttpheaders = [ | ||
("Content-Type", "application/pdf"), | ||
("Content-Length", len(pdf)), | ||
( | ||
"Content-Disposition", | ||
content_disposition(report.report_file + ".pdf"), | ||
), | ||
] | ||
return request.make_response(pdf, headers=pdfhttpheaders) | ||
return super(ReportController, self).report_routes( | ||
reportname, docids, converter, **data | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<!-- | ||
© 2017 Creu Blanca | ||
License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html). | ||
--> | ||
<report | ||
id="partner_fillpdf" | ||
model="res.partner" | ||
string="Fill PDF" | ||
report_type="fillpdf" | ||
name="report_fillpdf.partner_fillpdf" | ||
file="res_partner" | ||
attachment_use="False" | ||
/> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * report_fillpdf | ||
# | ||
# Translators: | ||
# Ricardo Gross <[email protected]>, 2017 | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-12-23 03:49+0000\n" | ||
"PO-Revision-Date: 2017-12-23 03:49+0000\n" | ||
"Last-Translator: Ricardo Gross <[email protected]>, 2017\n" | ||
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" | ||
"Language: de\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
||
#. module: report_fillpdf | ||
#: code:addons/report_fillpdf/models/ir_report.py:18 | ||
#, python-format | ||
msgid "%s model was not found" | ||
msgstr "%s Modell wurde nicht gefunden" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_abstract_display_name | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_partner_fillpdf_display_name | ||
msgid "Display Name" | ||
msgstr "Name anzeigen" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.actions.report,name:report_fillpdf.partner_fillpdf | ||
msgid "Fill PDF" | ||
msgstr "PDF ausfüllen" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_abstract_id | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_partner_fillpdf_id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_abstract___last_update | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_partner_fillpdf___last_update | ||
msgid "Last Modified on" | ||
msgstr "Zuletzt geändert am" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model,name:report_fillpdf.model_ir_actions_report | ||
msgid "ir.actions.report" | ||
msgstr "" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model,name:report_fillpdf.model_report_report_fillpdf_abstract | ||
msgid "report.report_fillpdf.abstract" | ||
msgstr "" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model,name:report_fillpdf.model_report_report_fillpdf_partner_fillpdf | ||
msgid "report.report_fillpdf.partner_fillpdf" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * report_fillpdf | ||
# | ||
# Translators: | ||
# Nicolas JEUDY <[email protected]>, 2018 | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2018-01-05 17:53+0000\n" | ||
"PO-Revision-Date: 2018-01-05 17:53+0000\n" | ||
"Last-Translator: Nicolas JEUDY <[email protected]>, 2018\n" | ||
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" | ||
"Language: fr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
|
||
#. module: report_fillpdf | ||
#: code:addons/report_fillpdf/models/ir_report.py:18 | ||
#, python-format | ||
msgid "%s model was not found" | ||
msgstr "%s model n'a pas été trouvé" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_abstract_display_name | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_partner_fillpdf_display_name | ||
msgid "Display Name" | ||
msgstr "Nom" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.actions.report,name:report_fillpdf.partner_fillpdf | ||
msgid "Fill PDF" | ||
msgstr "Remplir le PDF" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_abstract_id | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_partner_fillpdf_id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_abstract___last_update | ||
#: model:ir.model.fields,field_description:report_fillpdf.field_report_report_fillpdf_partner_fillpdf___last_update | ||
msgid "Last Modified on" | ||
msgstr "Dernière modification le" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model,name:report_fillpdf.model_ir_actions_report | ||
msgid "ir.actions.report" | ||
msgstr "ir.actions.report" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model,name:report_fillpdf.model_report_report_fillpdf_abstract | ||
msgid "report.report_fillpdf.abstract" | ||
msgstr "report.report_fillpdf.abstract" | ||
|
||
#. module: report_fillpdf | ||
#: model:ir.model,name:report_fillpdf.model_report_report_fillpdf_partner_fillpdf | ||
msgid "report.report_fillpdf.partner_fillpdf" | ||
msgstr "report.report_fillpdf.partner_fillpdf" |
Oops, something went wrong.