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] Add edi_purchase_ubl_oca #669

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions edi_purchase_ubl_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wait for the bot
1 change: 1 addition & 0 deletions edi_purchase_ubl_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import components
18 changes: 18 additions & 0 deletions edi_purchase_ubl_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2021 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "EDI UBL Purchase",
"summary": """Handle inbound / outbound exchanges for purchases.""",
"version": "14.0.1.0.0",
"development_status": "Alpha",
"license": "AGPL-3",
"website": "https://github.com/OCA/edi",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["simahawk"],
"depends": ["edi_oca", "edi_ubl_oca", "purchase_order_ubl"],
"demo": [
"demo/edi_exchange_type.xml",
],
}
1 change: 1 addition & 0 deletions edi_purchase_ubl_oca/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import generate
27 changes: 27 additions & 0 deletions edi_purchase_ubl_oca/components/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo.addons.component.core import Component


class EDIExchangePOGenerate(Component):
"""Generate purchase orders."""

_name = "edi.output.ubl.purchase.order"
_inherit = "edi.component.output.mixin"
_usage = "output.generate.purchase.order"

def generate(self):
return self._generate_ubl_xml()

# TODO: add tests
def _generate_ubl_xml(self):
order = self.record
doc_type = order.get_ubl_purchase_order_doc_type()
if not doc_type:
raise NotImplementedError("TODO: handle no doc type")
version = order.get_ubl_version()
xml_string = order.generate_ubl_xml_string(doc_type, version=version)
return xml_string
20 changes: 20 additions & 0 deletions edi_purchase_ubl_oca/demo/edi_exchange_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="demo_edi_exc_type_order_out" model="edi.exchange.type">
<field name="backend_type_id" ref="edi_ubl_oca.edi_backend_type_ubl" />
<field name="name">UBL PO out</field>
<field name="code">UBL_PO_out</field>
<field name="direction">output</field>
<field name="exchange_filename_pattern">{record_name}-{type.code}-{dt}</field>
<field name="exchange_file_ext">xml</field>
<field
name="model_ids"
eval="[(6, 0, [ref('purchase.model_purchase_order')])]"
/>
<field name="advanced_settings_edit">
components:
generate:
usage: output.generate.purchase.order
</field>
</record>
</odoo>
7 changes: 7 additions & 0 deletions edi_purchase_ubl_oca/readme/CONFIGURATION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
On your exchange type configured for UBL outbound exchanges use this conf in `advanced_settings_edit`::

components:
generate:
usage: output.generate.purchase.order

That's it.
1 change: 1 addition & 0 deletions edi_purchase_ubl_oca/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Simone Orsi <simone.orsi@camptocamp.com>
5 changes: 5 additions & 0 deletions edi_purchase_ubl_oca/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Handle purchase exchanges with the EDI framework.

This module is mostly a glue module for `purchase_order_ubl` with `edi_oca`.

Allows you to generate and send purchase orders as UBL XML files.
2 changes: 2 additions & 0 deletions purchase_order_ubl/tests/test_ubl_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ def test_ubl_generate(self):
elif order.state in rfq_states:
filename = order.get_ubl_filename("rfq", version=version)
self.assertTrue(filename in res)

# TODO: add tests to validate UBL data generation!
6 changes: 6 additions & 0 deletions setup/edi_purchase_ubl_oca/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,
)