Browse Source

[UPD] README.rst

13.0
OCA-git-bot 6 years ago
committed by laurent.corron
parent
commit
c1ca732300
  1. 5
      base_jsonify/README.rst
  2. 57
      base_jsonify/static/description/index.html

5
base_jsonify/README.rst

@ -25,8 +25,9 @@ Base Jsonify
|badge1| |badge2| |badge3| |badge4| |badge5|
This module add the jsonify method to the ORM. This method take as argument
the browse record and the "parser" that specify the field to extract.
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:

57
base_jsonify/static/description/index.html

@ -3,13 +3,13 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Base Jsonify</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7614 2013-02-21 15:55:51Z milde $
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
@ -37,6 +37,14 @@ table.borderless td, table.borderless th {
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
@ -161,12 +169,12 @@ h2.subtitle {
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left {
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right {
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
@ -177,6 +185,11 @@ img.align-center, .figure.align-center, object.align-center {
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
@ -194,6 +207,15 @@ div.align-right {
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
@ -346,16 +368,17 @@ ul.auto-toc {
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/10.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-10-0/server-tools-10-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/10.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module add the jsonify method to the ORM. This method take as argument
the browse record and the “parser” that specify the field to extract.</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 class="code python literal-block">
<span class="n">parser</span> <span class="o">=</span> <span class="p">[</span>
<span class="s">'name'</span><span class="p">,</span>
<span class="s">'number'</span><span class="p">,</span>
<span class="s">'create_date'</span><span class="p">,</span>
<span class="p">(</span><span class="s">'partner_id'</span><span class="p">,</span> <span class="p">[</span><span class="s">'id'</span><span class="p">,</span> <span class="s">'display_name'</span><span class="p">,</span> <span class="s">'ref'</span><span class="p">])</span>
<span class="p">(</span><span class="s">'line_id'</span><span class="p">,</span> <span class="p">[</span><span class="s">'id'</span><span class="p">,</span> <span class="p">(</span><span class="s">'product_id'</span><span class="p">,</span> <span class="p">[</span><span class="s">'name'</span><span class="p">]),</span> <span class="s">'price_unit'</span><span class="p">])</span>
<span class="s1">'name'</span><span class="p">,</span>
<span class="s1">'number'</span><span class="p">,</span>
<span class="s1">'create_date'</span><span class="p">,</span>
<span class="p">(</span><span class="s1">'partner_id'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'id'</span><span class="p">,</span> <span class="s1">'display_name'</span><span class="p">,</span> <span class="s1">'ref'</span><span class="p">])</span>
<span class="p">(</span><span class="s1">'line_id'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'id'</span><span class="p">,</span> <span class="p">(</span><span class="s1">'product_id'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'name'</span><span class="p">]),</span> <span class="s1">'price_unit'</span><span class="p">])</span>
<span class="p">]</span>
</pre>
<p>In order to be consitent with the odoo api the jsonify method always
@ -365,16 +388,16 @@ 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 class="code python literal-block">
<span class="n">parser</span> <span class="o">=</span> <span class="p">[</span>
<span class="s">'field_name:json_key'</span>
<span class="s1">'field_name:json_key'</span>
<span class="p">]</span>
</pre>
<pre class="code python literal-block">
<span class="n">parser</span> <span class="o">=</span> <span class="p">[</span>
<span class="s">'name'</span><span class="p">,</span>
<span class="s">'number'</span><span class="p">,</span>
<span class="s">'create_date:creationDate'</span><span class="p">,</span>
<span class="p">(</span><span class="s">'partner_id:partners'</span><span class="p">,</span> <span class="p">[</span><span class="s">'id'</span><span class="p">,</span> <span class="s">'display_name'</span><span class="p">,</span> <span class="s">'ref'</span><span class="p">])</span>
<span class="p">(</span><span class="s">'line_id:lines'</span><span class="p">,</span> <span class="p">[</span><span class="s">'id'</span><span class="p">,</span> <span class="p">(</span><span class="s">'product_id'</span><span class="p">,</span> <span class="p">[</span><span class="s">'name'</span><span class="p">]),</span> <span class="s">'price_unit'</span><span class="p">])</span>
<span class="s1">'name'</span><span class="p">,</span>
<span class="s1">'number'</span><span class="p">,</span>
<span class="s1">'create_date:creationDate'</span><span class="p">,</span>
<span class="p">(</span><span class="s1">'partner_id:partners'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'id'</span><span class="p">,</span> <span class="s1">'display_name'</span><span class="p">,</span> <span class="s1">'ref'</span><span class="p">])</span>
<span class="p">(</span><span class="s1">'line_id:lines'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'id'</span><span class="p">,</span> <span class="p">(</span><span class="s1">'product_id'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'name'</span><span class="p">]),</span> <span class="s1">'price_unit'</span><span class="p">])</span>
<span class="p">]</span>
</pre>
<p>Also the module provide a method “get_json_parser” on the ir.exports object

Loading…
Cancel
Save