From b2e7a38d74283faa260293d63039400f9b5fd1e2 Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Fri, 20 Oct 2017 17:45:21 +0200 Subject: [PATCH] [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 --- doc/howtos/backend.rst | 67 +++++++++------------------ doc/howtos/backend/exercise-dashboard | 2 +- doc/howtos/backend/exercise-gantt | 2 +- doc/howtos/backend/exercise-report | 4 +- doc/reference/reports.rst | 10 ++-- 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 - + - +

Report title

@@ -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 `_:: - - 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"/> + + 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 + -+ ++ + + + 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" /> + +