diff --git a/jsonifier/README.rst b/jsonifier/README.rst index 296f428f2af..1f383aa2c0d 100644 --- a/jsonifier/README.rst +++ b/jsonifier/README.rst @@ -17,13 +17,13 @@ JSONifier :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github - :target: https://github.com/OCA/server-tools/tree/17.0/jsonifier + :target: https://github.com/OCA/server-tools/tree/18.0/jsonifier :alt: OCA/server-tools .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-jsonifier + :target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-jsonifier :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/server-tools&target_branch=17.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -190,7 +190,6 @@ Note that the export values with the simple parser depends on the record's lang; this is in contrast with full parsers which are designed to be language agnostic. - NOTE: this module was named base_jsonify till version 14.0.1.5.0. **Table of contents** @@ -198,13 +197,44 @@ NOTE: this module was named base_jsonify till version 14.0.1.5.0. .. contents:: :local: +Usage +===== + +with_fieldname parameter +------------------------ + +The with_fieldname option of jsonify() method, when true, will inject on +the same level of the data "\_\ `fieldname <>`__\ $field" keys that will +contain the field name, in the language of the current user. + + Examples of with_fieldname usage: + +.. code:: python + + # example 1 + parser = [('name')] + a.jsonify(parser=parser) + [{'name': 'SO3996'}] + >>> a.jsonify(parser=parser, with_fieldname=False) + [{'name': 'SO3996'}] + >>> a.jsonify(parser=parser, with_fieldname=True) + [{'fieldname_name': 'Order Reference', 'name': 'SO3996'}}] + + + # example 2 - with a subparser- + parser=['name', 'create_date', ('order_line', ['id' , 'product_uom', 'is_expense'])] + >>> a.jsonify(parser=parser, with_fieldname=False) + [{'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}]}] + >>> a.jsonify(parser=parser, with_fieldname=True) + [{'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}]}] + Bug Tracker =========== Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -242,6 +272,6 @@ 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. -This module is part of the `OCA/server-tools `_ project on GitHub. +This module is part of the `OCA/server-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/jsonifier/readme/USAGE.md b/jsonifier/readme/USAGE.md new file mode 100644 index 00000000000..1e175196383 --- /dev/null +++ b/jsonifier/readme/USAGE.md @@ -0,0 +1,26 @@ +## with_fieldname parameter + +The with_fieldname option of jsonify() method, when true, will inject on +the same level of the data "\_[fieldname]()\$field" keys that will +contain the field name, in the language of the current user. + +> Examples of with_fieldname usage: + +``` python +# example 1 +parser = [('name')] +a.jsonify(parser=parser) +[{'name': 'SO3996'}] +>>> a.jsonify(parser=parser, with_fieldname=False) +[{'name': 'SO3996'}] +>>> a.jsonify(parser=parser, with_fieldname=True) +[{'fieldname_name': 'Order Reference', 'name': 'SO3996'}}] + + +# example 2 - with a subparser- +parser=['name', 'create_date', ('order_line', ['id' , 'product_uom', 'is_expense'])] +>>> a.jsonify(parser=parser, with_fieldname=False) +[{'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}]}] +>>> a.jsonify(parser=parser, with_fieldname=True) +[{'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}]}] +``` diff --git a/jsonifier/readme/USAGE.rst b/jsonifier/readme/USAGE.rst deleted file mode 100644 index 7b5ae0cc534..00000000000 --- a/jsonifier/readme/USAGE.rst +++ /dev/null @@ -1,28 +0,0 @@ -with_fieldname parameter -========================== - -The with_fieldname option of jsonify() method, when true, will inject on -the same level of the data "_fieldname_$field" keys that will -contain the field name, in the language of the current user. - - - Examples of with_fieldname usage: - -.. code-block:: python - - # example 1 - parser = [('name')] - a.jsonify(parser=parser) - [{'name': 'SO3996'}] - >>> a.jsonify(parser=parser, with_fieldname=False) - [{'name': 'SO3996'}] - >>> a.jsonify(parser=parser, with_fieldname=True) - [{'fieldname_name': 'Order Reference', 'name': 'SO3996'}}] - - - # example 2 - with a subparser- - parser=['name', 'create_date', ('order_line', ['id' , 'product_uom', 'is_expense'])] - >>> a.jsonify(parser=parser, with_fieldname=False) - [{'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}]}] - >>> a.jsonify(parser=parser, with_fieldname=True) - [{'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}]}]