Search 1.9 billion lines of Odoo code on GitHub

base_jsonify

Author: Akretion, Odoo Community Association (OCA)
License: AGPL-3
Branch: 13.0-rlf_master
Repository: acsone/server-tools
Dependencies: base
Languages: HTML (372, 45.4%), PO File (40, 4.9%), Python (308, 37.6%), XML (40, 4.9%), and reStructuredText (59, 7.2%)
Other branches: 10.0, 10.0-abi_master, 10.0-backport-base_m2m_custom_field, 10.0-backport-slow_statement_logger-lmi, 10.0-backport_12.0-lmi, 10.0-base_jsonify_imp-lmi, 10.0-enhancements, 10.0-fix-base-suspend-security-search-lmi, 10.0-fix-base_exception-dro, 10.0-fix-base_techical_features_cache-dro, 10.0-fix-dependencies-sbi, 10.0-ftd_master, 10.0-imp-mass_editing-groups-dro, 10.0-imp-mass_editing_hooks-dro, 10.0-imp-task-13269, 10.0-jsonify-cpi, 10.0-lns_master, 10.0-mass_editing_improvements-dro, 10.0-mig-attachment_unindex_content, 10.0-mig-base_user_role_history, 10.0-ref_keychain_account_index_tbi, 10.0-session_db-lmi, 10.0-session_db-sbi, 10.0-xmlify-len, 12.0, 12.0-asw_master, 12.0-backport-shopinvader_customer_multi_user-len, 12.0-bxp_master, 12.0-jsonifyfull-len, 12.0-jsonifystored-len, 12.0-jsonifystoredsimple-len, 12.0-partition-len, 12.0-safetranlations-len, 12.0-trn_master, 12.0-xmlify-len, 13.0, 13.0-MIG-base_jsonify, 13.0-bp-jsonifier-ape, 13.0-custom_sequence_code, 13.0-fix-cache-base_jsonify-ape, 13.0-fix-precommit-ape, 13.0-jsonifyfull-len, 13.0-jsonifystored-len, 13.0-jsonifystorednew-len, 13.0-mig-html_text, 13.0-mig-request_auditor, 13.0-mig_auto_export, 13.0-partition-len, 13.0-session_db-sbi, 13.0-slg_master, 13.0-update-dotfiles-sbi, 13.0-xmlify-len, 14-fix-mc-base_tech_user-dro, 14.0, 14.0-mass_mailing_mail_server-mle, 14.0-session_db-sbi, 9.0-backport-base-jsonify, 9.0-slg_master, bai_10.0_add_base_ir_values_groups, and pre-commit-cache-sbi
Other repositories: 001101/server-tools, 0yik/ak-odoo-incubator, 0yik/server-tools, 2FM/server-tools, 50611/server-tools, AITIC/server-tools, AMhadhbi/server-tools, Albin-John/server-tools, Alex-Woo/server-tools, Alfa-90/server-tools, Artielkami/server-tools, CB-Gran-Canaria/server-tools, CGenie/server-tools, Callino/server-tools, Cgruppo/server-tools, ChanFeei/server-tools, Change2improve/server-tools, ChinaShrimp/server-tools, CodeFishEG/server-tools, Colorlessgold/server-tools, ComitorDevTeam/server-tools, CompassionCH/server-tools, Comunitea/server-tools, ContrerasTorrez/server-tools, CrazyJET/server-tools, CustomOdoo/server-tools, DITIntl/server-tools, Danielzhulin/server-tools, Digital5-Odoo/server-tools, Dobtor-OCA/server-tools, DucTruongKomit/server-tools, DulingLai/server-tools, EBII/ak-odoo-incubator, ERPLibre/server-tools, EssentNovaTeam/server-tools, FernandoRomera/server-tools, ForgeFlow/server-tools, GSLabIt/server-tools, Gabinete-Digital/server-tools, Gebesa-Dev/server-tools, GleydsonHudson/server-tools, Glue-Software-Engineering-AG/server-tools, HomerDeoDatu/server-tools, Ingeos/server-tools, Intesco2-0/server-tools, IvanShirokikh/server-tools, Jarsa/server-tools, Jeisonpernia/server-tools, JuaniFreedoo/server-tools, JuniorKRnd/server-tools, Koesj/server-tools, KonaERP/server-tools, KottmannM/server-tools, LasLabs/server-tools, LevelPrime/server-tools, LlywelynLi/server-tools, LourenzoH/server-tools, Mahmoud-Alaa-Eldeen/server-tools, MathBenTech/server-tools, MediaJockey/server-tools, Mefistous/server-tools, Melodivo/server-tools, MindAndGo/server-tools, MjAbuz/server-tools, NGTS-AUS/server-tools, NL66278/server-tools, NeatNerdPrime/server-tools, Numigi/server-tools, OCA-MUK/server-tools, OCA/server-tools, OdooBulgaria/ak-odoo-incubator, OdooIndonesia/server-tools, OpenAT/ak-odoo-incubator, Othniel1796/server-tools, PieterPaulussen/server-tools, PlanetaTIC/server-tools, Ppamungkas/server-tools, PrenorSistemas/server-tools, QubiQ/server-tools, RL-OtherApps/ak-odoo-incubator, Rad0van/server-tools, Reinhard-sheng/server-tools, SanteLibre/server-tools, ScopeaFrance/server-tools, SequarSrl/server-tools, SeuMarco/server-tools, SilvioGregorini/server-tools, SimoRubi/server-tools, SimoneVagile/server-tools, SokreamPhanqrl/server-tools, SportPursuit/server-tools, StefanRijnhart/server-tools, Syci-Consulting/server-tools, TDu/server-tools, TRESCLOUD/server-tools, Tecnativa/server-tools, Thorncrag/server-tools, TimLai125/server-tools, Tonow-c2c/server-tools, UnknownInfo/server-tools, VanMoof/server-tools, Vauxoo/server-tools, Yaman-als/server-tools, YannickB/server-tools, YogeshMahera-SerpentCS/server-tools, aadarsh977/server-tools, aaltinisik/server-tools, abakus-it/server-tools, abdulhalim-cu/server-tools, abdulrhmans/server-tools, acsone/ak-odoo-incubator, adekock11/server-tools, adhoc-dev/server-tools, aitorbouzas/server-tools, ajaychauhan727/server-tools, ajayjaviya/server-tools, ajinvn2019/server-tools, akretion/ak-odoo-incubator, akretion/server-tools, alan80080/server-tools, albertvimlet/server-tools, alessavindell/server-tools, alfadil/server-tools, altoch/server-tools, amendoncabh/server-tools, anassahmed/server-tools, andriisem/server-tools, anhvu-sg/server-tools, anodino-dev/server-tools, ansinaesmejor/server-tools, antilhue/server-tools, area-scm/server-tools, aurestic/server-tools, avoinsystems/server-tools, azmeuk/server-tools, bacgdev/server-tools, bacgroup/server-tools, bala07123/server-tools, bangil0/server-tools, bealdav/server-tools, bicomm/server-tools, blooparksystems/server-tools, bmya/server-tools, bodi000/server-tools, boky1993/server-tools, boutitinizar/server-tools, brain-tec/server-tools, brainbeanapps/server-tools, camptocamp/ak-odoo-incubator, camptocamp/server-tools, captivea-dcr/server-tools, cheikhousy/server-tools, claro5/server-tools, cogitoweb/server-tools, connect-to-ak/server-tools, coopiteasy/server-tools, corsojulian7/server-tools, crnd-inc/server-tools, dalal-intellisoft/server-tools, damdam-s/server-tools, dani-xtendoo/server-tools, daramousk/server-tools, davidwah/server-tools, delgerS/server-tools, dennybiasiolli/server-tools, devang-dreambits/server-tools, diggy128/server-tools, dipakthapaofficial/server-tools, dmsergio/server-tools, dndoanh/server-tools, dong-z/server-tools, druidoo-dev/server-tools, dsasoftware/ak-odoo-incubator, eLBati/server-tools, ebirbe/server-tools, ecosoft-odoo/server-tools, eezee-it/server-tools, elicoidal/server-tools, emagdalenaC2i/server-tools, enocare/server-tools, erfanjahanshahlo/server-tools, ermannognan/server-tools, etobella/server-tools, eversatis/server-tools, ewac-nl/server-tools, exosoftware/oca-server-tools, ferdiansahgg/server-tools, florian-dacosta/ak-odoo-incubator, fmdl/server-tools, focusate/oca-server-tools, gab-net/server-tools, gastonfeng/server-tools, gdgellatly/server-tools, gitguohao/server-tools, goanzaloo/server-tools, grindtildeath/server-tools, guandalf/server-tools, guewen/server-tools, gurneyalex/server-tools, habbaba/server-tools, hadjerBachiri/ak-odoo-incubator, hbrunn/server-tools, hdb1234/server-tools, henrryyanez/server-tools, hibou-io/oca-server-tools, hiisoc/server-tools, hinfo506/server-tools, hparfr/server-tools, hq8399/server-tools, hvcabaim/server-tools, i-vyshnevska/server-tools, iamyeonhan/ak-odoo-incubator, ideaspositivas-group/server-tools, igallart/server-tools, igor-mitin/server-tools, initOS/server-tools, insscn/server-tools, intero-chz/server-tools, invitu/server-tools, ip-candres/server-tools, izzihector/server-tools, jaballate/server-tools, jackxusho/server-tools, jacky82669513/server-tools, janverb/server-tools, jcarlosmontoya/server-tools, jeanpaul-mupagasi/server-tools, jeroen7s/server-tools, josueBulle/server-tools, josuf567/server-tools, jphatig/server-tools, julenalgios/server-tools, julianram/server-tools, kait-avalah/server-tools, kevinkhao/ak-odoo-incubator, kikopeiro/server-tools, kittiu/server-tools, kmee/server-tools, kos94ok-3D/server-tools, leemannd/server-tools, legalsylvain/server-tools, lembregtse/server-tools, lideritjnma/server-tools, liehu1/server-tools, lilotter45/server-tools, lincersolucoes/oca-server-tools, liweijie0812/server-tools, loftwah/server-tools, lonelyleaves/server-tools, magnuscolors/ak-odoo-incubator, magnuscolors/server-tools, maherjaballi/server-tools, marcelomora/server-tools, marionumza/ak-odoo-incubator, merchise-autrement/server-tools, mikolodz/server-tools, modoolar/server-tools, msdeek/server-tools, mulaudzicalvin/server-tools, multidadosti-erp/server-tools, myonnet/oca-server-tools, nabima/server-tools, nehaksolves/server-tools, newtratip/server-tools, nicolasjelincic/server-tools, nilshamerlinck/server-tools, niulinlnc/server-tools, njeudy/server-tools, ntsirintanis/server-tools, nuobit/server-tools, odof/server-tools, odoo247/server-tools, odooerpdevelopers/server-tools, odoogap/server-tools, omalbastin/server-tools, onesteinbv/server-tools, onurugur/server-tools, osiell/server-tools, p-tombez/server-tools, percypalomino/server-tools, petrus-v/server-tools, phillipstack/server-tools, piensom/server-tools, popcomputadores-desenv/server-tools, praxigento/oca-server-tools, presenceverte/server-tools, programadorzurita/server-tools, pythoner-3k/server-tools, raizs/server-tools, rdeheele/server-tools, rifki/server-tools, rm-jamotion/server-tools, robertsvx27/server-tools, romendil/server-tools, royalline1/server-tools, rrgaona/server-tools, rsullivan2704/server-tools, rudisulistyo/server-tools, rwfnf/server-tools, sanube/server-tools, savoirfairelinux/server-tools, sc4you/ak-odoo-incubator, schout-it/server-tools, sebalix/server-tools, sergiocorato/server-tools, sewisoft/server-tools, shepilov-vladislav/server-tools, simahawk/server-tools, simone/server-tools, skukered/server-tools, smile-888/server-tools, sodexis/server-tools, solvosci/server-tools, ssaid/server-tools, steingabelgaard/server-tools, sunflowerit/server-tools, sunshineLhj/server-tools, suprielfath/server-tools, swbs-co/server-tools, sylvainvh/server-tools, sysprocesarcastro/server-tools, tafaRU/server-tools, takinobori/oca-server-tools, tarteo/server-tools, tegin/server-tools, tirma-sa/server-tools, tmasson/server-tools, tongjiou/server-tools, tonygalmiche/server-tools, trevi-software/server-tools, trobz/server-tools, tuanna7593/server-tools, unitek-solusi/OCA-server-tools, ursais/server-tools, valenciaricardos/ak-odoo-incubator, valentinthirion/server-tools, valmarnet/server-tools, vdedyukhin/server-tools, ventor-tech/server-tools, versada/ak-odoo-incubator, versada/server-tools, victoralmau/server-tools, vidtsin/ak-odoo-incubator, vmelnych/server-tools, westlyou/ak-odoo-incubator, willmakenoise/server-tools, wuhuizhong/server-tools, xAlphaOmega/server-tools, xcgd/server-tools, xichun/server-tools, xtjie/server-tools, xuanmu/server-tools, xwh123807/server-tools, xwh1238070/server-tools, yalabsio/server-tools, ycp1015/server-tools, yelizariev/server-tools, ygdmxy/server-tools, ypapouin/server-tools, yuzhengxing/server-tools, zarumaru/server-tools, zeroincombenze/server-tools, zhaohengzeng/server-tools, and zhaohuaw/server-tools

