Skip to main content

Base module that provide the jsonify method on all models

Project description

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

This module adds a ‘jsonify’ method to every model of the ORM. It works on the current recordset and requires a single argument ‘parser’ that specify the field to extract.

Example of parser:

parser = [
    'name',
    'number',
    'create_date',
    ('partner_id', ['id', 'display_name', 'ref'])
    ('line_id', ['id', ('product_id', ['name']), 'price_unit'])
]

In order to be consitent with the odoo api the jsonify method always return a list of object even if there is only one element in input

By default the key into the json is the name of the field extracted from the model. If you need to specify an alternate name to use as key, you can define your mapping as follow into the parser definition:

parser = [
    'field_name:json_key'
]
parser = [
    'name',
    'number',
    'create_date:creationDate',
    ('partner_id:partners', ['id', 'display_name', 'ref'])
    ('line_id:lines', ['id', ('product_id', ['name']), 'price_unit'])
]

Also the module provide a method “get_json_parser” on the ir.exports object that generate a parser from an ir.exports configuration.

Table of contents

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 smashing it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Akretion

Contributors

Maintainers

This module is maintained by the OCA.

Odoo Community Association

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.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

odoo12_addon_base_jsonify-12.0.1.1.1-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file odoo12_addon_base_jsonify-12.0.1.1.1-py3-none-any.whl.

File metadata

  • Download URL: odoo12_addon_base_jsonify-12.0.1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/30.4.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.5.3

File hashes

Hashes for odoo12_addon_base_jsonify-12.0.1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ef4086e103832cce612f5169fcd1db2ff5b87c74cc1dee0f32fd6d371babe02
MD5 9aa9d74cd50d1185d64cace97acc2a15
BLAKE2b-256 1dc734dfeedd572c1cb1f77e11fbe824e0b5c47d5fe98b64f1be745b6d08e599

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page