Base module that provide the jsonify method on all models
Project description
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
Contributors
BEAU Sébastien <sebastien.beau@akretion.com>
Raphaël Reverdy <raphael.reverdy@akretion.com>
Laurent Mignon <laurent.mignon@acsone.eu>
Maintainers
This module is maintained by the OCA.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for odoo10_addon_base_jsonify-10.0.1.0.0.99.dev10-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16a1a5629e51a70cbbd1458c381531f4813386ef27ff5c7a9466ec54e97a2f5e |
|
MD5 | 09e24b89f20eab836e4567285b69af9b |
|
BLAKE2b-256 | 72d082d9706b85631a98907d3bcde689f0062b5622372bd756dbd1ddf9e8a03c |