<h1 class="title">Base Jsonify</h1> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/base_jsonify"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_jsonify"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p>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.</p> <p>Example of parser:</p> <pre> <code lang="python">parser = [ 'name', 'number', 'create_date', ('partner_id', ['id', 'display_name', 'ref']) ('line_id', ['id', ('product_id', ['name']), 'price_unit']) ]</code> </pre> <p>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</p> <p>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:</p> <pre> <code lang="python">parser = [ 'field_name:json_key' ]</code> </pre> <pre> <code lang="python">parser = [ 'name', 'number', 'create_date:creationDate', ('partner_id:partners', ['id', 'display_name', 'ref']) ('line_id:lines', ['id', ('product_id', ['name']), 'price_unit']) ]</code> </pre> <p>If you need to parse the value of a field in a custom way, you can pass a callable or the name of a method on the model:</p> <pre> <code lang="python">parser = [ ('name', &quot;jsonify_name&quot;) # method name ('number', lambda rec, field_name: rec[field_name] * 2)) # callable ]</code> </pre> <p>Also the module provide a method &quot;get_json_parser&quot; on the ir.exports object that generate a parser from an ir.exports configuration.</p> <p><strong>Table of contents</strong></p> <div class="contents local topic" id="contents"> <ul class="simple"> <li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li> <li><a class="reference internal" href="#credits" id="id2">Credits</a><ul> <li><a class="reference internal" href="#authors" id="id3">Authors</a></li> <li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li> <li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li> </ul> </li> </ul> </div> <a name="bug-tracker"></a> <h2><a class="toc-backref" href="#id1">Bug Tracker</a></h2> <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>. 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 <a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_jsonify%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <p>Do not contact contributors directly about support or help with technical issues.</p> <a name="credits"></a> <h2><a class="toc-backref" href="#id2">Credits</a></h2> <a name="authors"></a> <h3><a class="toc-backref" href="#id3">Authors</a></h3> <ul class="simple"> <li>Akretion</li> </ul> <a name="contributors"></a> <h3><a class="toc-backref" href="#id4">Contributors</a></h3> <ul class="simple"> <li>BEAU Sébastien &lt;<a class="reference external" href="mailto:sebastien.beau&#64;akretion.com">sebastien.beau&#64;akretion.com</a>&gt;</li> <li>Raphaël Reverdy &lt;<a class="reference external" href="mailto:raphael.reverdy&#64;akretion.com">raphael.reverdy&#64;akretion.com</a>&gt;</li> <li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li> </ul> <a name="maintainers"></a> <h3><a class="toc-backref" href="#id5">Maintainers</a></h3> <p>This module is maintained by the OCA.</p> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <p>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.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/base_jsonify">OCA/server-tools</a> project on GitHub.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>