-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
[16.0][MIG] sale_order_import_edifact: Migration to 16.0 #821
Merged
OCA-git-bot
merged 13 commits into
OCA:16.0
from
QuocDuong1306:16.0-mig-sale_order_import_edifact
Nov 13, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fd17474
[14.0][MIG] sale_order_import_edifact & base_edifact
rmorant d62038b
[FIX] base_edifact: test chore
rmorant aa22ea3
[IMP] sale_order_import_edifact: pre-commit stuff
0d867a5
[MIG] sale_order_import_edifact: Migration to 16.0
1ed75fa
[FIX] sale_order_import_edifact: Allow files without vat
thienvh332 9132a03
[FIX] sale_order_import_edifact: fix get quantity form QTY segment
thienvh332 69443ba
[FIX] sale_order_import_edifact: fix problem product price is not pro…
thienvh332 116ffae
[IMP] sale_order_import_edifact: Fallback on PIA (SA) when LIN is empty
thienvh332 880c4a1
[IMP] sale_order_import_edifact: support get product desciption from …
thienvh332 0facfa5
[IMP] sale_order_import_edifact: add new data demo
thienvh332 f796b06
[IMP] sale_order_import_edifact: add testcase for no ean in LIN segment
thienvh332 a5efa96
[IMP] sale_order_import_edifact: add testcase for no PRI segment
thienvh332 a22cf47
[IMP] sale_order_import_edifact: support EDI files with no extension
nilshamerlinck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:46860173810e6f096acdc9b7aef8ddd3a5f7cbda5bde91f48aa52f65491a536d | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |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/16.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-16-0/edi-16-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=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
UN/EDIFACT | ||
United Nations rules for Electronic 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:%2016.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 <[email protected]> (https://www.albasoft.com) | ||
* Marc Poch <[email protected]> | ||
* Duong (Tran Quoc) <[email protected]> | ||
* Simone Orsi <[email protected]> | ||
|
||
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/16.0/sale_order_import_edifact>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "16.0.1.0.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"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import business_document_import |
57 changes: 57 additions & 0 deletions
57
sale_order_import_edifact/models/business_document_import.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright 2019 PlanetaTIC - Marc Poch <[email protected]> | ||
# 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 = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* Rafa Morant <[email protected]> (https://www.albasoft.com) | ||
* Marc Poch <[email protected]> | ||
* Duong (Tran Quoc) <[email protected]> | ||
simahawk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* Simone Orsi <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
UN/EDIFACT | ||
United Nations rules for Electronic 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>`_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
matching a partner via gln should be a generic thing... what is really needed here that is specific to edifact?
IMO there's something "wrong" or "too rigid" here
edi/partner_identification_import/models/business_document_import.py
Line 15 in d9309db
If you don't have time to solve it now, I would a TODO to refactor that piece of code and drop this one.
CC @jbaudoux