diff --git a/purchase_order_ubl/models/purchase.py b/purchase_order_ubl/models/purchase.py index b4ee05bed5..c87af9378f 100644 --- a/purchase_order_ubl/models/purchase.py +++ b/purchase_order_ubl/models/purchase.py @@ -245,7 +245,7 @@ def add_xml_in_pdf_buffer(self, buffer): buffer = self._ubl_add_xml_in_pdf_buffer(xml_string, xml_filename, buffer) return buffer - def embed_ubl_xml_in_pdf(self, pdf_content): + def embed_ubl_xml_in_pdf(self, pdf_content, pdf_file=None): self.ensure_one() doc_type = self.get_ubl_purchase_order_doc_type() if doc_type: @@ -256,7 +256,7 @@ def embed_ubl_xml_in_pdf(self, pdf_content): xml_string, self.get_document_name(doc_type), version=version ) pdf_content = self.embed_xml_in_pdf( - xml_string, xml_filename, pdf_content=pdf_content + xml_string, xml_filename, pdf_content=pdf_content, pdf_file=pdf_file ) return pdf_content diff --git a/purchase_order_ubl_py3o/README.rst b/purchase_order_ubl_py3o/README.rst new file mode 100644 index 0000000000..8ba778a7b0 --- /dev/null +++ b/purchase_order_ubl_py3o/README.rst @@ -0,0 +1 @@ +Will be re-generated from readme subdir diff --git a/purchase_order_ubl_py3o/__init__.py b/purchase_order_ubl_py3o/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/purchase_order_ubl_py3o/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_order_ubl_py3o/__manifest__.py b/purchase_order_ubl_py3o/__manifest__.py new file mode 100644 index 0000000000..85ab3fa4d3 --- /dev/null +++ b/purchase_order_ubl_py3o/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2017-2021 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Py3o UBL Purchase Order", + "version": "14.0.1.0.0", + "category": "Purchases", + "license": "AGPL-3", + "summary": "Generate UBL purchase orders with Py3o reporting engine", + "author": "Akretion,Odoo Community Association (OCA)", + "maintainers": ["alexis-via"], + "website": "https://github.com/OCA/edi", + "depends": ["purchase_order_ubl", "report_py3o_fusion_server"], + "installable": True, +} diff --git a/purchase_order_ubl_py3o/i18n/es.po b/purchase_order_ubl_py3o/i18n/es.po new file mode 100644 index 0000000000..6f56fbf935 --- /dev/null +++ b/purchase_order_ubl_py3o/i18n/es.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_order_ubl_py3o +# +# Translators: +# enjolras , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-12 01:43+0000\n" +"PO-Revision-Date: 2018-03-12 01:43+0000\n" +"Last-Translator: enjolras , 2018\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\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: purchase_order_ubl_py3o +#: model:ir.model,name:purchase_order_ubl_py3o.model_py3o_report +msgid "Report Py30" +msgstr "Informe Py30" diff --git a/purchase_order_ubl_py3o/i18n/purchase_order_ubl_py3o.pot b/purchase_order_ubl_py3o/i18n/purchase_order_ubl_py3o.pot new file mode 100644 index 0000000000..646eb5ce7b --- /dev/null +++ b/purchase_order_ubl_py3o/i18n/purchase_order_ubl_py3o.pot @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_order_ubl_py3o +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: purchase_order_ubl_py3o +#: model:ir.model,name:purchase_order_ubl_py3o.model_py3o_report +msgid "Report Py30" +msgstr "" + diff --git a/purchase_order_ubl_py3o/models/__init__.py b/purchase_order_ubl_py3o/models/__init__.py new file mode 100644 index 0000000000..f5828d0104 --- /dev/null +++ b/purchase_order_ubl_py3o/models/__init__.py @@ -0,0 +1 @@ +from . import py3o_report diff --git a/purchase_order_ubl_py3o/models/py3o_report.py b/purchase_order_ubl_py3o/models/py3o_report.py new file mode 100644 index 0000000000..3424c25f8f --- /dev/null +++ b/purchase_order_ubl_py3o/models/py3o_report.py @@ -0,0 +1,28 @@ +# Copyright 2017-2021 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class Py3oReport(models.TransientModel): + _inherit = "py3o.report" + + @api.model + def _ubl_purchase_order_report_names(self): + return ["purchase.report_purchaseorder", "purchase.report_purchasequotation"] + + def _postprocess_report(self, model_instance, result_path): + purchase_reports = self._ubl_purchase_order_report_names() + # We could match on object instead of report_name... + # but I'm not sure it's a better approach + if ( + self.ir_actions_report_id.report_name in purchase_reports + and self.ir_actions_report_id.report_type == "py3o" + and self.ir_actions_report_id.py3o_filetype == "pdf" + and model_instance + and result_path + ): + # re-write PDF on report_path + model_instance.embed_ubl_xml_in_pdf(None, pdf_file=result_path) + return super()._postprocess_report(model_instance, result_path) diff --git a/purchase_order_ubl_py3o/readme/CONFIGURE.rst b/purchase_order_ubl_py3o/readme/CONFIGURE.rst new file mode 100644 index 0000000000..05dcf8709a --- /dev/null +++ b/purchase_order_ubl_py3o/readme/CONFIGURE.rst @@ -0,0 +1 @@ +No configuration needed. diff --git a/purchase_order_ubl_py3o/readme/CONTRIBUTORS.rst b/purchase_order_ubl_py3o/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..ff65d68ce6 --- /dev/null +++ b/purchase_order_ubl_py3o/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Alexis de Lattre diff --git a/purchase_order_ubl_py3o/readme/DESCRIPTION.rst b/purchase_order_ubl_py3o/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..f6bf0baf63 --- /dev/null +++ b/purchase_order_ubl_py3o/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +If you use the py3o reporting engine (module *report_py3o_fusion_server* from the `reporting-engine `_ OCA project) to generate your PDF purchase orders/RFQs and you want these PDF documents to have an embedded UBL XML file, this module is for you! diff --git a/purchase_order_ubl_py3o/static/description/icon.png b/purchase_order_ubl_py3o/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/purchase_order_ubl_py3o/static/description/icon.png differ diff --git a/setup/purchase_order_ubl_py3o/odoo/addons/purchase_order_ubl_py3o b/setup/purchase_order_ubl_py3o/odoo/addons/purchase_order_ubl_py3o new file mode 120000 index 0000000000..ac2c8e19ec --- /dev/null +++ b/setup/purchase_order_ubl_py3o/odoo/addons/purchase_order_ubl_py3o @@ -0,0 +1 @@ +../../../../purchase_order_ubl_py3o \ No newline at end of file diff --git a/setup/purchase_order_ubl_py3o/setup.py b/setup/purchase_order_ubl_py3o/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/purchase_order_ubl_py3o/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)