Skip to content

Commit a15f3e5

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

File tree

12 files changed

+627
-0
lines changed

12 files changed

+627
-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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
import json
6+
7+
from odoo import fields, models
8+
9+
10+
class EDIExchangeOutputTemplate(models.Model):
11+
_inherit = "edi.exchange.template.output"
12+
13+
generator = fields.Selection(
14+
selection_add=[("json", "JSON")],
15+
ondelete={"json": "set default"},
16+
)
17+
18+
def _generate_json(self, exchange_record, **kw):
19+
"""Generate JSON output."""
20+
result = self._render_json_values(exchange_record, **kw)
21+
return result
22+
23+
def _post_process_output(self, output):
24+
result = super()._post_process_output(output)
25+
if self.generator == "json":
26+
result = self._post_process_json_output(result)
27+
return result
28+
29+
def _render_json_values(self, exchange_record, **kw):
30+
"""Render JSON values."""
31+
values = {
32+
"exchange_record": exchange_record,
33+
"record": exchange_record.record,
34+
"backend": exchange_record.backend_id,
35+
"template": self,
36+
"render_edi_template": self._render_template,
37+
"get_info_provider": self._get_info_provider,
38+
"info": {},
39+
}
40+
values.update(kw)
41+
values.update(self._time_utils())
42+
return self._evaluate_code_snippet(**values)
43+
44+
def _post_process_json_output(self, output):
45+
"""Post-process JSON output."""
46+
return json.dumps(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)