Skip to content

Commit 9f0c7b9

Browse files
imlopesvictorvermot
authored andcommitted
[ADD] edi_exchange_template_oca_json
1 parent 12b6703 commit 9f0c7b9

File tree

12 files changed

+621
-0
lines changed

12 files changed

+621
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
==========================================
2+
EDI Exchange Template - Add JSON generator
3+
==========================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:81ee8002397b75724a8d89327a5ca3eb2eaa0a717e2ad37894751baff75a3425
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi--framework-lightgray.png?logo=github
20+
:target: https://github.com/OCA/edi-framework/tree/18.0/edi_exchange_template_oca_json
21+
:alt: OCA/edi-framework
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/edi-framework-18-0/edi-framework-18-0-edi_exchange_template_oca_json
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-framework&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Provide extra JSON generator type for EDI exchange templates.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Bug Tracker
39+
===========
40+
41+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi-framework/issues>`_.
42+
In case of trouble, please check there if your issue has already been reported.
43+
If you spotted it first, help us to smash it by providing a detailed and welcomed
44+
`feedback <https://github.com/OCA/edi-framework/issues/new?body=module:%20edi_exchange_template_oca_json%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
45+
46+
Do not contact contributors directly about support or help with technical issues.
47+
48+
Credits
49+
=======
50+
51+
Authors
52+
-------
53+
54+
* Camptocamp
55+
56+
Contributors
57+
------------
58+
59+
- Italo Lopes <italo.lopes@camptocamp.com>
60+
61+
Maintainers
62+
-----------
63+
64+
This module is maintained by the OCA.
65+
66+
.. image:: https://odoo-community.org/logo.png
67+
:alt: Odoo Community Association
68+
:target: https://odoo-community.org
69+
70+
OCA, or the Odoo Community Association, is a nonprofit organization whose
71+
mission is to support the collaborative development of Odoo features and
72+
promote its widespread use.
73+
74+
This module is part of the `OCA/edi-framework <https://github.com/OCA/edi-framework/tree/18.0/edi_exchange_template_oca_json>`_ project on GitHub.
75+
76+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2025 Camptocamp SA
2+
# @author Italo LOPES <italo.lopes@camptocamp.com>
3+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
4+
{
5+
"name": "EDI Exchange Template - Add JSON generator",
6+
"summary": """EDI Exchange Template - Add JSON generator.""",
7+
"version": "18.0.1.0.0",
8+
"development_status": "Beta",
9+
"license": "LGPL-3",
10+
"author": "Camptocamp, Odoo Community Association (OCA)",
11+
"website": "https://github.com/OCA/edi-framework",
12+
"depends": ["edi_exchange_template_oca"],
13+
"data": [],
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import edi_exchange_template_output
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2025 Camptocamp SA
2+
# @author Italo LOPES <italo.lopes@camptocamp.com>
3+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
4+
5+
6+
from odoo import fields, models
7+
8+
9+
class EDIExchangeOutputTemplate(models.Model):
10+
_inherit = "edi.exchange.template.output"
11+
12+
generator = fields.Selection(
13+
selection_add=[("json", "JSON")],
14+
ondelete={"json": "set default"},
15+
)
16+
17+
def _generate_json(self, exchange_record, **kw):
18+
"""Generate JSON output."""
19+
result = self._render_json_values(exchange_record, **kw)
20+
return result
21+
22+
def _post_process_output(self, output):
23+
result = super()._post_process_output(output)
24+
if self.generator == "json":
25+
result = self._post_process_json_output(result)
26+
return result
27+
28+
def _render_json_values(self, exchange_record, **kw):
29+
"""Render JSON values."""
30+
values = {
31+
"exchange_record": exchange_record,
32+
"record": exchange_record.record,
33+
"backend": exchange_record.backend_id,
34+
"template": self,
35+
"render_edi_template": self._render_template,
36+
"get_info_provider": self._get_info_provider,
37+
"info": {},
38+
}
39+
values.update(kw)
40+
values.update(self._time_utils())
41+
return self._evaluate_code_snippet(**values)
42+
43+
def _post_process_json_output(self, output):
44+
"""Post-process JSON output."""
45+
return str(output)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Italo Lopes \<<italo.lopes@camptocamp.com>\>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Provide extra JSON generator type for EDI exchange templates.
9.23 KB
Loading

0 commit comments

Comments
 (0)