In below example a sample widget that calls my_method() and displays the result.
local.HomePage = instance.Widget.extend({
start: function() {
var self = this;
var model = new instance.web.Model("oepetstore.message_of_the_day");
model.call("my_method", {context: new instance.web.CompoundContext()}).then(function(result) {
self.$el.append("Hello " + result["hello"] + "
");
// will show "Hello world" to the user
});
},
});
Note-The class used to call Odoo models is openerp.Model(). It is instantiated with the Odoo model's name as first parameter.
0 Comment(s)