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][BKP] sale_order_import_edifact backport from PR 821 v16 #859

Closed
wants to merge 5 commits into from
Closed
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
137 changes: 137 additions & 0 deletions sale_order_import_edifact/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
===========================================
Import Business Document EDIFACT/D96A Order
===========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c713f38149d0a8b1ea09d0ff667663dde1cbb3dd0bba13fbd0312ec866a9703b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github
:target: https://github.com/OCA/edi/tree/14.0/sale_order_import_edifact
:alt: OCA/edi
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-sale_order_import_edifact
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

UN/EDIFACT
United Nations rules for Elec­tronic Data Interchange for Administration, Commerce and Transport

This module plugs EDIFACT/D96A ORDER in sale_order_import process.

https://www.stedi.com/edi/edifact/D96A/messages/ORDERS

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

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


This module struggles with EDIFACT format, if you need X12 format you will need something like sale_order_import_x12 module.

Regardless format, a concret document should need a concret specification nammed release. For example Amazon uses "D96A" specification.

See <https://www.stedi.com/edi/edifact>

Known issues / Roadmap
======================

* Move the previews button feature to the base module

Changelog
=========

.. The change log. The goal of this file is to help readers
understand changes between versions. The primary audience is
end users and integrators. Purely technical changes such as
code refactoring must not be mentioned here.

This file may contain ONE level of section titles, underlined
with the ~ (tilde) character. Other section markers are
forbidden and will likely break the structure of the README.rst
or other documents where this fragment is included.

14.0.1.0.0 (2023-06-07)
~~~~~~~~~~~~~~~~~~~~~~~

* [14.0][ADD] sale_order_import_edifact & base_edifact.
(`#779 <https://github.com/OCA/edi/pull/779>`_)

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/edi/issues/new?body=module:%20sale_order_import_edifact%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ALBA Software
* Camptocamp

Contributors
~~~~~~~~~~~~

