Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ addon | version | maintainers | summary
[edi_account_core_oca](edi_account_core_oca/) | 18.0.1.1.1 | <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Define EDI Configuration for Account Moves
[edi_account_oca](edi_account_oca/) | 18.0.1.1.1 | <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Define some component listeners for Account Moves
[edi_component_oca](edi_component_oca/) | 18.0.1.1.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Allow to use Connector as a source in EDI
[edi_core_oca](edi_core_oca/) | 18.0.1.7.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Define backends, exchange types, exchange records, basic automation and views for handling EDI exchanges.
[edi_core_oca](edi_core_oca/) | 18.0.1.7.1 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Define backends, exchange types, exchange records, basic automation and views for handling EDI exchanges.
[edi_endpoint_oca](edi_endpoint_oca/) | 18.0.1.0.3 | | Base module allowing configuration of custom endpoints for EDI framework.
[edi_exchange_template_oca](edi_exchange_template_oca/) | 18.0.1.3.3 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Allows definition of exchanges via templates.
[edi_exchange_template_party_data](edi_exchange_template_party_data/) | 18.0.1.0.1 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Glue module between edi_exchange_template and edi_party_data
Expand Down
2 changes: 1 addition & 1 deletion edi_core_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EDI
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:27258fb23153f2660be19d7c76b04c4d09d35d1e240b779076c7f4a9fa66d9f2
!! source digest: sha256:aa0c40a082ced3e5e5d376f0eaf4c3a4487421a5abc4c22a81665a279bddaad1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion edi_core_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Define backends, exchange types, exchange records,
basic automation and views for handling EDI exchanges.
""",
"version": "18.0.1.7.0",
"version": "18.0.1.7.1",
"website": "https://github.com/OCA/edi-framework",
"development_status": "Beta",
"license": "LGPL-3",
Expand Down
2 changes: 1 addition & 1 deletion edi_core_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>EDI</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:27258fb23153f2660be19d7c76b04c4d09d35d1e240b779076c7f4a9fa66d9f2
!! source digest: sha256:aa0c40a082ced3e5e5d376f0eaf4c3a4487421a5abc4c22a81665a279bddaad1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/edi-framework/tree/18.0/edi_core_oca"><img alt="OCA/edi-framework" src="https://img.shields.io/badge/github-OCA%2Fedi--framework-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/edi-framework-18-0/edi-framework-18-0-edi_core_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/edi-framework&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Base EDI backend.</p>
Expand Down
66 changes: 66 additions & 0 deletions edi_core_oca/tests/test_backend_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@


class EDIBackendTestCaseBase(EDIBackendCommonTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.default_record = cls.backend.create_record(
"test_csv_input",
{"model": cls.partner._name, "res_id": cls.partner.id},
)

def setUp(self):
super().setUp()
self.loader = FakeModelLoader(self.env, self.__module__)
Expand Down Expand Up @@ -92,3 +100,61 @@ def test_get_handler_no_handler(self):
for action in ["receive", "input_validate", "process"]:
with self.assertRaises(EDINotImplementedError):
self.backend._get_exec_handler(record, action)

# ---- conf / env_ctx resolution ------------------------------------------

def test_get_conf_for_record(self):
"""`_get_conf_for_record` returns the action conf, or {} when missing."""
self.exchange_type_in.advanced_settings_edit = (
"execution_model:\n"
" receive:\n"
" env_ctx:\n"
" foo: bar\n"
" other_key: 1\n"
)
record = self.default_record
# Action declared -> its conf
self.assertEqual(
self.backend._get_conf_for_record(record, "receive"),
{"env_ctx": {"foo": "bar"}, "other_key": 1},
)
# Action not declared -> empty
self.assertEqual(self.backend._get_conf_for_record(record, "process"), {})

def test_get_record_env_ctx(self):
"""`_get_record_env_ctx` returns env_ctx for the action, else {}."""
self.exchange_type_in.advanced_settings_edit = (
"execution_model:\n"
" receive:\n"
" env_ctx:\n"
" foo: bar\n"
" flag: true\n"
" process:\n"
" other_key: 1\n"
)
record = self.default_record
# Action with env_ctx -> mapping
self.assertEqual(
self.backend._get_record_env_ctx(record, "receive"),
{"foo": "bar", "flag": True},
)
# Action present but no env_ctx -> empty
self.assertEqual(self.backend._get_record_env_ctx(record, "process"), {})

def test_get_exec_handler_propagates_env_ctx(self):
"""The handler returned by `_get_exec_handler` carries env_ctx keys."""
self.exchange_type_in.advanced_settings_edit = (
"execution_model:\n"
" receive:\n"
" env_ctx:\n"
" edi_test_marker: hello\n"
" edi_test_flag: true\n"
)
record = self.default_record
handler = self.backend._get_exec_handler(record, "receive")
ctx = handler.__self__.env.context
self.assertEqual(ctx.get("edi_test_marker"), "hello")
self.assertEqual(ctx.get("edi_test_flag"), True)
# Action without env_ctx -> handler context not polluted
handler_proc = self.backend._get_exec_handler(record, "process")
self.assertNotIn("edi_test_marker", handler_proc.__self__.env.context)
Loading