==========================
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,
although supporting client features (e.g. new data representation such as
uid = xmlrpclib.ServerProxy(root + 'common').login(DB, USER, PASS)
print "Logged in as %s (uid: %d)" % (USER, uid)
- # Create a new idea
+ # Create a new note
sock = xmlrpclib.ServerProxy(root + 'object')
args = {
- 'name' : 'Another idea',
- 'description' : 'This is another idea of mine',
- 'inventor_id': uid,
+ 'color' : 8,
+ 'memo' : 'This is a note',
+ '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
url = "http://%s:%s/jsonrpc" % (HOST, PORT)
uid = call(url, "common", "login", DB, USER, PASS)
- # create a new idea
+ # create a new note
args = {
- 'name' : 'Another idea',
- 'description' : 'This is another idea of mine',
- 'inventor_id': uid,
+ 'color' : 8,
+ 'memo' : 'This is another note',
+ '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
`jsonrpclib <https://pypi.python.org/pypi/jsonrpclib>`::
args = [DB, uid, PASS, model, method] + list(args)
return server.call(service="object", method="execute", args=args)
- # create a new idea
+ # create a new note
args = {
- 'name' : 'Another idea',
- 'description' : 'This is another idea of mine',
- 'inventor_id': uid,
+ 'color' : 8,
+ 'memo' : 'This is another note',
+ '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.
+ </field>
+ </record>
+
-+ <!-- top level menu: no paret -->
++ <!-- top level menu: no parent -->
+ <menuitem id="main_openacademy_menu" name="Open Academy"/>
+ <!-- A first level in the left side menu is needed
+ before using action= attribute -->
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ 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"?>
+<openerp>
+ <data>
+ <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="view_type">form</field>
+ <field name="view_mode">graph</field>
+ ref="openacademy.openacademy_session_graph_view"/>
+ </record>
+ <record model="ir.actions.act_window" id="act_session_calendar">
++ <field name="name">Sessions</field>
+ <field name="res_model">openacademy.session</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">calendar</field>
+ <field name="view_id" ref="openacademy.session_calendar_view"/>
+ </record>
+ <record model="ir.actions.act_window" id="act_course_list">
++ <field name="name">Courses</field>
+ <field name="res_model">openacademy.course</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
============
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:: text
oepetstore
+ |-- images
+ | |-- alligator.jpg
+ | |-- ball.jpg
+ | |-- crazy_circle.jpg
+ | |-- fish.jpg
+ | `-- mice.jpg
|-- __init__.py
+ |-- oepetstore.message_of_the_day.csv
|-- __openerp__.py
|-- petstore_data.xml
|-- petstore.py
currently look like::
openerp.oepetstore = function(instance, local) {
- var _t = openerp.web._t,
- _lt = openerp.web._lt;
- var QWeb = openerp.web.qweb;
+ var _t = instance.web._t,
+ _lt = instance.web._lt;
+ var QWeb = instance.web.qweb;
local.HomePage = instance.Widget.extend({
start: function() {
},
});
- openerp.web.client_actions.add(
- 'petstore.homepage', 'local.HomePage');
+ instance.web.client_actions.add(
+ 'petstore.homepage', 'instance.oepetstore.HomePage');
}
Which only prints a small message in the browser's console.
structural extensibility where an XML-based templating engine can be
generically altered using e.g. XPath or CSS and a tree-alteration DSL (or
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
----------
},
start: function() {
this.input_changed();
+ return this._super();
},
input_changed: function() {
var color = [
local.HomePage = instance.Widget.extend({
template: "HomePage",
start: function() {
- this.colorInput = new local.ColorInputWidget(this)
- .on("change:color", this, this.color_changed);
- .appendTo(this.$el);
+ this.colorInput = new local.ColorInputWidget(this);
+ this.colorInput.on("change:color", this, this.color_changed);
+ return this.colorInput.appendTo(this.$el);
},
color_changed: function() {
this.$(".oe_color_div").css("background-color", this.colorInput.get("color"));
.filter([['categ_id.name', '=', "Pet Toys"]])
.limit(5)
.all()
- .then(function (result) {
- self.$el.append(QWeb.render('PetToys', {item: item}));
+ .then(function (results) {
+ _(results).each(function (item) {
+ self.$el.append(QWeb.render('PetToy', {item: item}));
+ });
});
}
});
<div class="oe_petstore_homepage_right"></div>
</div>
</t>
- <t t-name="MessageofTheDay">
+ <t t-name="MessageOfTheDay">
<div class="oe_petstore_motd">
<p class="oe_mywidget_message_of_the_day"></p>
</div>
.. patch::
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::
#. 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
allows using the website layout in our template
-#. use the wesite layout in the template
+#. use the website layout in the template
.. patch::
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
-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.
The teacher's name is also editable, and when saved the change is visible on
#. actions. Actions have various types: links, reports, code which Odoo should
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…
-#. 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
model is displayed inside the view.
* to extend a model in-place, it's :attr:`inherited
<openerp.models.Model._inherit>` without giving it a new
:attr:`~openerp.models.Model._name`
- * ``product.template`` already uses the discussions system, so we
- can remove it from our extension model
+ * ``product.template`` already uses the discussions system, so we can
+ remove it from our extension model
* we're creating our courses as *published* by default so they can be
seen without having to log in