* Rafa Morant <rmorant@albasoft.com> (https://www.albasoft.com)
* Marc Poch <mpoch@planetatic.com>
* Duong (Tran Quoc) <duongtq@trobz.com>
* Simone Orsi <simone.orsi@camptocamp.com>

Other credits
~~~~~~~~~~~~~

The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-rmorant| image:: https://github.com/rmorant.png?size=40px
:target: https://github.com/rmorant
:alt: rmorant

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-rmorant|

This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/14.0/sale_order_import_edifact>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions sale_order_import_edifact/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
24 changes: 24 additions & 0 deletions sale_order_import_edifact/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 ALBA Software S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

{
"name": "Import Business Document EDIFACT/D96A Order",
"summary": "EDIFACT/D96A Order",
"version": "14.0.1.1.0",
"development_status": "Alpha",
"category": "Sales Management",
"website": "https://github.com/OCA/edi",
"author": "ALBA Software, Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["rmorant"],
"license": "AGPL-3",
"depends": [
"sale_management",
"partner_identification_gln",
"base_edifact",
"sale_order_import",
],
"data": [
"wizard/sale_order_import_view.xml",
],
"demo": ["demo/demo_data.xml"],
}
116 changes: 116 additions & 0 deletions sale_order_import_edifact/demo/demo_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="0">

<record id="partner_edi_dm" model="res.partner">
<field name="name">AMATEST EU SARL</field>
<field name="is_company" eval="True" />
<field name="customer_rank" eval="1" />
<field name="street">38 Avenue J.F. Kennedy</field>
<field name="zip">1234</field>
<field name="city">Luxembourg</field>
<field name="country_id" ref="base.lu" />
</record>
<record id="partner_edi_shipto_dm" model="res.partner">
<field name="name">AMATEST EU (TST)</field>
<field name="parent_id" ref="partner_edi_dm" />
<field name="street">80 Bojsdoeisn</field>
<field name="zip">4321</field>
<field name="city">Gliwice</field>
<field name="country_id" ref="base.pl" />
<field name="email" />
<field name="type">delivery</field>
</record>
<record id="partner_edi_invoiceto_dm" model="res.partner">
<field name="name">AMATEST Invoice</field>
<field name="parent_id" ref="partner_edi_dm" />
<field name="function">Accountant</field>
<field name="customer_rank" eval="1" />
<field name="type">invoice</field>
</record>


<record id="res_partner_id_number_edi" model="res.partner.id_number">
<field
name="category_id"
ref="partner_identification_gln.partner_identification_gln_number_category"
/>
<field name="partner_id" ref="partner_edi_dm" />
<field name="name">5450534000017</field>
</record>
<record id="res_partner_id_number_edi_shipto" model="res.partner.id_number">
<field
name="category_id"
ref="partner_identification_gln.partner_identification_gln_number_category"
/>
<field name="partner_id" ref="partner_edi_shipto_dm" />
<field name="name">5450534008617</field>
</record>
<record id="res_partner_id_number_edi_invoiceto" model="res.partner.id_number">
<field
name="category_id"
ref="partner_identification_gln.partner_identification_gln_number_category"
/>
<field name="partner_id" ref="partner_edi_invoiceto_dm" />
<field name="name">5450534008143</field>
</record>

<record id="product_product_edifact1_dm" model="product.product">
<field name="name">EDIFACT Demo 1</field>
<field name="sale_ok" eval="True" />
<field name="type">consu</field>
<field name="default_code">edifact1</field>
<field name="categ_id" ref="product.product_category_all" />
<field name="barcode">9783898307529</field>
</record>
<record id="product_product_edifact2_dm" model="product.product">
<field name="name">EDIFACT Demo 2</field>
<field name="sale_ok" eval="True" />
<field name="type">consu</field>
<field name="default_code">edifac2</field>
<field name="categ_id" ref="product.product_category_all" />
<field name="barcode">9783898307538</field>
</record>
<record id="product_product_edifact3_dm" model="product.product">
<field name="name">EDIFACT Demo 3</field>
<field name="sale_ok" eval="True" />
<field name="type">consu</field>
<field name="default_code">edifact</field>
<field name="categ_id" ref="product.product_category_all" />
<field name="barcode">9783898307645</field>
</record>
<record id="product_product_edifact4_dm" model="product.product">
<field name="name">Product1</field>
<field name="sale_ok" eval="True" />
<field name="type">consu</field>
<field name="default_code">1276</field>
<field name="categ_id" ref="product.product_category_all" />
</record>
<record id="product_product_edifact5_dm" model="product.product">
<field name="name">Product2</field>
<field name="sale_ok" eval="True" />
<field name="type">consu</field>
<field name="default_code">46630</field>
<field name="categ_id" ref="product.product_category_all" />
</record>
<record id="product_product_edifact6_dm" model="product.product">
<field name="name">Product3</field>
<field name="sale_ok" eval="True" />
<field name="type">consu</field>
<field name="default_code">98891 75</field>
<field name="categ_id" ref="product.product_category_all" />
</record>
<record id="product_product_edifact7_dm" model="product.product">
<field name="name">Product4</field>
<field name="sale_ok" eval="True" />
<field name="type">consu</field>
<field name="default_code">37230</field>
<field name="categ_id" ref="product.product_category_all" />
</record>
<record id="product_product_edifact8_dm" model="product.product">
<field name="name">Product5</field>
<field name="sale_ok" eval="True" />
<field name="type">consu</field>
<field name="default_code">1076</field>
<field name="categ_id" ref="product.product_category_all" />
</record>
</odoo>
1 change: 1 addition & 0 deletions sale_order_import_edifact/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import business_document_import
57 changes: 57 additions & 0 deletions sale_order_import_edifact/models/business_document_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2019 PlanetaTIC - Marc Poch <mpoch@planetatic.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, exceptions, models


class BusinessDocumentImport(models.AbstractModel):
_inherit = "business.document.import"

# TODO: refactor code in partner_identification_import and drop this one
@api.model
def _hook_match_partner(self, partner_dict, chatter_msg, domain, order):
"""
2 types
partner_dict = {'gln':""}
partner_dict = {'partner': {'gln':""}, 'address':{'country_code':"ES",...}}
"""
partner = partner_dict.get("partner", partner_dict)
partner_dict.get("address", False)
if not partner.get("gln"):
return super()._hook_match_partner(partner_dict, chatter_msg, domain, order)
party_id = partner["gln"]

partner_id_category = self.env.ref(
"partner_identification_gln.partner_identification_gln_number_category"
)
if not partner_id_category:
raise exceptions.UserError(
_(
"partner_identification_gln module should be installed with a xmlid: "
"partner_identification_gln_number_category"
)
)
id_number = self.env["res.partner.id_number"].search(
[("category_id", "=", int(partner_id_category)), ("name", "=", party_id)],
limit=1,
)
if not id_number:
ctx = partner.get(
"edi_ctx", {"order_filename": _("Unknown"), "rff_va": _("Unknown")}
)
raise exceptions.UserError(
_(
"Partner GLN Code: %(party)s not found in order file: '%(file)s' "
"from VAT registration number '%(vat)s'.",
party=party_id,
file=ctx.get("order_filename"),
vat=ctx.get("rff_va"),
)
)

return id_number.partner_id

# @api.model
# def post_create_or_update(self, parsed_dict, record, doc_filename=None):
# if 'origin_exchange_record_id' in record.fields_get():
# record.origin_exchange_record_id =
6 changes: 6 additions & 0 deletions sale_order_import_edifact/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

This module struggles with EDIFACT format, if you need X12 format you will need something like sale_order_import_x12 module.

Regardless format, a concret document should need a concret specification nammed release. For example Amazon uses "D96A" specification.

See <https://www.stedi.com/edi/edifact>
4 changes: 4 additions & 0 deletions sale_order_import_edifact/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Rafa Morant <rmorant@albasoft.com> (https://www.albasoft.com)
* Marc Poch <mpoch@planetatic.com>
* Duong (Tran Quoc) <duongtq@trobz.com>
* Simone Orsi <simone.orsi@camptocamp.com>
1 change: 1 addition & 0 deletions sale_order_import_edifact/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp
6 changes: 6 additions & 0 deletions sale_order_import_edifact/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
UN/EDIFACT
United Nations rules for Elec­tronic Data Interchange for Administration, Commerce and Transport

This module plugs EDIFACT/D96A ORDER in sale_order_import process.

https://www.stedi.com/edi/edifact/D96A/messages/ORDERS
15 changes: 15 additions & 0 deletions sale_order_import_edifact/readme/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. The change log. The goal of this file is to help readers
understand changes between versions. The primary audience is
end users and integrators. Purely technical changes such as
code refactoring must not be mentioned here.

This file may contain ONE level of section titles, underlined
with the ~ (tilde) character. Other section markers are
forbidden and will likely break the structure of the README.rst
or other documents where this fragment is included.

14.0.1.0.0 (2023-06-07)
~~~~~~~~~~~~~~~~~~~~~~~

* [14.0][ADD] sale_order_import_edifact & base_edifact.
(`#779 <https://github.com/OCA/edi/pull/779>`_)
1 change: 1 addition & 0 deletions sale_order_import_edifact/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Move the previews button feature to the base module
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading