Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][MIG] purchase_order_ubl_py3o #799

Merged
merged 8 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions purchase_order_ubl/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions purchase_order_ubl_py3o/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Will be re-generated from readme subdir
1 change: 1 addition & 0 deletions purchase_order_ubl_py3o/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions purchase_order_ubl_py3o/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2017-2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <[email protected]>
# 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,
}
24 changes: 24 additions & 0 deletions purchase_order_ubl_py3o/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_order_ubl_py3o
#
# Translators:
# enjolras <[email protected]>, 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 <[email protected]>, 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"
20 changes: 20 additions & 0 deletions purchase_order_ubl_py3o/i18n/purchase_order_ubl_py3o.pot
Original file line number Diff line number Diff line change
@@ -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 ""

1 change: 1 addition & 0 deletions purchase_order_ubl_py3o/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import py3o_report
28 changes: 28 additions & 0 deletions purchase_order_ubl_py3o/models/py3o_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2017-2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <[email protected]>
# 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"]

Check warning on line 13 in purchase_order_ubl_py3o/models/py3o_report.py

View check run for this annotation

Codecov / codecov/patch

purchase_order_ubl_py3o/models/py3o_report.py#L13

Added line #L13 was not covered by tests

def _postprocess_report(self, model_instance, result_path):
purchase_reports = self._ubl_purchase_order_report_names()

Check warning on line 16 in purchase_order_ubl_py3o/models/py3o_report.py

View check run for this annotation

Codecov / codecov/patch

purchase_order_ubl_py3o/models/py3o_report.py#L16

Added line #L16 was not covered by tests
# 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)

Check warning on line 28 in purchase_order_ubl_py3o/models/py3o_report.py

View check run for this annotation

Codecov / codecov/patch

purchase_order_ubl_py3o/models/py3o_report.py#L27-L28

Added lines #L27 - L28 were not covered by tests
1 change: 1 addition & 0 deletions purchase_order_ubl_py3o/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No configuration needed.
1 change: 1 addition & 0 deletions purchase_order_ubl_py3o/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Alexis de Lattre <[email protected]>
1 change: 1 addition & 0 deletions purchase_order_ubl_py3o/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If you use the py3o reporting engine (module *report_py3o_fusion_server* from the `reporting-engine <https://github.com/OCA/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!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions setup/purchase_order_ubl_py3o/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading