Skip to content

Commit bddb86a

Browse files
author
duongtq
committed
[MIG] sale_order_import_edifact: Migration to 16.0
1 parent 0e4d79e commit bddb86a

File tree

9 files changed

+55
-104
lines changed

9 files changed

+55
-104
lines changed

sale_order_import_edifact/README.rst

+19-34
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
Import Business Document EDIFACT/D96A Order
33
===========================================
44

5-
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
67
!! This file is generated by oca-gen-addon-readme !!
78
!! changes will be overwritten. !!
89
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:5cd158dc563903a96f99facfaf42f4dc8bb231b12be898d0191b604023bb5caa
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
912
1013
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
1114
:target: https://odoo-community.org/page/development-status
@@ -14,16 +17,16 @@ Import Business Document EDIFACT/D96A Order
1417
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1518
:alt: License: AGPL-3
1619
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github
17-
:target: https://github.com/OCA/edi/tree/14.0/sale_order_import_edifact
20+
:target: https://github.com/OCA/edi/tree/16.0/sale_order_import_edifact
1821
:alt: OCA/edi
1922
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20-
:target: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-sale_order_import_edifact
23+
:target: https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-sale_order_import_edifact
2124
:alt: Translate me on Weblate
22-
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/226/14.0
24-
:alt: Try me on Runbot
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
2528

26-
|badge1| |badge2| |badge3| |badge4| |badge5|
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
2730

2831
UN/EDIFACT
2932
United Nations rules for Elec­tronic Data Interchange for Administration, Commerce and Transport
@@ -46,30 +49,6 @@ Configuration
4649
=============
4750

4851

49-
EDI Exchange Type "Advanced Settings"
50-
51-
.. code-block:: yaml
52-
53-
components:
54-
process:
55-
usage: input.process.sale.order
56-
57-
sale_order_import:
58-
price_source: order
59-
confirm_order: false
60-
wiz_ctx:
61-
file_ext: 'edi'
62-
release: 'd96a'
63-
doc_type: 'rfq'
64-
65-
66-
- price_source. Can be 'order' or 'pricelist'
67-
- confirm_order. False by default
68-
- wiz_ctx. Wizard's context
69-
- file_ext. File extensions supported. By default: 'txt,d96a'
70-
- release. EDIFACT format release.
71-
- doc_type. ('rfq', "Request for Quotation") | ('order', "Order"). Default 'order'
72-
7352
This module struggles with EDIFACT format, if you need X12 format you will need something like sale_order_import_x12 module.
7453

7554
Regardless format, a concret document should need a concret specification nammed release. For example Amazon uses "D96A" specification.
@@ -109,8 +88,8 @@ Bug Tracker
10988

