summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.model.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-03-05 09:34:56 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commite5740270568404d71a3bc093074a085c9c2eded8 (patch)
tree7b84740d92c550236de25a37cf37d244760bdbf3 /addons/website/static/src/js/website.model.js
parent0df9968433389e0d504276cd711473c2eef937ae (diff)
[REF] web,*: remove 'web.model' and 'web.dataModel
Use this.rpc instead of Model object, with web.ajax if necessary. nb: EventDispatcherMixin include now the custom_events managment instead of widget
Diffstat (limited to 'addons/website/static/src/js/website.model.js')
-rw-r--r--addons/website/static/src/js/website.model.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/addons/website/static/src/js/website.model.js b/addons/website/static/src/js/website.model.js
new file mode 100644
index 00000000000..66b75e398af
--- /dev/null
+++ b/addons/website/static/src/js/website.model.js
@@ -0,0 +1,41 @@
+/**
+ * Service to fetch data, websites Javascript must use performModelRPC of this module
+ */
+odoo.define('website.model', function (require) {
+"use strict";
+
+var Class = require('web.Class');
+var Mixins = require('web.mixins');
+var ajax = require('web.ajax');
+
+var CallService = Class.extend(Mixins.EventDispatcherMixin, {
+ custom_events: {
+ call_service: '_callService'
+ },
+ init: function () {
+ Mixins.EventDispatcherMixin.init.call(this);
+ },
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * @param {OdooEvent} event
+ */
+ _callService: function (event) {
+ var result = ajax[event.data.method].apply(ajax, event.data.args);
+ event.data.callback(result);
+ },
+});
+
+var Model = Class.extend(Mixins.EventDispatcherMixin, Mixins.ServicesMixin, {
+ init: function (parent) {
+ Mixins.EventDispatcherMixin.init.call(this);
+ this.setParent(parent);
+ },
+});
+
+return new Model(new CallService());
+});