[FIX] doc: typos and code samples from howtos
* The dashboard from the backend howto doesn't specify "name" field which causes non-null constraint violation. * Some useful examples uses idea.idea" model which isn't available in 8.0 so I replaced them with "note.note". closes #3993
This commit is contained in:
parent
83b28737e9
commit
38f0508bba
|
@ -8,7 +8,7 @@ Start/Stop the Odoo server
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
Odoo uses a client/server architecture in which clients are web browsers
|
Odoo uses a client/server architecture in which clients are web browsers
|
||||||
accessing the odoo server via RPC.
|
accessing the Odoo server via RPC.
|
||||||
|
|
||||||
Business logic and extension is generally performed on the server side,
|
Business logic and extension is generally performed on the server side,
|
||||||
although supporting client features (e.g. new data representation such as
|
although supporting client features (e.g. new data representation such as
|
||||||
|
@ -1691,14 +1691,14 @@ server with the library ``xmlrpclib``::
|
||||||
uid = xmlrpclib.ServerProxy(root + 'common').login(DB, USER, PASS)
|
uid = xmlrpclib.ServerProxy(root + 'common').login(DB, USER, PASS)
|
||||||
print "Logged in as %s (uid: %d)" % (USER, uid)
|
print "Logged in as %s (uid: %d)" % (USER, uid)
|
||||||
|
|
||||||
# Create a new idea
|
# Create a new note
|
||||||
sock = xmlrpclib.ServerProxy(root + 'object')
|
sock = xmlrpclib.ServerProxy(root + 'object')
|
||||||
args = {
|
args = {
|
||||||
'name' : 'Another idea',
|
'color' : 8,
|
||||||
'description' : 'This is another idea of mine',
|
'memo' : 'This is a note',
|
||||||
'inventor_id': uid,
|
'create_uid': uid,
|
||||||
}
|
}
|
||||||
idea_id = sock.execute(DB, uid, PASS, 'idea.idea', 'create', args)
|
note_id = sock.execute(DB, uid, PASS, 'note.note', 'create', args)
|
||||||
|
|
||||||
.. exercise:: Add a new service to the client
|
.. exercise:: Add a new service to the client
|
||||||
|
|
||||||
|
@ -1780,13 +1780,13 @@ with the standard Python libraries ``urllib2`` and ``json``::
|
||||||
url = "http://%s:%s/jsonrpc" % (HOST, PORT)
|
url = "http://%s:%s/jsonrpc" % (HOST, PORT)
|
||||||
uid = call(url, "common", "login", DB, USER, PASS)
|
uid = call(url, "common", "login", DB, USER, PASS)
|
||||||
|
|
||||||
# create a new idea
|
# create a new note
|
||||||
args = {
|
args = {
|
||||||
'name' : 'Another idea',
|
'color' : 8,
|
||||||
'description' : 'This is another idea of mine',
|
'memo' : 'This is another note',
|
||||||
'inventor_id': uid,
|
'create_uid': uid,
|
||||||
}
|
}
|
||||||
idea_id = call(url, "object", "execute", DB, uid, PASS, 'idea.idea', 'create', args)
|
note_id = call(url, "object", "execute", DB, uid, PASS, 'note.note', 'create', args)
|
||||||
|
|
||||||
Here is the same program, using the library
|
Here is the same program, using the library
|
||||||
`jsonrpclib <https://pypi.python.org/pypi/jsonrpclib>`::
|
`jsonrpclib <https://pypi.python.org/pypi/jsonrpclib>`::
|
||||||
|
@ -1805,13 +1805,13 @@ Here is the same program, using the library
|
||||||
args = [DB, uid, PASS, model, method] + list(args)
|
args = [DB, uid, PASS, model, method] + list(args)
|
||||||
return server.call(service="object", method="execute", args=args)
|
return server.call(service="object", method="execute", args=args)
|
||||||
|
|
||||||
# create a new idea
|
# create a new note
|
||||||
args = {
|
args = {
|
||||||
'name' : 'Another idea',
|
'color' : 8,
|
||||||
'description' : 'This is another idea of mine',
|
'memo' : 'This is another note',
|
||||||
'inventor_id': uid,
|
'create_uid': uid,
|
||||||
}
|
}
|
||||||
idea_id = invoke('idea.idea', 'create', args)
|
note_id = invoke('note.note', 'create', args)
|
||||||
|
|
||||||
Examples can be easily adapted from XML-RPC to JSON-RPC.
|
Examples can be easily adapted from XML-RPC to JSON-RPC.
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ Index: addons/openacademy/views/openacademy.xml
|
||||||
+ </field>
|
+ </field>
|
||||||
+ </record>
|
+ </record>
|
||||||
+
|
+
|
||||||
+ <!-- top level menu: no paret -->
|
+ <!-- top level menu: no parent -->
|
||||||
+ <menuitem id="main_openacademy_menu" name="Open Academy"/>
|
+ <menuitem id="main_openacademy_menu" name="Open Academy"/>
|
||||||
+ <!-- A first level in the left side menu is needed
|
+ <!-- A first level in the left side menu is needed
|
||||||
+ before using action= attribute -->
|
+ before using action= attribute -->
|
||||||
|
|
|
@ -26,11 +26,12 @@ Index: addons/openacademy/views/session_board.xml
|
||||||
===================================================================
|
===================================================================
|
||||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||||
+++ addons/openacademy/views/session_board.xml 2014-08-26 17:26:21.531783052 +0200
|
+++ addons/openacademy/views/session_board.xml 2014-08-26 17:26:21.531783052 +0200
|
||||||
@@ -0,0 +1,63 @@
|
@@ -0,0 +1,66 @@
|
||||||
+<?xml version="1.0"?>
|
+<?xml version="1.0"?>
|
||||||
+<openerp>
|
+<openerp>
|
||||||
+ <data>
|
+ <data>
|
||||||
+ <record model="ir.actions.act_window" id="act_session_graph">
|
+ <record model="ir.actions.act_window" id="act_session_graph">
|
||||||
|
+ <field name="name">Attendees by course</field>
|
||||||
+ <field name="res_model">openacademy.session</field>
|
+ <field name="res_model">openacademy.session</field>
|
||||||
+ <field name="view_type">form</field>
|
+ <field name="view_type">form</field>
|
||||||
+ <field name="view_mode">graph</field>
|
+ <field name="view_mode">graph</field>
|
||||||
|
@ -38,12 +39,14 @@ Index: addons/openacademy/views/session_board.xml
|
||||||
+ ref="openacademy.openacademy_session_graph_view"/>
|
+ ref="openacademy.openacademy_session_graph_view"/>
|
||||||
+ </record>
|
+ </record>
|
||||||
+ <record model="ir.actions.act_window" id="act_session_calendar">
|
+ <record model="ir.actions.act_window" id="act_session_calendar">
|
||||||
|
+ <field name="name">Sessions</field>
|
||||||
+ <field name="res_model">openacademy.session</field>
|
+ <field name="res_model">openacademy.session</field>
|
||||||
+ <field name="view_type">form</field>
|
+ <field name="view_type">form</field>
|
||||||
+ <field name="view_mode">calendar</field>
|
+ <field name="view_mode">calendar</field>
|
||||||
+ <field name="view_id" ref="openacademy.session_calendar_view"/>
|
+ <field name="view_id" ref="openacademy.session_calendar_view"/>
|
||||||
+ </record>
|
+ </record>
|
||||||
+ <record model="ir.actions.act_window" id="act_course_list">
|
+ <record model="ir.actions.act_window" id="act_course_list">
|
||||||
|
+ <field name="name">Courses</field>
|
||||||
+ <field name="res_model">openacademy.course</field>
|
+ <field name="res_model">openacademy.course</field>
|
||||||
+ <field name="view_type">form</field>
|
+ <field name="view_type">form</field>
|
||||||
+ <field name="view_mode">tree,form</field>
|
+ <field name="view_mode">tree,form</field>
|
||||||
|
|
|
@ -8,7 +8,7 @@ Basic set up
|
||||||
============
|
============
|
||||||
|
|
||||||
Create a basic theme module with :command:`odoo.py scaffold` and the ``theme``
|
Create a basic theme module with :command:`odoo.py scaffold` and the ``theme``
|
||||||
template: from the root odoo folder, use
|
template: from the root Odoo folder, use
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,14 @@ If you browse the ``petstore`` folder, you should see the following content:
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
|
||||||
oepetstore
|
oepetstore
|
||||||
|
|-- images
|
||||||
|
| |-- alligator.jpg
|
||||||
|
| |-- ball.jpg
|
||||||
|
| |-- crazy_circle.jpg
|
||||||
|
| |-- fish.jpg
|
||||||
|
| `-- mice.jpg
|
||||||
|-- __init__.py
|
|-- __init__.py
|
||||||
|
|-- oepetstore.message_of_the_day.csv
|
||||||
|-- __openerp__.py
|
|-- __openerp__.py
|
||||||
|-- petstore_data.xml
|
|-- petstore_data.xml
|
||||||
|-- petstore.py
|
|-- petstore.py
|
||||||
|
@ -78,9 +85,9 @@ sub-folders are conventional and not strictly necessary.
|
||||||
currently look like::
|
currently look like::
|
||||||
|
|
||||||
openerp.oepetstore = function(instance, local) {
|
openerp.oepetstore = function(instance, local) {
|
||||||
var _t = openerp.web._t,
|
var _t = instance.web._t,
|
||||||
_lt = openerp.web._lt;
|
_lt = instance.web._lt;
|
||||||
var QWeb = openerp.web.qweb;
|
var QWeb = instance.web.qweb;
|
||||||
|
|
||||||
local.HomePage = instance.Widget.extend({
|
local.HomePage = instance.Widget.extend({
|
||||||
start: function() {
|
start: function() {
|
||||||
|
@ -88,8 +95,8 @@ sub-folders are conventional and not strictly necessary.
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
openerp.web.client_actions.add(
|
instance.web.client_actions.add(
|
||||||
'petstore.homepage', 'local.HomePage');
|
'petstore.homepage', 'instance.oepetstore.HomePage');
|
||||||
}
|
}
|
||||||
|
|
||||||
Which only prints a small message in the browser's console.
|
Which only prints a small message in the browser's console.
|
||||||
|
@ -528,7 +535,7 @@ characteristics:
|
||||||
structural extensibility where an XML-based templating engine can be
|
structural extensibility where an XML-based templating engine can be
|
||||||
generically altered using e.g. XPath or CSS and a tree-alteration DSL (or
|
generically altered using e.g. XPath or CSS and a tree-alteration DSL (or
|
||||||
even just XSLT). This flexibility and extensibility is a core
|
even just XSLT). This flexibility and extensibility is a core
|
||||||
characteristic of Odoo, and losting it was considered unacceptable.
|
characteristic of Odoo, and losing it was considered unacceptable.
|
||||||
|
|
||||||
Using QWeb
|
Using QWeb
|
||||||
----------
|
----------
|
||||||
|
@ -1121,6 +1128,7 @@ Exercise
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
this.input_changed();
|
this.input_changed();
|
||||||
|
return this._super();
|
||||||
},
|
},
|
||||||
input_changed: function() {
|
input_changed: function() {
|
||||||
var color = [
|
var color = [
|
||||||
|
@ -1136,9 +1144,9 @@ Exercise
|
||||||
local.HomePage = instance.Widget.extend({
|
local.HomePage = instance.Widget.extend({
|
||||||
template: "HomePage",
|
template: "HomePage",
|
||||||
start: function() {
|
start: function() {
|
||||||
this.colorInput = new local.ColorInputWidget(this)
|
this.colorInput = new local.ColorInputWidget(this);
|
||||||
.on("change:color", this, this.color_changed);
|
this.colorInput.on("change:color", this, this.color_changed);
|
||||||
.appendTo(this.$el);
|
return this.colorInput.appendTo(this.$el);
|
||||||
},
|
},
|
||||||
color_changed: function() {
|
color_changed: function() {
|
||||||
this.$(".oe_color_div").css("background-color", this.colorInput.get("color"));
|
this.$(".oe_color_div").css("background-color", this.colorInput.get("color"));
|
||||||
|
@ -1560,8 +1568,10 @@ Exercises
|
||||||
.filter([['categ_id.name', '=', "Pet Toys"]])
|
.filter([['categ_id.name', '=', "Pet Toys"]])
|
||||||
.limit(5)
|
.limit(5)
|
||||||
.all()
|
.all()
|
||||||
.then(function (result) {
|
.then(function (results) {
|
||||||
self.$el.append(QWeb.render('PetToys', {item: item}));
|
_(results).each(function (item) {
|
||||||
|
self.$el.append(QWeb.render('PetToy', {item: item}));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1578,7 +1588,7 @@ Exercises
|
||||||
<div class="oe_petstore_homepage_right"></div>
|
<div class="oe_petstore_homepage_right"></div>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
<t t-name="MessageofTheDay">
|
<t t-name="MessageOfTheDay">
|
||||||
<div class="oe_petstore_motd">
|
<div class="oe_petstore_motd">
|
||||||
<p class="oe_mywidget_message_of_the_day"></p>
|
<p class="oe_mywidget_message_of_the_day"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -142,7 +142,7 @@ First define an Odoo model file and import it:
|
||||||
.. patch::
|
.. patch::
|
||||||
|
|
||||||
Then setup :ref:`basic access control <reference/security/acl>` for the model
|
Then setup :ref:`basic access control <reference/security/acl>` for the model
|
||||||
and and add them to the manifest:
|
and add them to the manifest:
|
||||||
|
|
||||||
.. patch::
|
.. patch::
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ integration and a few other services (e.g. default styling, theming) via the
|
||||||
#. then add the ``website=True`` flag on the controller, this sets up a few
|
#. then add the ``website=True`` flag on the controller, this sets up a few
|
||||||
new variables on :ref:`the request object <reference/http/request>` and
|
new variables on :ref:`the request object <reference/http/request>` and
|
||||||
allows using the website layout in our template
|
allows using the website layout in our template
|
||||||
#. use the wesite layout in the template
|
#. use the website layout in the template
|
||||||
|
|
||||||
.. patch::
|
.. patch::
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ interfaces. Change the *person* template to use ``t-field``:
|
||||||
|
|
||||||
Restart Odoo and upgrade the module, there is now a placeholder under the
|
Restart Odoo and upgrade the module, there is now a placeholder under the
|
||||||
teacher's name and a new zone for blocks in :guilabel:`Edit` mode. Content
|
teacher's name and a new zone for blocks in :guilabel:`Edit` mode. Content
|
||||||
dropped there is stored in the correspoding teacher's ``biography`` field, and
|
dropped there is stored in the corresponding teacher's ``biography`` field, and
|
||||||
thus specific to that teacher.
|
thus specific to that teacher.
|
||||||
|
|
||||||
The teacher's name is also editable, and when saved the change is visible on
|
The teacher's name is also editable, and when saved the change is visible on
|
||||||
|
@ -344,7 +344,7 @@ The conceptual structure of the Odoo backend is simple:
|
||||||
#. actions. Actions have various types: links, reports, code which Odoo should
|
#. actions. Actions have various types: links, reports, code which Odoo should
|
||||||
execute or data display. Data display actions are called *window actions*,
|
execute or data display. Data display actions are called *window actions*,
|
||||||
and tell Odoo to display a given *model* according to a set of views…
|
and tell Odoo to display a given *model* according to a set of views…
|
||||||
#. a view has a type, a the broad category to which it corresponds (a list,
|
#. a view has a type, a broad category to which it corresponds (a list,
|
||||||
a graph, a calendar) and an *architecture* which customises the way the
|
a graph, a calendar) and an *architecture* which customises the way the
|
||||||
model is displayed inside the view.
|
model is displayed inside the view.
|
||||||
|
|
||||||
|
@ -457,8 +457,8 @@ though they may have to be looked for.
|
||||||
* to extend a model in-place, it's :attr:`inherited
|
* to extend a model in-place, it's :attr:`inherited
|
||||||
<openerp.models.Model._inherit>` without giving it a new
|
<openerp.models.Model._inherit>` without giving it a new
|
||||||
:attr:`~openerp.models.Model._name`
|
:attr:`~openerp.models.Model._name`
|
||||||
* ``product.template`` already uses the discussions system, so we
|
* ``product.template`` already uses the discussions system, so we can
|
||||||
can remove it from our extension model
|
remove it from our extension model
|
||||||
* we're creating our courses as *published* by default so they can be
|
* we're creating our courses as *published* by default so they can be
|
||||||
seen without having to log in
|
seen without having to log in
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue