summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRichard Mathot <rim@odoo.com>2017-10-20 17:45:21 +0200
committerRichard Mathot <rim@odoo.com>2017-10-23 11:45:05 +0200
commitb2e7a38d74283faa260293d63039400f9b5fd1e2 (patch)
tree71d1ff8f858b5eb2281f382dc1b08d90a608b84e /doc
parent9898c49754a064797a814c91aeb18c58f9b4ad2c (diff)
[FIX] doc: some changes due to Odoo 11
* Gantt view definitions have been changed * reports call different templates than Odoo 10.0 * XML-RPC and JSON-RPC examples migrated to Python 3
Diffstat (limited to 'doc')
-rw-r--r--doc/howtos/backend.rst67
-rw-r--r--doc/howtos/backend/exercise-dashboard2
-rw-r--r--doc/howtos/backend/exercise-gantt2
-rw-r--r--doc/howtos/backend/exercise-report4
-rw-r--r--doc/reference/reports.rst10
5 files changed, 30 insertions, 55 deletions
diff --git a/doc/howtos/backend.rst b/doc/howtos/backend.rst
index a42a92261ca..ec31f63af53 100644
--- a/doc/howtos/backend.rst
+++ b/doc/howtos/backend.rst
@@ -1501,7 +1501,7 @@ Reporting
Printed reports
---------------
-Odoo 8.0 comes with a new report engine based on :ref:`reference/qweb`,
+Odoo 11.0 uses a report engine based on :ref:`reference/qweb`,
`Twitter Bootstrap`_ and Wkhtmltopdf_.
A report is a combination two elements:
@@ -1529,9 +1529,9 @@ A report is a combination two elements:
.. code-block:: xml
- <t t-call="report.html_container">
+ <t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
- <t t-call="report.external_layout">
+ <t t-call="web.external_layout">
<div class="page">
<h2>Report title</h2>
</div>
@@ -1631,18 +1631,18 @@ exist in many languages.
XML-RPC Library
---------------
-The following example is a Python program that interacts with an Odoo
-server with the library ``xmlrpclib``::
+The following example is a Python 3 program that interacts with an Odoo
+server with the library ``xmlrpc.client``::
- import xmlrpclib
+ import xmlrpc.client
root = 'http://%s:%d/xmlrpc/' % (HOST, PORT)
- uid = xmlrpclib.ServerProxy(root + 'common').login(DB, USER, PASS)
- print "Logged in as %s (uid: %d)" % (USER, uid)
+ uid = xmlrpc.client.ServerProxy(root + 'common').login(DB, USER, PASS)
+ print("Logged in as %s (uid: %d)" % (USER, uid))
# Create a new note
- sock = xmlrpclib.ServerProxy(root + 'object')
+ sock = xmlrpc.client.ServerProxy(root + 'object')
args = {
'color' : 8,
'memo' : 'This is a note',
@@ -1662,7 +1662,7 @@ server with the library ``xmlrpclib``::
.. code-block:: python
import functools
- import xmlrpclib
+ import xmlrpc.client
HOST = 'localhost'
PORT = 8069
DB = 'openacademy'
@@ -1671,17 +1671,17 @@ server with the library ``xmlrpclib``::
ROOT = 'http://%s:%d/xmlrpc/' % (HOST,PORT)
# 1. Login
- uid = xmlrpclib.ServerProxy(ROOT + 'common').login(DB,USER,PASS)
- print "Logged in as %s (uid:%d)" % (USER,uid)
+ uid = xmlrpc.client.ServerProxy(ROOT + 'common').login(DB,USER,PASS)
+ print("Logged in as %s (uid:%d)" % (USER,uid))
call = functools.partial(
- xmlrpclib.ServerProxy(ROOT + 'object').execute,
+ xmlrpc.client.ServerProxy(ROOT + 'object').execute,
DB, uid, PASS)
# 2. Read the sessions
sessions = call('openacademy.session','search_read', [], ['name','seats'])
for session in sessions:
- print "Session %s (%s seats)" % (session['name'], session['seats'])
+ print("Session %s (%s seats)" % (session['name'], session['seats']))
# 3.create a new session
session_id = call('openacademy.session', 'create', {
'name' : 'My session',
@@ -1701,12 +1701,12 @@ server with the library ``xmlrpclib``::
JSON-RPC Library
----------------
-The following example is a Python program that interacts with an Odoo server
-with the standard Python libraries ``urllib2`` and ``json``::
+The following example is a Python 3 program that interacts with an Odoo server
+with the standard Python libraries ``urllib.request`` and ``json``::
import json
import random
- import urllib2
+ import urllib.request
def json_rpc(url, method, params):
data = {
@@ -1715,10 +1715,10 @@ with the standard Python libraries ``urllib2`` and ``json``::
"params": params,
"id": random.randint(0, 1000000000),
}
- req = urllib2.Request(url=url, data=json.dumps(data), headers={
+ req = urllib.request.Request(url=url, data=json.dumps(data).encode(), headers={
"Content-Type":"application/json",
})
- reply = json.load(urllib2.urlopen(req))
+ reply = json.load(urllib.request.urlopen(req))
if reply.get("error"):
raise Exception(reply["error"])
return reply["result"]
@@ -1732,37 +1732,12 @@ with the standard Python libraries ``urllib2`` and ``json``::
# create a new note
args = {
- 'color' : 8,
- 'memo' : 'This is another note',
+ 'color': 8,
+ 'memo': 'This is another note',
'create_uid': uid,
}
note_id = call(url, "object", "execute", DB, uid, PASS, 'note.note', 'create', args)
-Here is the same program, using the library
-`jsonrpclib <https://pypi.python.org/pypi/jsonrpclib>`_::
-
- import jsonrpclib
-
- # server proxy object
- url = "http://%s:%s/jsonrpc" % (HOST, PORT)
- server = jsonrpclib.Server(url)
-
- # log in the given database
- uid = server.call(service="common", method="login", args=[DB, USER, PASS])
-
- # helper function for invoking model methods
- def invoke(model, method, *args):
- args = [DB, uid, PASS, model, method] + list(args)
- return server.call(service="object", method="execute", args=args)
-
- # create a new note
- args = {
- 'color' : 8,
- 'memo' : 'This is another note',
- 'create_uid': uid,
- }
- note_id = invoke('note.note', 'create', args)
-
Examples can be easily adapted from XML-RPC to JSON-RPC.
.. note::
diff --git a/doc/howtos/backend/exercise-dashboard b/doc/howtos/backend/exercise-dashboard
index ecda32c82d7..01876e65114 100644
--- a/doc/howtos/backend/exercise-dashboard
+++ b/doc/howtos/backend/exercise-dashboard
@@ -90,6 +90,6 @@ Index: addons/openacademy/views/session_board.xml
+ name="Session Dashboard" parent="base.menu_reporting_dashboard"
+ action="open_board_session"
+ sequence="1"
-+ id="menu_board_session" icon="terp-graph"/>
++ id="menu_board_session"/>
+
+</odoo>
diff --git a/doc/howtos/backend/exercise-gantt b/doc/howtos/backend/exercise-gantt
index 63c3981f09e..6ee1e426ff3 100644
--- a/doc/howtos/backend/exercise-gantt
+++ b/doc/howtos/backend/exercise-gantt
@@ -45,7 +45,7 @@ diff --git a/openacademy/views/openacademy.xml b/openacademy/views/openacademy.x
+ <gantt string="Session Gantt" color="course_id"
+ date_start="start_date" date_delay="hours"
+ default_group_by='instructor_id'>
-+ <field name="name"/>
++ <!-- <field name="name"/> this is not required after Odoo 10.0 -->
+ </gantt>
+ </field>
+ </record>
diff --git a/doc/howtos/backend/exercise-report b/doc/howtos/backend/exercise-report
index cfe8cad4b67..68cc7b4b12e 100644
--- a/doc/howtos/backend/exercise-report
+++ b/doc/howtos/backend/exercise-report
@@ -29,9 +29,9 @@ Index: addons/openacademy/reports.xml
+ report_type="qweb-pdf" />
+
+ <template id="report_session_view">
-+ <t t-call="report.html_container">
++ <t t-call="web.html_container">
+ <t t-foreach="docs" t-as="doc">
-+ <t t-call="report.external_layout">
++ <t t-call="web.external_layout">
+ <div class="page">
+ <h2 t-field="doc.name"/>
+ <p>From <span t-field="doc.start_date"/> to <span t-field="doc.end_date"/></p>
diff --git a/doc/reference/reports.rst b/doc/reference/reports.rst
index e324b132ae0..6ec6e6a157c 100644
--- a/doc/reference/reports.rst
+++ b/doc/reference/reports.rst
@@ -83,9 +83,9 @@ Minimal viable template
A minimal template would look like::
<template id="report_invoice">
- <t t-call="report.html_container">
+ <t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
- <t t-call="report.external_layout">
+ <t t-call="web.external_layout">
<div class="page">
<h2>Report title</h2>
<p>This object's name is <span t-field="o.name"/></p>
@@ -143,7 +143,7 @@ For example, let's look at the Sale Order report from the Sale module::
<!-- Main template -->
<template id="report_saleorder">
- <t t-call="report.html_container">
+ <t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="sale.report_saleorder_document" t-lang="doc.partner_id.lang"/>
</t>
@@ -154,7 +154,7 @@ For example, let's look at the Sale Order report from the Sale module::
<template id="report_saleorder_document">
<!-- Re-browse of the record with the partner lang -->
<t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" />
- <t t-call="report.external_layout">
+ <t t-call="web.external_layout">
<div class="page">
<div class="oe_structure"/>
<div class="row">
@@ -175,7 +175,7 @@ each Sale Order will be printed in the language of the corresponding customer. I
to translate only the body of the document, but keep the header and footer in a default
language, you could call the report's external layout this way::
- <t t-call="report.external_layout" t-lang="en_US">
+ <t t-call="web.external_layout" t-lang="en_US">
.. tip::