~jke-openerp/+junk/training-web

« back to all changes in this revision

Viewing changes to web_framework.rst

  • Committer: jke-openerp
  • Date: 2013-09-30 08:04:00 UTC
  • Revision ID: jke@openerp.com-20130930080400-5s47g60olu2te31z
...

Show diffs side-by-side

added added

removed removed

Lines of Context:
912
912
                    });
913
913
                    self.input_changed();
914
914
                },
915
 
                input_changed: function(confirm) {
 
915
                input_changed: function() {
916
916
                    var color = "#";
917
917
                    color += this.$el.find(".oe_color_red").val();
918
918
                    color += this.$el.find(".oe_color_green").val();
1122
1122
 
1123
1123
    Please note that, even if ``include()`` can be a powerful tool, it's not considered a very good programming practice
1124
1124
    because it can easily create problems if used in a wrong way. So you should use it to modify the behavior of an
1125
 
    existing component only when the is no other possibility, and try to limit its usages to the strict minimum.
 
1125
    existing component only when there are no other options, and try to limit its usages to the strict minimum.
1126
1126
 
1127
1127
Translations
1128
1128
------------
1353
1353
.. topic:: Exercise - Message of the Day
1354
1354
 
1355
1355
    Create a widget ``MessageOfTheDay`` that will display the message contained in the last record of the
1356
 
    ``message_of_the_day``. The widget should query the message as soon as it is inserted the the DOM and display the
 
1356
    ``message_of_the_day``. The widget should query the message as soon as it is inserted in the DOM and display the
1357
1357
    message to the user. Display that widget on the home page of the OpenERP Pet Store module.
1358
1358
 
1359
1359
.. only:: not nosolutions
1386
1386
                },
1387
1387
                start: function() {
1388
1388
                    var self = this;
1389
 
                    new instance.web.Model("message_of_the_day").query(["message"]).first().then(function(result) {
 
1389
                    new instance.web.Model("message_of_the_day").query(["message"]).order_by("-id").first().then(function(result) {
1390
1390
                        self.$(".oe_mywidget_message_of_the_day").text(result.message);
1391
1391
                    });
1392
1392
                },
1455
1455
            instance.oepetstore.HomePage = instance.web.Widget.extend({
1456
1456
                template: "HomePage",
1457
1457
                start: function() {
 
1458
                    var motd = new instance.oepetstore.MessageOfTheDay(this);
 
1459
                    motd.appendTo(this.$(".oe_petstore_homepage_left"));
 
1460
 
1458
1461
                    var pettoys = new instance.oepetstore.PetToysList(this);
1459
 
                    pettoys.appendTo(this.$(".oe_petstore_homepage_left"));
1460
 
                    var motd = new instance.oepetstore.MessageOfTheDay(this);
1461
 
                    motd.appendTo(this.$(".oe_petstore_homepage_right"));
 
1462
                    pettoys.appendTo(this.$(".oe_petstore_homepage_right"));
1462
1463
                },
1463
1464
            });
1464
1465