Skip to content

Commit

Permalink
[MIG] purchase_order_ubl_py3o from v10 to v14
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-via committed Jul 13, 2023
1 parent 87be97d commit e3a8e6e
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 79 deletions.
5 changes: 2 additions & 3 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,8 +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

def get_ubl_purchase_order_doc_type(self):
Expand Down
53 changes: 1 addition & 52 deletions purchase_order_ubl_py3o/README.rst
Original file line number Diff line number Diff line change
@@ -1,52 +1 @@
.. 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

=======================
Py3o UBL Purchase Order
=======================

If you use the py3o reporting engine (module *report_py3o* 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 !

Configuration
=============

No configuration is needed.

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/226/10.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/edi/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
------------

* Alexis de Lattre <[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.
Will be re-generated from readme subdir
2 changes: 0 additions & 2 deletions purchase_order_ubl_py3o/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from . import models
10 changes: 5 additions & 5 deletions purchase_order_ubl_py3o/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (Alexis de Lattre <[email protected]>)
# 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': '10.0.1.0.0',
'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)',
'website': 'http://www.akretion.com',
'depends': ['purchase_order_ubl', 'report_py3o'],
'website': 'https://github.com/OCA/edi',
'depends': ['purchase_order_ubl', 'report_py3o_fusion_server'],
'installable': True,
}
2 changes: 0 additions & 2 deletions purchase_order_ubl_py3o/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from . import py3o_report
29 changes: 14 additions & 15 deletions purchase_order_ubl_py3o/models/py3o_report.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (Alexis de Lattre <[email protected]>)
# 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 models, api
from odoo import api, models


class Py3oReport(models.TransientModel):
_inherit = 'py3o.report'

@api.model
def _postprocess_report(self, report_path, res_id, save_in_attachment):
purchase_reports = [
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_xml_id.report_name
in purchase_reports and
self.ir_actions_report_xml_id.report_type == 'py3o' and
self.ir_actions_report_xml_id.py3o_filetype == 'pdf' and
res_id and
report_path):
order = self.env['purchase.order'].browse(res_id)
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
order.embed_ubl_xml_in_pdf(pdf_file=report_path)
return super(Py3oReport, self)._postprocess_report(
report_path, res_id, save_in_attachment)
model_instance.embed_ubl_xml_in_pdf(None, pdf_file=result_path)
return super()._postprocess_report(model_instance, result_path)
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!

0 comments on commit e3a8e6e

Please sign in to comment.