11089
Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/issues>`_.
11190
In case of trouble, please check there if your issue has already been reported.
112-
If you spotted it first, help us smashing it by providing a detailed and welcomed
113-
`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**>`_.
91+
If you spotted it first, help us to smash it by providing a detailed and welcomed
92+
`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**>`_.
11493

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

@@ -127,6 +106,12 @@ Contributors
127106

128107
* Rafa Morant <rmorant@albasoft.com> (https://www.albasoft.com)
129108
* Marc Poch <mpoch@planetatic.com>
109+
* Duong (Tran Quoc) <duongtq@trobz.com>
110+
111+
Other credits
112+
~~~~~~~~~~~~~
113+
114+
The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp
130115

131116
Maintainers
132117
~~~~~~~~~~~
@@ -149,6 +134,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
149134

150135
|maintainer-rmorant|
151136

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

154139
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sale_order_import_edifact/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Import Business Document EDIFACT/D96A Order",
66
"summary": "EDIFACT/D96A Order",
7-
"version": "14.0.1.0.0",
7+
"version": "16.0.1.0.0",
88
"development_status": "Alpha",
99
"category": "Sales Management",
1010
"website": "https://github.com/OCA/edi",
@@ -22,7 +22,7 @@
2222
"partner_identification",
2323
"partner_identification_gln",
2424
"base_edifact",
25-
"edi_sale_order_import",
25+
"sale_order_import",
2626
],
2727
"data": [
2828
"wizard/sale_order_import_view.xml",

sale_order_import_edifact/models/business_document_import.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ def _hook_match_partner(self, partner_dict, chatter_msg, domain, order):
4040
)
4141
raise exceptions.UserError(
4242
_(
43-
"Partner GLN Code: %s not found in order file: '%s' "
44-
"from VAT registration number '%s'."
43+
"Partner GLN Code: %(party)s not found in order file: '%(file)s' "
44+
"from VAT registration number '%(vat)s'.",
45+
party=party_id,
46+
file=ctx.get("order_filename"),
47+
vat=ctx.get("rff_va"),
4548
)
46-
% (party_id, ctx.get("order_filename"), ctx.get("rff_va"))
4749
)
4850

4951
return id_number.partner_id

sale_order_import_edifact/readme/CONFIGURE.rst

-24
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
11

2-
EDI Exchange Type "Advanced Settings"
3-
4-
.. code-block:: yaml
5-
6-
components:
7-
process:
8-
usage: input.process.sale.order
9-
10-
sale_order_import:
11-
price_source: order
12-
confirm_order: false
13-
wiz_ctx:
14-
file_ext: 'edi'
15-
release: 'd96a'
16-
doc_type: 'rfq'
17-
18-
19-
- price_source. Can be 'order' or 'pricelist'
20-
- confirm_order. False by default
21-
- wiz_ctx. Wizard's context
22-
- file_ext. File extensions supported. By default: 'txt,d96a'
23-
- release. EDIFACT format release.
24-
- doc_type. ('rfq', "Request for Quotation") | ('order', "Order"). Default 'order'
25-
262
This module struggles with EDIFACT format, if you need X12 format you will need something like sale_order_import_x12 module.
273

284
Regardless format, a concret document should need a concret specification nammed release. For example Amazon uses "D96A" specification.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
* Rafa Morant <rmorant@albasoft.com> (https://www.albasoft.com)
22
* Marc Poch <mpoch@planetatic.com>
3+
* Duong (Tran Quoc) <duongtq@trobz.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

sale_order_import_edifact/static/description/index.html

+14-28
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,10 @@ <h1 class="title">Import Business Document EDIFACT/D96A Order</h1>
366366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370+
!! source digest: sha256:5cd158dc563903a96f99facfaf42f4dc8bb231b12be898d0191b604023bb5caa
369371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
370-
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/edi/tree/14.0/sale_order_import_edifact"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-sale_order_import_edifact"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/226/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/edi/tree/16.0/sale_order_import_edifact"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-sale_order_import_edifact"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/edi&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
371373
<dl class="docutils">
372374
<dt>UN/EDIFACT</dt>
373375
<dd>United Nations rules for Elec­tronic Data Interchange for Administration, Commerce and Transport</dd>
@@ -393,35 +395,14 @@ <h1 class="title">Import Business Document EDIFACT/D96A Order</h1>
393395
<li><a class="reference internal" href="#credits" id="id8">Credits</a><ul>
394396
<li><a class="reference internal" href="#authors" id="id9">Authors</a></li>
395397
<li><a class="reference internal" href="#contributors" id="id10">Contributors</a></li>
396-
<li><a class="reference internal" href="#maintainers" id="id11">Maintainers</a></li>
398+
<li><a class="reference internal" href="#other-credits" id="id11">Other credits</a></li>
399+
<li><a class="reference internal" href="#maintainers" id="id12">Maintainers</a></li>
397400
</ul>
398401
</li>
399402
</ul>
400403
</div>
401404
<div class="section" id="configuration">
402405
<h1><a class="toc-backref" href="#id3">Configuration</a></h1>
403-
<p>EDI Exchange Type “Advanced Settings”</p>
404-
<pre class="code yaml literal-block">
405-
<span class="nt">components</span><span class="p">:</span><span class="w">
406-
</span><span class="nt">process</span><span class="p">:</span><span class="w">
407-
</span><span class="nt">usage</span><span class="p">:</span><span class="w"> </span><span class="l-Scalar-Plain">input.process.sale.order</span><span class="w">
408-
409-
</span><span class="nt">sale_order_import</span><span class="p">:</span><span class="w">
410-
</span><span class="nt">price_source</span><span class="p">:</span><span class="w"> </span><span class="l-Scalar-Plain">order</span><span class="w">
411-
</span><span class="nt">confirm_order</span><span class="p">:</span><span class="w"> </span><span class="l-Scalar-Plain">false</span><span class="w">
412-
</span><span class="nt">wiz_ctx</span><span class="p">:</span><span class="w">
413-
</span><span class="nt">file_ext</span><span class="p">:</span><span class="w"> </span><span class="s">'edi'</span><span class="w">
414-
</span><span class="nt">release</span><span class="p">:</span><span class="w"> </span><span class="s">'d96a'</span><span class="w">
415-
</span><span class="nt">doc_type</span><span class="p">:</span><span class="w"> </span><span class="s">'rfq'</span>
416-
</pre>
417-
<ul class="simple">
418-
<li>price_source. Can be ‘order’ or ‘pricelist’</li>
419-
<li>confirm_order. False by default</li>
420-
<li>wiz_ctx. Wizard’s context
421-
- file_ext. File extensions supported. By default: ‘txt,d96a’
422-
- release. EDIFACT format release.
423-
- doc_type. (‘rfq’, “Request for Quotation”) | (‘order’, “Order”). Default ‘order’</li>
424-
</ul>
425406
<p>This module struggles with EDIFACT format, if you need X12 format you will need something like sale_order_import_x12 module.</p>
426407
<p>Regardless format, a concret document should need a concret specification nammed release. For example Amazon uses “D96A” specification.</p>
427408
<p>See &lt;<a class="reference external" href="https://www.stedi.com/edi/edifact">https://www.stedi.com/edi/edifact</a>&gt;</p>
@@ -458,8 +439,8 @@ <h2><a class="toc-backref" href="#id6">14.0.1.0.0 (2023-06-07)</a></h2>
458439
<h1><a class="toc-backref" href="#id7">Bug Tracker</a></h1>
459440
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/edi/issues">GitHub Issues</a>.
460441
In case of trouble, please check there if your issue has already been reported.
461-
If you spotted it first, help us smashing it by providing a detailed and welcomed
462-
<a class="reference external" href="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**">feedback</a>.</p>
442+
If you spotted it first, help us to smash it by providing a detailed and welcomed
443+
<a class="reference external" href="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**">feedback</a>.</p>
463444
<p>Do not contact contributors directly about support or help with technical issues.</p>
464445
</div>
465446
<div class="section" id="credits">
@@ -475,18 +456,23 @@ <h2><a class="toc-backref" href="#id10">Contributors</a></h2>
475456
<ul class="simple">
476457
<li>Rafa Morant &lt;<a class="reference external" href="mailto:rmorant&#64;albasoft.com">rmorant&#64;albasoft.com</a>&gt; (<a class="reference external" href="https://www.albasoft.com">https://www.albasoft.com</a>)</li>
477458
<li>Marc Poch &lt;<a class="reference external" href="mailto:mpoch&#64;planetatic.com">mpoch&#64;planetatic.com</a>&gt;</li>
459+
<li>Duong (Tran Quoc) &lt;<a class="reference external" href="mailto:duongtq&#64;trobz.com">duongtq&#64;trobz.com</a>&gt;</li>
478460
</ul>
479461
</div>
462+
<div class="section" id="other-credits">
463+
<h2><a class="toc-backref" href="#id11">Other credits</a></h2>
464+
<p>The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp</p>
465+
</div>
480466
<div class="section" id="maintainers">
481-
<h2><a class="toc-backref" href="#id11">Maintainers</a></h2>
467+
<h2><a class="toc-backref" href="#id12">Maintainers</a></h2>
482468
<p>This module is maintained by the OCA.</p>
483469
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
484470
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
485471
mission is to support the collaborative development of Odoo features and
486472
promote its widespread use.</p>
487473
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
488474
<p><a class="reference external" href="https://github.com/rmorant"><img alt="rmorant" src="https://github.com/rmorant.png?size=40px" /></a></p>
489-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/14.0/sale_order_import_edifact">OCA/edi</a> project on GitHub.</p>
475+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/16.0/sale_order_import_edifact">OCA/edi</a> project on GitHub.</p>
490476
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
491477
</div>
492478
</div>

sale_order_import_edifact/tests/test_edifact_order_import.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def test_edifact_order_import(self):
1717
edifact_file = expected._get_content()
1818
wiz = self.env["sale.order.import"].create(
1919
{
20+
"import_type": "edifact",
2021
"order_file": base64.b64encode(edifact_file),
2122
"order_filename": filename,
2223
}

sale_order_import_edifact/wizard/sale_order_import.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class SaleOrderImportEdifact(models.TransientModel):
1414
_name = "sale.order.import"
1515
_inherit = ["sale.order.import", "base.edifact"]
1616

17+
import_type = fields.Selection(
18+
selection_add=[("edifact", "EDIFACT")], ondelete={"edifact": "cascade"}
19+
)
1720
state = fields.Selection(
1821
selection_add=[("tech", "Technical")], ondelete={"tech": "set default"}
1922
)
@@ -34,7 +37,6 @@ def edifact_ok(self):
3437
@api.onchange("order_file")
3538
def order_file_change(self):
3639
if self.edifact_ok:
37-
self.csv_import = False
3840
self.doc_type = self.env.context.get("doc_type", "rfq")
3941
self.price_source = "order"
4042
else:
@@ -66,21 +68,18 @@ def parse_order_button(self):
6668
action["res_id"] = self.id
6769
return action
6870

69-
# Parser hook
70-
def _parse_file(self, filename, filecontent, detect_doc_type=False):
71-
"Called from parse_order()"
72-
parsed_order = super(SaleOrderImportEdifact, self)._parse_file(
73-
filename, filecontent, detect_doc_type
74-
)
75-
if not parsed_order and self.edifact_ok:
76-
self.env.context.get("release", "d96a")
77-
interchange = self._loads_edifact(filecontent)
78-
parsed_order = self.parse_edifact_sale_order(interchange)
79-
return parsed_order
71+
def _get_supported_types(self):
72+
# Add more types for EDIFACT
73+
res = super()._get_supported_types()
74+
res.update({"edifact": ("text/plain")})
75+
return res
8076

8177
@api.model
82-
def parse_edifact_sale_order(self, interchange):
78+
def parse_edifact_order(self, filecontent, detect_doc_type):
8379
# https://github.com/nerdocs/pydifact/blob/master/pydifact/segmentcollection.py
80+
if not self.edifact_ok:
81+
return None
82+
interchange = self._loads_edifact(filecontent)
8483
header = interchange.get_header_segment()
8584
# > UNB segment: [['UNOA', '2'], ['5450534000000', '14'],
8685
# ['8435337000003', '14'], ['230306', '0435'], '5506']

0 commit comments

Comments
 (0)