Skip to content

Commit f4531cc

Browse files
committed
[14.0][BKP] sale_order_import_edifact backport from OCA#821
1 parent daab3b0 commit f4531cc

21 files changed

+1440
-0
lines changed

sale_order_import_edifact/README.rst

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
===========================================
2+
Import Business Document EDIFACT/D96A Order
3+
===========================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:46860173810e6f096acdc9b7aef8ddd3a5f7cbda5bde91f48aa52f65491a536d
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github
20+
:target: https://github.com/OCA/edi/tree/16.0/sale_order_import_edifact
21+
:alt: OCA/edi
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-sale_order_import_edifact
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
UN/EDIFACT
32+
United Nations rules for Elec­tronic Data Interchange for Administration, Commerce and Transport
33+
34+
This module plugs EDIFACT/D96A ORDER in sale_order_import process.
35+
36+
https://www.stedi.com/edi/edifact/D96A/messages/ORDERS
37+
38+
.. IMPORTANT::
39+
This is an alpha version, the data model and design can change at any time without warning.
40+
Only for development or testing purpose, do not use in production.
41+
`More details on development status <https://odoo-community.org/page/development-status>`_
42+
43+
**Table of contents**
44+
45+
.. contents::
46+
:local:
47+
48+
Configuration
49+
=============
50+
51+
52+
This module struggles with EDIFACT format, if you need X12 format you will need something like sale_order_import_x12 module.
53+
54+
Regardless format, a concret document should need a concret specification nammed release. For example Amazon uses "D96A" specification.
55+
56+
See <https://www.stedi.com/edi/edifact>
57+
58+
Known issues / Roadmap
59+
======================
60+
61+
* Move the previews button feature to the base module
62+
63+
Changelog
64+
=========
65+
66+
.. The change log. The goal of this file is to help readers
67+
understand changes between versions. The primary audience is
68+
end users and integrators. Purely technical changes such as
69+
code refactoring must not be mentioned here.
70+
71+
This file may contain ONE level of section titles, underlined
72+
with the ~ (tilde) character. Other section markers are
73+
forbidden and will likely break the structure of the README.rst
74+
or other documents where this fragment is included.
75+
76+
14.0.1.0.0 (2023-06-07)
77+
~~~~~~~~~~~~~~~~~~~~~~~
78+
79+
* [14.0][ADD] sale_order_import_edifact & base_edifact.
80+
(`#779 <https://github.com/OCA/edi/pull/779>`_)
81+
82+
Bug Tracker
83+
===========
84+
85+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/issues>`_.
86+
In case of trouble, please check there if your issue has already been reported.
87+
If you spotted it first, help us to smash it by providing a detailed and welcomed
88+
`feedback <https://github.com/OCA/edi/issues/new?body=module:%20sale_order_import_edifact%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
89+
90+
Do not contact contributors directly about support or help with technical issues.
91+
92+
Credits
93+
=======
94+
95+
Authors
96+
~~~~~~~
97+
98+
* ALBA Software
99+
* Camptocamp
100+
101+
Contributors
102+
~~~~~~~~~~~~
103+
104+
* Rafa Morant <rmorant@albasoft.com> (https://www.albasoft.com)
105+
* Marc Poch <mpoch@planetatic.com>
106+
* Duong (Tran Quoc) <duongtq@trobz.com>
107+
* Simone Orsi <simone.orsi@camptocamp.com>
108+
109+
Other credits
110+
~~~~~~~~~~~~~
111+
112+
The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp
113+
114+
Maintainers
115+
~~~~~~~~~~~
116+
117+
This module is maintained by the OCA.
118+
119+
.. image:: https://odoo-community.org/logo.png
120+
:alt: Odoo Community Association
121+
:target: https://odoo-community.org
122+
123+
OCA, or the Odoo Community Association, is a nonprofit organization whose
124+
mission is to support the collaborative development of Odoo features and
125+
promote its widespread use.
126+
127+
.. |maintainer-rmorant| image:: https://github.com/rmorant.png?size=40px
128+
:target: https://github.com/rmorant
129+
:alt: rmorant
130+
131+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
132+
133+
|maintainer-rmorant|
134+
135+
This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/16.0/sale_order_import_edifact>`_ project on GitHub.
136+
137+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sale_order_import_edifact/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from . import wizard
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2023 ALBA Software S.L.
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
3+
4+
{
5+
"name": "Import Business Document EDIFACT/D96A Order",
6+
"summary": "EDIFACT/D96A Order",
7+
"version": "14.0.1.1.0",
8+
"development_status": "Alpha",
9+
"category": "Sales Management",
10+
"website": "https://github.com/OCA/edi",
11+
"author": "ALBA Software, Camptocamp, Odoo Community Association (OCA)",
12+
"maintainers": ["rmorant"],
13+
"license": "AGPL-3",
14+
"depends": [
15+
"sale_management",
16+
"partner_identification_gln",
17+
"base_edifact",
18+
"sale_order_import",
19+
],
20+
"data": [
21+
"wizard/sale_order_import_view.xml",
22+
],
23+
"demo": ["demo/demo_data.xml"],
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="0">
3+
4+
<record id="partner_edi_dm" model="res.partner">
5+
<field name="name">AMATEST EU SARL</field>
6+
<field name="is_company" eval="True" />
7+
<field name="customer_rank" eval="1" />
8+
<field name="street">38 Avenue J.F. Kennedy</field>
9+
<field name="zip">1234</field>
10+
<field name="city">Luxembourg</field>
11+
<field name="country_id" ref="base.lu" />
12+
</record>
13+
<record id="partner_edi_shipto_dm" model="res.partner">
14+
<field name="name">AMATEST EU (TST)</field>
15+
<field name="parent_id" ref="partner_edi_dm" />
16+
<field name="street">80 Bojsdoeisn</field>
17+
<field name="zip">4321</field>
18+
<field name="city">Gliwice</field>
19+
<field name="country_id" ref="base.pl" />
20+
<field name="email" />
21+
<field name="type">delivery</field>
22+
</record>
23+
<record id="partner_edi_invoiceto_dm" model="res.partner">
24+
<field name="name">AMATEST Invoice</field>
25+
<field name="parent_id" ref="partner_edi_dm" />
26+
<field name="function">Accountant</field>
27+
<field name="customer_rank" eval="1" />
28+
<field name="type">invoice</field>
29+
</record>
30+
31+
32+
<record id="res_partner_id_number_edi" model="res.partner.id_number">
33+
<field
34+
name="category_id"
35+
ref="partner_identification_gln.partner_identification_gln_number_category"
36+
/>
37+
<field name="partner_id" ref="partner_edi_dm" />
38+
<field name="name">5450534000017</field>
39+
</record>
40+
<record id="res_partner_id_number_edi_shipto" model="res.partner.id_number">
41+
<field
42+
name="category_id"
43+
ref="partner_identification_gln.partner_identification_gln_number_category"
44+
/>
45+
<field name="partner_id" ref="partner_edi_shipto_dm" />
46+
<field name="name">5450534008617</field>
47+
</record>
48+
<record id="res_partner_id_number_edi_invoiceto" model="res.partner.id_number">
49+
<field
50+
name="category_id"
51+
ref="partner_identification_gln.partner_identification_gln_number_category"
52+
/>
53+
<field name="partner_id" ref="partner_edi_invoiceto_dm" />
54+
<field name="name">5450534008143</field>
55+
</record>
56+
57+
<record id="product_product_edifact1_dm" model="product.product">
58+
<field name="name">EDIFACT Demo 1</field>
59+
<field name="sale_ok" eval="True" />
60+
<field name="type">consu</field>
61+
<field name="default_code">edifact1</field>
62+
<field name="categ_id" ref="product.product_category_all" />
63+
<field name="barcode">9783898307529</field>
64+
</record>
65+
<record id="product_product_edifact2_dm" model="product.product">
66+
<field name="name">EDIFACT Demo 2</field>
67+
<field name="sale_ok" eval="True" />
68+
<field name="type">consu</field>
69+
<field name="default_code">edifac2</field>
70+
<field name="categ_id" ref="product.product_category_all" />
71+
<field name="barcode">9783898307538</field>
72+
</record>
73+
<record id="product_product_edifact3_dm" model="product.product">
74+
<field name="name">EDIFACT Demo 3</field>
75+
<field name="sale_ok" eval="True" />
76+
<field name="type">consu</field>
77+
<field name="default_code">edifact</field>
78+
<field name="categ_id" ref="product.product_category_all" />
79+
<field name="barcode">9783898307645</field>
80+
</record>
81+
<record id="product_product_edifact4_dm" model="product.product">
82+
<field name="name">Product1</field>
83+
<field name="sale_ok" eval="True" />
84+
<field name="type">consu</field>
85+
<field name="default_code">1276</field>
86+
<field name="categ_id" ref="product.product_category_all" />
87+
</record>
88+
<record id="product_product_edifact5_dm" model="product.product">
89+
<field name="name">Product2</field>
90+
<field name="sale_ok" eval="True" />
91+
<field name="type">consu</field>
92+
<field name="default_code">46630</field>
93+
<field name="categ_id" ref="product.product_category_all" />
94+
</record>
95+
<record id="product_product_edifact6_dm" model="product.product">
96+
<field name="name">Product3</field>
97+
<field name="sale_ok" eval="True" />
98+
<field name="type">consu</field>
99+
<field name="default_code">98891 75</field>
100+
<field name="categ_id" ref="product.product_category_all" />
101+
</record>
102+
<record id="product_product_edifact7_dm" model="product.product">
103+
<field name="name">Product4</field>
104+
<field name="sale_ok" eval="True" />
105+
<field name="type">consu</field>
106+
<field name="default_code">37230</field>
107+
<field name="categ_id" ref="product.product_category_all" />
108+
</record>
109+
<record id="product_product_edifact8_dm" model="product.product">
110+
<field name="name">Product5</field>
111+
<field name="sale_ok" eval="True" />
112+
<field name="type">consu</field>
113+
<field name="default_code">1076</field>
114+
<field name="categ_id" ref="product.product_category_all" />
115+
</record>
116+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import business_document_import
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2019 PlanetaTIC - Marc Poch <mpoch@planetatic.com>
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import _, api, exceptions, models
5+
6+
7+
class BusinessDocumentImport(models.AbstractModel):
8+
_inherit = "business.document.import"
9+
10+
# TODO: refactor code in partner_identification_import and drop this one
11+
@api.model
12+
def _hook_match_partner(self, partner_dict, chatter_msg, domain, order):
13+
"""
14+
2 types
15+
partner_dict = {'gln':""}
16+
partner_dict = {'partner': {'gln':""}, 'address':{'country_code':"ES",...}}
17+
"""
18+
partner = partner_dict.get("partner", partner_dict)
19+
partner_dict.get("address", False)
20+
if not partner.get("gln"):
21+
return super()._hook_match_partner(partner_dict, chatter_msg, domain, order)
22+
party_id = partner["gln"]
23+
24+
partner_id_category = self.env.ref(
25+
"partner_identification_gln.partner_identification_gln_number_category"
26+
)
27+
if not partner_id_category:
28+
raise exceptions.UserError(
29+
_(
30+
"partner_identification_gln module should be installed with a xmlid: "
31+
"partner_identification_gln_number_category"
32+
)
33+
)
34+
id_number = self.env["res.partner.id_number"].search(
35+
[("category_id", "=", int(partner_id_category)), ("name", "=", party_id)],
36+
limit=1,
37+
)
38+
if not id_number:
39+
ctx = partner.get(
40+
"edi_ctx", {"order_filename": _("Unknown"), "rff_va": _("Unknown")}
41+
)
42+
raise exceptions.UserError(
43+
_(
44+
"Partner GLN Code: %(party)s not found in order file: '%(file)s' "
45+
"from VAT registration number '%(vat)s'.",
46+
party=party_id,
47+
file=ctx.get("order_filename"),
48+
vat=ctx.get("rff_va"),
49+
)
50+
)
51+
52+
return id_number.partner_id
53+
54+
# @api.model
55+
# def post_create_or_update(self, parsed_dict, record, doc_filename=None):
56+
# if 'origin_exchange_record_id' in record.fields_get():
57+
# record.origin_exchange_record_id =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
This module struggles with EDIFACT format, if you need X12 format you will need something like sale_order_import_x12 module.
3+
4+
Regardless format, a concret document should need a concret specification nammed release. For example Amazon uses "D96A" specification.
5+
6+
See <https://www.stedi.com/edi/edifact>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* Rafa Morant <rmorant@albasoft.com> (https://www.albasoft.com)
2+
* Marc Poch <mpoch@planetatic.com>
3+
* Duong (Tran Quoc) <duongtq@trobz.com>
4+
* Simone Orsi <simone.orsi@camptocamp.com>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
UN/EDIFACT
2+
United Nations rules for Elec­tronic Data Interchange for Administration, Commerce and Transport
3+
4+
This module plugs EDIFACT/D96A ORDER in sale_order_import process.
5+
6+
https://www.stedi.com/edi/edifact/D96A/messages/ORDERS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. The change log. The goal of this file is to help readers
2+
understand changes between versions. The primary audience is
3+
end users and integrators. Purely technical changes such as
4+
code refactoring must not be mentioned here.
5+
6+
This file may contain ONE level of section titles, underlined
7+
with the ~ (tilde) character. Other section markers are
8+
forbidden and will likely break the structure of the README.rst
9+
or other documents where this fragment is included.
10+
11+
14.0.1.0.0 (2023-06-07)
12+
~~~~~~~~~~~~~~~~~~~~~~~
13+
14+
* [14.0][ADD] sale_order_import_edifact & base_edifact.
15+
(`#779 <https://github.com/OCA/edi/pull/779>`_)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Move the previews button feature to the base module
Loading

0 commit comments

Comments
 (0)