mangono-addon-export_json 18.0.1.0.4__py3-none-any.whl → 19.0.1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mangono_addon_export_json-18.0.1.0.4.dist-info → mangono_addon_export_json-19.0.1.0.1.dist-info}/METADATA +2 -3
- mangono_addon_export_json-19.0.1.0.1.dist-info/RECORD +52 -0
- odoo/addons/export_json/README.rst +2 -2
- odoo/addons/export_json/__init__.py +4 -0
- odoo/addons/export_json/__manifest__.py +10 -3
- odoo/addons/export_json/controller/main.py +1 -1
- odoo/addons/export_json/demo/export_demo.xml +7 -0
- odoo/addons/export_json/demo/ir.exports.line.csv +16 -0
- odoo/addons/export_json/demo/resolver_demo.xml +12 -0
- odoo/addons/export_json/jsonifier/README.rst +284 -0
- odoo/addons/export_json/jsonifier/__init__.py +1 -0
- odoo/addons/export_json/jsonifier/__manifest__.old +27 -0
- odoo/addons/export_json/jsonifier/demo/export_demo.xml +7 -0
- odoo/addons/export_json/jsonifier/demo/ir.exports.line.csv +16 -0
- odoo/addons/export_json/jsonifier/demo/resolver_demo.xml +12 -0
- odoo/addons/export_json/jsonifier/exceptions.py +7 -0
- odoo/addons/export_json/jsonifier/i18n/ca.po +234 -0
- odoo/addons/export_json/jsonifier/i18n/es.po +266 -0
- odoo/addons/export_json/jsonifier/i18n/it.po +277 -0
- odoo/addons/export_json/jsonifier/i18n/zh_CN.po +260 -0
- odoo/addons/export_json/jsonifier/models/__init__.py +5 -0
- odoo/addons/export_json/jsonifier/models/ir_exports.py +124 -0
- odoo/addons/export_json/jsonifier/models/ir_exports_line.py +55 -0
- odoo/addons/export_json/jsonifier/models/ir_exports_resolver.py +58 -0
- odoo/addons/export_json/jsonifier/models/models.py +263 -0
- odoo/addons/export_json/jsonifier/models/utils.py +35 -0
- odoo/addons/export_json/jsonifier/pyproject.toml +3 -0
- odoo/addons/export_json/jsonifier/readme/CONTRIBUTORS.md +8 -0
- odoo/addons/export_json/jsonifier/readme/CREDITS.md +1 -0
- odoo/addons/export_json/jsonifier/readme/DESCRIPTION.md +163 -0
- odoo/addons/export_json/jsonifier/readme/USAGE.md +26 -0
- odoo/addons/export_json/jsonifier/security/ir.model.access.csv +2 -0
- odoo/addons/export_json/jsonifier/tests/__init__.py +3 -0
- odoo/addons/export_json/jsonifier/tests/test_get_parser.py +436 -0
- odoo/addons/export_json/jsonifier/tests/test_helpers.py +45 -0
- odoo/addons/export_json/jsonifier/tests/test_ir_exports_line.py +66 -0
- odoo/addons/export_json/jsonifier/views/ir_exports_resolver_view.xml +26 -0
- odoo/addons/export_json/jsonifier/views/ir_exports_view.xml +38 -0
- odoo/addons/export_json/models/file_json.py +1 -2
- odoo/addons/export_json/tests/test_export_json.py +14 -11
- mangono_addon_export_json-18.0.1.0.4.dist-info/RECORD +0 -20
- {mangono_addon_export_json-18.0.1.0.4.dist-info → mangono_addon_export_json-19.0.1.0.1.dist-info}/WHEEL +0 -0
- {mangono_addon_export_json-18.0.1.0.4.dist-info → mangono_addon_export_json-19.0.1.0.1.dist-info}/top_level.txt +0 -0
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mangono-addon-export_json
|
|
3
|
-
Version:
|
|
3
|
+
Version: 19.0.1.0.1
|
|
4
4
|
Project-URL: Homepage, https://mangono.fr/
|
|
5
5
|
Author-Email: Mangono <opensource+odoo@mangono.fr>
|
|
6
6
|
License-Expression: AGPL-3.0
|
|
7
7
|
Classifier: Development Status :: 5 - Production/Stable
|
|
8
8
|
Classifier: Framework :: Odoo
|
|
9
|
-
Classifier: Framework :: Odoo ::
|
|
9
|
+
Classifier: Framework :: Odoo :: 19.0
|
|
10
10
|
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
11
11
|
Classifier: Programming Language :: Python
|
|
12
|
-
Requires-Python: >=3.10
|
|
13
12
|
Description-Content-Type: text/markdown
|
|
14
13
|
|
|
15
14
|
JSON Export system for Odoo Community edition.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
odoo/addons/export_json/README.rst,sha256=gJFtIWYj4CGiG4y6mzK51F3_tSsiy7ePdsmt53pTbcg,1046
|
|
2
|
+
odoo/addons/export_json/README_PYPI.md,sha256=EPAGNA3CPAnOmE8NYvVP6WpPt1QAr2LMMjl4Aj2zanw,47
|
|
3
|
+
odoo/addons/export_json/__init__.py,sha256=QYByk0KGOAXB51BLCwKbwPWu9BLGX4j7YUrCKxCC0r8,137
|
|
4
|
+
odoo/addons/export_json/__manifest__.py,sha256=5TEGz2d8p_WPwrUFWUqaOadrRLzfil5W9WoF_rkMe_g,689
|
|
5
|
+
odoo/addons/export_json/controller/__init__.py,sha256=4KFqEP2QHFbPN66eQJMdGsmNz2v7ywWv_FR1pW_kkLk,19
|
|
6
|
+
odoo/addons/export_json/controller/main.py,sha256=9kWvSRDyY81MXFzKpsLi-5_pDE1-aXDnTo61d2opO6c,16130
|
|
7
|
+
odoo/addons/export_json/demo/export_demo.xml,sha256=VV0Gq7FdcR_cMitqfhZH8dySSffpgqwyumfGc8vc0Fk,222
|
|
8
|
+
odoo/addons/export_json/demo/ir.exports.line.csv,sha256=HxlVBNSWLOZBbyGw_wy1VuamlCFVl6etq1hKRYLmDdM,682
|
|
9
|
+
odoo/addons/export_json/demo/resolver_demo.xml,sha256=CpsPBWiHl-QJvAjzPiPV4s-VaWjXEXQYnRRxoX9imYI,466
|
|
10
|
+
odoo/addons/export_json/docs/export_json_userguide.adoc,sha256=z1uwdxU16Ji4VOnDdLIzLnv7XqpKiAi5SZ2qSNbZorc,943
|
|
11
|
+
odoo/addons/export_json/docs/images/export_json2.png,sha256=4rKkrvcIgzRGFrtBwmL8CwheZLB3wDxK0vg3XnqOPUI,68768
|
|
12
|
+
odoo/addons/export_json/docs/images/export_json3_popup_export.png,sha256=LIDCvP2rhqSo-iXal0I46cnDWFo3tU2-jujQr-mMXAQ,102814
|
|
13
|
+
odoo/addons/export_json/docs/images/export_json_popup_export2.png,sha256=1a_UZ3jRqju5o3fhoiiySI8xauU2xwluk_9o79-m8nA,21395
|
|
14
|
+
odoo/addons/export_json/docs/images/process_export1.png,sha256=L_Eskhv0dNfZzkbBU4Vvh8AOspZPEsr3UIdJ_bMOUsg,61036
|
|
15
|
+
odoo/addons/export_json/jsonifier/README.rst,sha256=0i3sxnztZZ7iTrdmPTAsBX4bLkTWbad6GztzUGdNT3Y,9757
|
|
16
|
+
odoo/addons/export_json/jsonifier/__init__.py,sha256=X9EJGOE2GtZbS0G82PtSXmWSZ_R8jEM0rlJTDliQjp4,21
|
|
17
|
+
odoo/addons/export_json/jsonifier/__manifest__.old,sha256=owX9VZIUdf41SLA6DouLb1UwFkjqyC95tBXxArL8TgI,959
|
|
18
|
+
odoo/addons/export_json/jsonifier/exceptions.py,sha256=cKShS44xAo7d-2A_YLediqTFlMhmGpyO3VgB92R9ycc,253
|
|
19
|
+
odoo/addons/export_json/jsonifier/pyproject.toml,sha256=fTmy7R95Ca6vKwz6oo7aFYgJcT7IoMJRCHjNqRg6PNY,69
|
|
20
|
+
odoo/addons/export_json/jsonifier/demo/export_demo.xml,sha256=VV0Gq7FdcR_cMitqfhZH8dySSffpgqwyumfGc8vc0Fk,222
|
|
21
|
+
odoo/addons/export_json/jsonifier/demo/ir.exports.line.csv,sha256=HxlVBNSWLOZBbyGw_wy1VuamlCFVl6etq1hKRYLmDdM,682
|
|
22
|
+
odoo/addons/export_json/jsonifier/demo/resolver_demo.xml,sha256=CpsPBWiHl-QJvAjzPiPV4s-VaWjXEXQYnRRxoX9imYI,466
|
|
23
|
+
odoo/addons/export_json/jsonifier/i18n/ca.po,sha256=UR-DfmJV2cnkQJfeyKy4rfOvwH4iZw4W0XRHbQ40bYw,6701
|
|
24
|
+
odoo/addons/export_json/jsonifier/i18n/es.po,sha256=X0Yi4btr3jE5sXiM0wuMIEG9OaUkiVO_DVLIyWRKqEc,8774
|
|
25
|
+
odoo/addons/export_json/jsonifier/i18n/it.po,sha256=ejDZ-NUh5e3sVyUcM4TInL4lQ5clSMOXRW_R1EuRI7M,9134
|
|
26
|
+
odoo/addons/export_json/jsonifier/i18n/zh_CN.po,sha256=1xnIPxOQwVaJLOxJGem8fma36ki24T2BQkAU27q_img,8577
|
|
27
|
+
odoo/addons/export_json/jsonifier/models/__init__.py,sha256=vMrJWrhG8vP6uBASZP_6Xmay7TaDddc6eDdIdt9nqLc,130
|
|
28
|
+
odoo/addons/export_json/jsonifier/models/ir_exports.py,sha256=t4fK6F7uTIRxLtcCuMkkuwKk3y1CRbN-6T8AlaZwRpM,4097
|
|
29
|
+
odoo/addons/export_json/jsonifier/models/ir_exports_line.py,sha256=RsBulti4T-u5pnNTK4lZl61aLHAuMh2fr62Bv42EOz0,2165
|
|
30
|
+
odoo/addons/export_json/jsonifier/models/ir_exports_resolver.py,sha256=QbEQCBnE497qfGRBi56awdk5WnMv0EW3kfvnFoTe5_U,2122
|
|
31
|
+
odoo/addons/export_json/jsonifier/models/models.py,sha256=-7Qe9ozU7axzHnz4_nct1PvHM0QZNRvdBr-6iTgSbOI,10627
|
|
32
|
+
odoo/addons/export_json/jsonifier/models/utils.py,sha256=DLb5J4qgNJBFhdOarOPbyuXEFUZ3Z9qXVar4GWmziI0,1154
|
|
33
|
+
odoo/addons/export_json/jsonifier/readme/CONTRIBUTORS.md,sha256=A9UCqi8jBd7ZD7WxOtpAIm8Iv4wp5FmqoTznKJ6bvow,380
|
|
34
|
+
odoo/addons/export_json/jsonifier/readme/CREDITS.md,sha256=iBbhXVnE2APvLFeXl0Bdd-uXfNXH21qo0HnEDi8tVNI,88
|
|
35
|
+
odoo/addons/export_json/jsonifier/readme/DESCRIPTION.md,sha256=lvE6_Y0BadWf4a7e5_LfSy0Pme-fyXlgxrWxZwIUbH0,4896
|
|
36
|
+
odoo/addons/export_json/jsonifier/readme/USAGE.md,sha256=pYRGwOS1kYiUV9dC6yPNcKqnEWFUgY3oHGjF87zA5aE,1397
|
|
37
|
+
odoo/addons/export_json/jsonifier/security/ir.model.access.csv,sha256=hjmdELWdlvc-yzyNrZAnu7QMo1dyTDYO5ApDwiLPkdc,176
|
|
38
|
+
odoo/addons/export_json/jsonifier/tests/__init__.py,sha256=C9L9KtfPuj5gjfK3wp_Qp-oyCNizUw3lIrgvM8Dg-Jw,92
|
|
39
|
+
odoo/addons/export_json/jsonifier/tests/test_get_parser.py,sha256=SVz9y0UjONw0bQWCoeww8oNL5GS7wsrQMWyTfW_ZhrI,17099
|
|
40
|
+
odoo/addons/export_json/jsonifier/tests/test_helpers.py,sha256=y9c3yVDQI11zmHUVBEGu53fNYMZZ4E_UKPlY6I5g0Ic,1493
|
|
41
|
+
odoo/addons/export_json/jsonifier/tests/test_ir_exports_line.py,sha256=Pl2kuPCniPyZ8iWprkc_7fBnm_zKNtmtgrQHjIwhCbs,2620
|
|
42
|
+
odoo/addons/export_json/jsonifier/views/ir_exports_resolver_view.xml,sha256=_7f-yt_x3x4A-qXsFHzqPWQCJVoVeObb5Z3TtLNUqFg,899
|
|
43
|
+
odoo/addons/export_json/jsonifier/views/ir_exports_view.xml,sha256=8KJC3t-b5hlChKx-h9Km9F72IjC4HHM8VQ-265kWTHY,1676
|
|
44
|
+
odoo/addons/export_json/models/__init__.py,sha256=TR1KOlZczvm4dhDPMpq1_ebc9B8c9q1fzGGV61pK7AI,24
|
|
45
|
+
odoo/addons/export_json/models/file_json.py,sha256=XLDZwzLmnN-IncaGDP4JNxTDGdslIqzbLVeZlL_Gvo4,510
|
|
46
|
+
odoo/addons/export_json/static/src/css/description.css,sha256=ZUoNviTVfhLg3q_aQwuJyrJuh047wGy1t3GWtcoJFcE,3066
|
|
47
|
+
odoo/addons/export_json/tests/__init__.py,sha256=pyQlWluF3AhruvDbvI13etPuJs2ZZ75iAQY1lRZMsZE,31
|
|
48
|
+
odoo/addons/export_json/tests/test_export_json.py,sha256=ql8PRMlaVZfmRmNuNG6VMdZvU3182lP-BfDxiJNKDWk,32567
|
|
49
|
+
mangono_addon_export_json-19.0.1.0.1.dist-info/METADATA,sha256=DDhLDl74APQ2y_Lq3l2RQ6X7oVDkLh1IXC8moyi24TU,528
|
|
50
|
+
mangono_addon_export_json-19.0.1.0.1.dist-info/WHEEL,sha256=ADTnST8WcJ5NkvOhz6ibaMSK2Os3Cjf9hXrb4uW3WtU,98
|
|
51
|
+
mangono_addon_export_json-19.0.1.0.1.dist-info/top_level.txt,sha256=QE6RBQ0QX5f4eFuUcGgU5Kbq1A_qJcDs-e_vpr6pmfU,4
|
|
52
|
+
mangono_addon_export_json-19.0.1.0.1.dist-info/RECORD,,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
JSON Export
|
|
6
6
|
===========
|
|
7
|
-
JSON Export system for Odoo
|
|
7
|
+
JSON Export system for Odoo 19 Community edition.
|
|
8
8
|
|
|
9
9
|
Configuration
|
|
10
10
|
=============
|
|
@@ -21,7 +21,7 @@ General Public License, Version 3 (LGPL v3).
|
|
|
21
21
|
|
|
22
22
|
Credits
|
|
23
23
|
-------
|
|
24
|
-
Developer: (
|
|
24
|
+
Developer: (V19) Mangono , Contact: contact@mangono.fr
|
|
25
25
|
|
|
26
26
|
Contacts
|
|
27
27
|
--------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "JSON Export",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.0.1.0.1",
|
|
4
4
|
"category": "Extra Tools",
|
|
5
5
|
"license": "AGPL-3",
|
|
6
6
|
"summary": "Add JSON export to all models similar to XLSX or CSV exports.",
|
|
@@ -13,8 +13,15 @@ JSON Export
|
|
|
13
13
|
see README
|
|
14
14
|
""",
|
|
15
15
|
"website": "https://mangono.fr/",
|
|
16
|
-
"depends": ["base", "web"
|
|
17
|
-
"data": [
|
|
16
|
+
"depends": ["base", "web"],
|
|
17
|
+
"data": [
|
|
18
|
+
"jsonifier/security/ir.model.access.csv",
|
|
19
|
+
],
|
|
20
|
+
"demo": [
|
|
21
|
+
"demo/resolver_demo.xml",
|
|
22
|
+
"demo/export_demo.xml",
|
|
23
|
+
"demo/ir.exports.line.csv",
|
|
24
|
+
],
|
|
18
25
|
"installable": True,
|
|
19
26
|
"images": ["static/description/banner.png"],
|
|
20
27
|
}
|
|
@@ -18,7 +18,7 @@ _logger = logging.getLogger(__name__)
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class JsonExport(Export):
|
|
21
|
-
@http.route("/web/export/formats", type="
|
|
21
|
+
@http.route("/web/export/formats", type="jsonrpc", auth="user")
|
|
22
22
|
def formats(self):
|
|
23
23
|
res = super().formats()
|
|
24
24
|
res.append({"tag": "json", "label": "JSON"})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
id,export_id/id,name
|
|
2
|
+
name,ir_exp_partner,name
|
|
3
|
+
active,ir_exp_partner,active
|
|
4
|
+
partner_latitude,ir_exp_partner,partner_latitude
|
|
5
|
+
color,ir_exp_partner,color
|
|
6
|
+
category_id_name,ir_exp_partner,category_id/name
|
|
7
|
+
country_id_name,ir_exp_partner,country_id/name
|
|
8
|
+
country_id_code,ir_exp_partner,country_id/code
|
|
9
|
+
child_ids_name,ir_exp_partner,child_ids/name
|
|
10
|
+
child_ids_id,ir_exp_partner,child_ids/id
|
|
11
|
+
child_ids_email,ir_exp_partner,child_ids/email
|
|
12
|
+
child_ids_country_id_name,ir_exp_partner,child_ids/country_id/name
|
|
13
|
+
child_ids_country_id_code,ir_exp_partner,child_ids/country_id/code
|
|
14
|
+
child_ids_child_ids_name,ir_exp_partner,child_ids/child_ids/name
|
|
15
|
+
lang,ir_exp_partner,lang
|
|
16
|
+
comment,ir_exp_partner,comment
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<odoo>
|
|
3
|
+
<record id="ir_exports_resolver_dict" model="ir.exports.resolver">
|
|
4
|
+
<field name="name">ExtraData dictionary (number/text)</field>
|
|
5
|
+
<field name="python_code">
|
|
6
|
+
is_number = field_type in ('integer', 'float')
|
|
7
|
+
ftype = "NUMBER" if is_number else "TEXT"
|
|
8
|
+
value = value if is_number else str(value)
|
|
9
|
+
result = {"Key": name, "Value": value, "Type": ftype, "IsPublic": True}
|
|
10
|
+
</field>
|
|
11
|
+
</record>
|
|
12
|
+
</odoo>
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
=========
|
|
2
|
+
JSONifier
|
|
3
|
+
=========
|
|
4
|
+
|
|
5
|
+
..
|
|
6
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
7
|
+
!! This file is generated by oca-gen-addon-readme !!
|
|
8
|
+
!! changes will be overwritten. !!
|
|
9
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
10
|
+
!! source digest: sha256:cbf418975463b6a5ff3ae89fdd5b77a2f9c2ad8c23f82869ce51846f94bff7ce
|
|
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%2Fserver--tools-lightgray.png?logo=github
|
|
20
|
+
:target: https://github.com/OCA/server-tools/tree/18.0/jsonifier
|
|
21
|
+
:alt: OCA/server-tools
|
|
22
|
+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
|
23
|
+
:target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-jsonifier
|
|
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/server-tools&target_branch=18.0
|
|
27
|
+
:alt: Try me on Runboat
|
|
28
|
+
|
|
29
|
+
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|
30
|
+
|
|
31
|
+
This module adds a 'jsonify' method to every model of the ORM. It works
|
|
32
|
+
on the current recordset and requires a single argument 'parser' that
|
|
33
|
+
specify the field to extract.
|
|
34
|
+
|
|
35
|
+
Example of a simple parser:
|
|
36
|
+
|
|
37
|
+
.. code:: python
|
|
38
|
+
|
|
39
|
+
parser = [
|
|
40
|
+
'name',
|
|
41
|
+
'number',
|
|
42
|
+
'create_date',
|
|
43
|
+
('partner_id', ['id', 'display_name', 'ref'])
|
|
44
|
+
('line_id', ['id', ('product_id', ['name']), 'price_unit'])
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
In order to be consistent with the Odoo API the jsonify method always
|
|
48
|
+
returns a list of objects even if there is only one element in the
|
|
49
|
+
recordset.
|
|
50
|
+
|
|
51
|
+
By default the key into the JSON is the name of the field extracted from
|
|
52
|
+
the model. If you need to specify an alternate name to use as key, you
|
|
53
|
+
can define your mapping as follow into the parser definition:
|
|
54
|
+
|
|
55
|
+
.. code:: python
|
|
56
|
+
|
|
57
|
+
parser = [
|
|
58
|
+
'field_name:json_key'
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
.. code:: python
|
|
62
|
+
|
|
63
|
+
parser = [
|
|
64
|
+
'name',
|
|
65
|
+
'number',
|
|
66
|
+
'create_date:creationDate',
|
|
67
|
+
('partner_id:partners', ['id', 'display_name', 'ref'])
|
|
68
|
+
('line_id:lines', ['id', ('product_id', ['name']), 'price_unit'])
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
If you need to parse the value of a field in a custom way, you can pass
|
|
72
|
+
a callable or the name of a method on the model:
|
|
73
|
+
|
|
74
|
+
.. code:: python
|
|
75
|
+
|
|
76
|
+
parser = [
|
|
77
|
+
('name', "jsonify_name") # method name
|
|
78
|
+
('number', lambda rec, field_name: rec[field_name] * 2)) # callable
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
Also the module provide a method "get_json_parser" on the ir.exports
|
|
82
|
+
object that generate a parser from an ir.exports configuration.
|
|
83
|
+
|
|
84
|
+
Further features are available for advanced uses. It defines a simple
|
|
85
|
+
"resolver" model that has a "python_code" field and a resolve function
|
|
86
|
+
so that arbitrary functions can be configured to transform fields, or
|
|
87
|
+
process the resulting dictionary. It is also to specify a lang to
|
|
88
|
+
extract the translation of any given field.
|
|
89
|
+
|
|
90
|
+
To use these features, a full parser follows the following structure:
|
|
91
|
+
|
|
92
|
+
.. code:: python
|
|
93
|
+
|
|
94
|
+
parser = {
|
|
95
|
+
"resolver": 3,
|
|
96
|
+
"language_agnostic": True,
|
|
97
|
+
"langs": {
|
|
98
|
+
False: [
|
|
99
|
+
{'name': 'description'},
|
|
100
|
+
{'name': 'number', 'resolver': 5},
|
|
101
|
+
({'name': 'partner_id', 'target': 'partner'}, [{'name': 'display_name'}])
|
|
102
|
+
],
|
|
103
|
+
'fr_FR': [
|
|
104
|
+
{'name': 'description', 'target': 'descriptions_fr'},
|
|
105
|
+
({'name': 'partner_id', 'target': 'partner'}, [{'name': 'description', 'target': 'description_fr'}])
|
|
106
|
+
],
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
One would get a result having this structure (note that the translated
|
|
111
|
+
fields are merged in the same dictionary):
|
|
112
|
+
|
|
113
|
+
.. code:: python
|
|
114
|
+
|
|
115
|
+
exported_json == {
|
|
116
|
+
"description": "English description",
|
|
117
|
+
"description_fr": "French description, voilà",
|
|
118
|
+
"number": 42,
|
|
119
|
+
"partner": {
|
|
120
|
+
"display_name": "partner name",
|
|
121
|
+
"description_fr": "French description of that partner",
|
|
122
|
+
},
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
Note that a resolver can be passed either as a recordset or as an id, so
|
|
126
|
+
as to be fully serializable. A slightly simpler version in case the
|
|
127
|
+
translation of fields is not needed, but other features like custom
|
|
128
|
+
resolvers are:
|
|
129
|
+
|
|
130
|
+
.. code:: python
|
|
131
|
+
|
|
132
|
+
parser = {
|
|
133
|
+
"resolver": 3,
|
|
134
|
+
"fields": [
|
|
135
|
+
{'name': 'description'},
|
|
136
|
+
{'name': 'number', 'resolver': 5},
|
|
137
|
+
({'name': 'partner_id', 'target': 'partners'}, [{'name': 'display_name'}]),
|
|
138
|
+
],
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
By passing the fields key instead of langs, we have essentially the same
|
|
142
|
+
behaviour as simple parsers, with the added benefit of being able to use
|
|
143
|
+
resolvers.
|
|
144
|
+
|
|
145
|
+
Standard use-cases of resolvers are: - give field-specific defaults
|
|
146
|
+
(e.g. "" instead of None) - cast a field type (e.g. int()) - alias a
|
|
147
|
+
particular field for a specific export - ...
|
|
148
|
+
|
|
149
|
+
A simple parser is simply translated into a full parser at export.
|
|
150
|
+
|
|
151
|
+
If the global resolver is given, then the json_dict goes through:
|
|
152
|
+
|
|
153
|
+
.. code:: python
|
|
154
|
+
|
|
155
|
+
resolver.resolve(dict, record)
|
|
156
|
+
|
|
157
|
+
Which allows to add external data from the context or transform the
|
|
158
|
+
dictionary if necessary. Similarly if given for a field the resolver
|
|
159
|
+
evaluates the result.
|
|
160
|
+
|
|
161
|
+
It is possible for a target to have a marshaller by ending the target
|
|
162
|
+
with '=list': in that case the result is put into a list.
|
|
163
|
+
|
|
164
|
+
.. code:: python
|
|
165
|
+
|
|
166
|
+
parser = {
|
|
167
|
+
fields: [
|
|
168
|
+
{'name': 'name'},
|
|
169
|
+
{'name': 'field_1', 'target': 'customTags=list'},
|
|
170
|
+
{'name': 'field_2', 'target': 'customTags=list'},
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
Would result in the following JSON structure:
|
|
175
|
+
|
|
176
|
+
.. code:: python
|
|
177
|
+
|
|
178
|
+
{
|
|
179
|
+
'name': 'record_name',
|
|
180
|
+
'customTags': ['field_1_value', 'field_2_value'],
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
The intended use-case is to be compatible with APIs that require all
|
|
184
|
+
translated parameters to be exported simultaneously, and ask for custom
|
|
185
|
+
properties to be put in a sub-dictionary. Since it is often the case
|
|
186
|
+
that some of these requirements are optional, new requirements could be
|
|
187
|
+
met without needing to add field or change any code.
|
|
188
|
+
|
|
189
|
+
Note that the export values with the simple parser depends on the
|
|
190
|
+
record's lang; this is in contrast with full parsers which are designed
|
|
191
|
+
to be language agnostic.
|
|
192
|
+
|
|
193
|
+
NOTE: this module was named base_jsonify till version 14.0.1.5.0.
|
|
194
|
+
|
|
195
|
+
**Table of contents**
|
|
196
|
+
|
|
197
|
+
.. contents::
|
|
198
|
+
:local:
|
|
199
|
+
|
|
200
|
+
Usage
|
|
201
|
+
=====
|
|
202
|
+
|
|
203
|
+
with_fieldname parameter
|
|
204
|
+
------------------------
|
|
205
|
+
|
|
206
|
+
The with_fieldname option of jsonify() method, when true, will inject on
|
|
207
|
+
the same level of the data "\_fieldname\_$field" keys that will contain
|
|
208
|
+
the field name, in the language of the current user.
|
|
209
|
+
|
|
210
|
+
Examples of with_fieldname usage:
|
|
211
|
+
|
|
212
|
+
.. code:: python
|
|
213
|
+
|
|
214
|
+
# example 1
|
|
215
|
+
parser = [('name')]
|
|
216
|
+
a.jsonify(parser=parser)
|
|
217
|
+
[{'name': 'SO3996'}]
|
|
218
|
+
>>> a.jsonify(parser=parser, with_fieldname=False)
|
|
219
|
+
[{'name': 'SO3996'}]
|
|
220
|
+
>>> a.jsonify(parser=parser, with_fieldname=True)
|
|
221
|
+
[{'fieldname_name': 'Order Reference', 'name': 'SO3996'}}]
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
# example 2 - with a subparser-
|
|
225
|
+
parser=['name', 'create_date', ('order_line', ['id' , 'product_uom', 'is_expense'])]
|
|
226
|
+
>>> a.jsonify(parser=parser, with_fieldname=False)
|
|
227
|
+
[{'name': 'SO3996', 'create_date': '2015-06-02T12:18:26.279909+00:00', 'order_line': [{'id': 16649, 'product_uom': 'stuks', 'is_expense': False}, {'id': 16651, 'product_uom': 'stuks', 'is_expense': False}, {'id': 16650, 'product_uom': 'stuks', 'is_expense': False}]}]
|
|
228
|
+
>>> a.jsonify(parser=parser, with_fieldname=True)
|
|
229
|
+
[{'fieldname_name': 'Order Reference', 'name': 'SO3996', 'fieldname_create_date': 'Creation Date', 'create_date': '2015-06-02T12:18:26.279909+00:00', 'fieldname_order_line': 'Order Lines', 'order_line': [{'fieldname_id': 'ID', 'id': 16649, 'fieldname_product_uom': 'Unit of Measure', 'product_uom': 'stuks', 'fieldname_is_expense': 'Is expense', 'is_expense': False}]}]
|
|
230
|
+
|
|
231
|
+
Bug Tracker
|
|
232
|
+
===========
|
|
233
|
+
|
|
234
|
+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
|
|
235
|
+
In case of trouble, please check there if your issue has already been reported.
|
|
236
|
+
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
|
237
|
+
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20jsonifier%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
|
238
|
+
|
|
239
|
+
Do not contact contributors directly about support or help with technical issues.
|
|
240
|
+
|
|
241
|
+
Credits
|
|
242
|
+
=======
|
|
243
|
+
|
|
244
|
+
Authors
|
|
245
|
+
-------
|
|
246
|
+
|
|
247
|
+
* Akretion
|
|
248
|
+
* ACSONE
|
|
249
|
+
* Camptocamp
|
|
250
|
+
|
|
251
|
+
Contributors
|
|
252
|
+
------------
|
|
253
|
+
|
|
254
|
+
- BEAU Sébastien <sebastien.beau@akretion.com>
|
|
255
|
+
- Raphaël Reverdy <raphael.reverdy@akretion.com>
|
|
256
|
+
- Laurent Mignon <laurent.mignon@acsone.eu>
|
|
257
|
+
- Nans Lefebvre <nans.lefebvre@acsone.eu>
|
|
258
|
+
- Simone Orsi <simone.orsi@camptocamp.com>
|
|
259
|
+
- Iván Todorovich <ivan.todorovich@camptocamp.com>
|
|
260
|
+
- Nguyen Minh Chien <chien@trobz.com>
|
|
261
|
+
- Thien Vo <thienvh@trobz.com>
|
|
262
|
+
|
|
263
|
+
Other credits
|
|
264
|
+
-------------
|
|
265
|
+
|
|
266
|
+
The migration of this module from 17.0 to 18.0 was financially supported
|
|
267
|
+
by Camptocamp.
|
|
268
|
+
|
|
269
|
+
Maintainers
|
|
270
|
+
-----------
|
|
271
|
+
|
|
272
|
+
This module is maintained by the OCA.
|
|
273
|
+
|
|
274
|
+
.. image:: https://odoo-community.org/logo.png
|
|
275
|
+
:alt: Odoo Community Association
|
|
276
|
+
:target: https://odoo-community.org
|
|
277
|
+
|
|
278
|
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|
279
|
+
mission is to support the collaborative development of Odoo features and
|
|
280
|
+
promote its widespread use.
|
|
281
|
+
|
|
282
|
+
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/18.0/jsonifier>`_ project on GitHub.
|
|
283
|
+
|
|
284
|
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import models
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Copyright 2017-2018 Akretion (http://www.akretion.com)
|
|
2
|
+
# Sébastien BEAU <sebastien.beau@akretion.com>
|
|
3
|
+
# Raphaël Reverdy <raphael.reverdy@akretion.com>
|
|
4
|
+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
|
|
5
|
+
|
|
6
|
+
# Integrated pending PR validation https://github.com/OCA/server-tools/actions/runs/21240237637/job/61116370844?pr=3499
|
|
7
|
+
{
|
|
8
|
+
"name": "JSONifier",
|
|
9
|
+
"summary": "JSON-ify data for all models",
|
|
10
|
+
"version": "19.0.1.1.0",
|
|
11
|
+
"category": "Uncategorized",
|
|
12
|
+
"website": "https://github.com/OCA/server-tools",
|
|
13
|
+
"author": "Akretion, ACSONE, Camptocamp, Odoo Community Association (OCA)",
|
|
14
|
+
"license": "LGPL-3",
|
|
15
|
+
"installable": True,
|
|
16
|
+
"depends": ["base"],
|
|
17
|
+
"data": [
|
|
18
|
+
"security/ir.model.access.csv",
|
|
19
|
+
"views/ir_exports_view.xml",
|
|
20
|
+
"views/ir_exports_resolver_view.xml",
|
|
21
|
+
],
|
|
22
|
+
"demo": [
|
|
23
|
+
"demo/resolver_demo.xml",
|
|
24
|
+
"demo/export_demo.xml",
|
|
25
|
+
"demo/ir.exports.line.csv",
|
|
26
|
+
],
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
id,export_id/id,name
|
|
2
|
+
name,ir_exp_partner,name
|
|
3
|
+
active,ir_exp_partner,active
|
|
4
|
+
partner_latitude,ir_exp_partner,partner_latitude
|
|
5
|
+
color,ir_exp_partner,color
|
|
6
|
+
category_id_name,ir_exp_partner,category_id/name
|
|
7
|
+
country_id_name,ir_exp_partner,country_id/name
|
|
8
|
+
country_id_code,ir_exp_partner,country_id/code
|
|
9
|
+
child_ids_name,ir_exp_partner,child_ids/name
|
|
10
|
+
child_ids_id,ir_exp_partner,child_ids/id
|
|
11
|
+
child_ids_email,ir_exp_partner,child_ids/email
|
|
12
|
+
child_ids_country_id_name,ir_exp_partner,child_ids/country_id/name
|
|
13
|
+
child_ids_country_id_code,ir_exp_partner,child_ids/country_id/code
|
|
14
|
+
child_ids_child_ids_name,ir_exp_partner,child_ids/child_ids/name
|
|
15
|
+
lang,ir_exp_partner,lang
|
|
16
|
+
comment,ir_exp_partner,comment
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<odoo>
|
|
3
|
+
<record id="ir_exports_resolver_dict" model="ir.exports.resolver">
|
|
4
|
+
<field name="name">ExtraData dictionary (number/text)</field>
|
|
5
|
+
<field name="python_code">
|
|
6
|
+
is_number = field_type in ('integer', 'float')
|
|
7
|
+
ftype = "NUMBER" if is_number else "TEXT"
|
|
8
|
+
value = value if is_number else str(value)
|
|
9
|
+
result = {"Key": name, "Value": value, "Type": ftype, "IsPublic": True}
|
|
10
|
+
</field>
|
|
11
|
+
</record>
|
|
12
|
+
</odoo>
|