You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.8 KiB

8 years ago
  1. ============
  2. Base Jsonify
  3. ============
  4. .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  5. !! This file is generated by oca-gen-addon-readme !!
  6. !! changes will be overwritten. !!
  7. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  8. .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
  9. :target: https://odoo-community.org/page/development-status
  10. :alt: Beta
  11. .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
  12. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  13. :alt: License: AGPL-3
  14. .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
  15. :target: https://github.com/OCA/server-tools/tree/10.0/base_jsonify
  16. :alt: OCA/server-tools
  17. .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
  18. :target: https://translation.odoo-community.org/projects/server-tools-10-0/server-tools-10-0-base_jsonify
  19. :alt: Translate me on Weblate
  20. .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
  21. :target: https://runbot.odoo-community.org/runbot/149/10.0
  22. :alt: Try me on Runbot
  23. |badge1| |badge2| |badge3| |badge4| |badge5|
  24. This module add the jsonify method to the ORM. This method take as argument
  25. the browse record and the "parser" that specify the field to extract.
  26. Example of parser:
  27. .. code-block:: python
  28. parser = [
  29. 'name',
  30. 'number',
  31. 'create_date',
  32. ('partner_id', ['id', 'display_name', 'ref'])
  33. ('line_id', ['id', ('product_id', ['name']), 'price_unit'])
  34. ]
  35. In order to be consitent with the odoo api the jsonify method always
  36. return a list of object even if there is only one element in input
  37. By default the key into the json is the name of the field extracted
  38. from the model. If you need to specify an alternate name to use as key, you
  39. can define your mapping as follow into the parser definition:
  40. .. code-block:: python
  41. parser = [
  42. 'field_name:json_key'
  43. ]
  44. .. code-block:: python
  45. parser = [
  46. 'name',
  47. 'number',
  48. 'create_date:creationDate',
  49. ('partner_id:partners', ['id', 'display_name', 'ref'])
  50. ('line_id:lines', ['id', ('product_id', ['name']), 'price_unit'])
  51. ]
  52. Also the module provide a method "get_json_parser" on the ir.exports object
  53. that generate a parser from an ir.exports configuration
  54. **Table of contents**
  55. .. contents::
  56. :local:
  57. Bug Tracker
  58. ===========
  59. Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
  60. In case of trouble, please check there if your issue has already been reported.
  61. If you spotted it first, help us smashing it by providing a detailed and welcomed
  62. `feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_jsonify%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
  63. Do not contact contributors directly about support or help with technical issues.
  64. Credits
  65. =======
  66. Authors
  67. ~~~~~~~
  68. * Akretion
  69. Contributors
  70. ~~~~~~~~~~~~
  71. * BEAU Sébastien <sebastien.beau@akretion.com>
  72. * Raphaël Reverdy <raphael.reverdy@akretion.com>
  73. * Laurent Mignon <laurent.mignon@acsone.eu>
  74. Maintainers
  75. ~~~~~~~~~~~
  76. This module is maintained by the OCA.
  77. .. image:: https://odoo-community.org/logo.png
  78. :alt: Odoo Community Association
  79. :target: https://odoo-community.org
  80. OCA, or the Odoo Community Association, is a nonprofit organization whose
  81. mission is to support the collaborative development of Odoo features and
  82. promote its widespread use.
  83. This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/10.0/base_jsonify>`_ project on GitHub.
  84. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.