diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-10-10 19:14:30 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-10-10 19:14:30 +0200 |
| commit | 0be264b29eac11a5dec5e6565d23d4ea86bd905a (patch) | |
| tree | 79362f2340c89cb3cf2e8d8a467f357b7c7a8326 /addons/iap/static/src/js | |
| parent | cf753a7fdf1739dcf37d2ad74f4c8efb3d4ff3b3 (diff) | |
| parent | e1104ac344cbc349a46b22339b13dfe9cbab8bcb (diff) | |
[MERGE] forward port branch 11.0 up to e1104ac344c
Diffstat (limited to 'addons/iap/static/src/js')
| -rw-r--r-- | addons/iap/static/src/js/crash_manager.js | 49 | ||||
| -rw-r--r-- | addons/iap/static/src/js/dashboard.js | 29 | ||||
| -rw-r--r-- | addons/iap/static/src/js/iap_credit.js | 28 |
3 files changed, 106 insertions, 0 deletions
diff --git a/addons/iap/static/src/js/crash_manager.js b/addons/iap/static/src/js/crash_manager.js new file mode 100644 index 00000000000..3c8d330013e --- /dev/null +++ b/addons/iap/static/src/js/crash_manager.js @@ -0,0 +1,49 @@ +odoo.define('iap.CrashManager', function (require) { +"use strict"; + +var ajax = require('web.ajax'); +var core = require('web.core'); +var CrashManager = require('web.CrashManager'); +var Dialog = require('web.Dialog'); + +var _t = core._t; +var QWeb = core.qweb; + +CrashManager.include({ + /** + * @override + */ + rpc_error: function (error) { + if (error.data.name === "odoo.addons.iap.models.iap.InsufficientCreditError") { + var error_data = JSON.parse(error.data.message); + ajax.jsonRpc('/web/dataset/call_kw', 'call', { + model: 'iap.account', + method: 'get_credits_url', + args: [], + kwargs: { + base_url: error_data.base_url, + service_name: error_data.service_name, + credit: error_data.credit, + } + }).then(function (url) { + new Dialog(this, { + size: 'large', + title: error_data.title || _t("Insufficient Balance"), + $content: $(QWeb.render('iap.redirect_to_odoo_credit', { + data: error_data, + })).css('padding', 0), + buttons: [ + {text: 'Buy credits at Odoo', classes : "btn-primary", click: function() { + window.open(url, '_blank'); + }, close:true}, + {text: _t("Cancel"), close: true} + ], + }).open(); + }); + } else { + this._super.apply(this, arguments); + } + }, +}); + +}); diff --git a/addons/iap/static/src/js/dashboard.js b/addons/iap/static/src/js/dashboard.js new file mode 100644 index 00000000000..b3490da2eda --- /dev/null +++ b/addons/iap/static/src/js/dashboard.js @@ -0,0 +1,29 @@ +odoo.define('iap.Dashboard', function (require) { +"use strict"; + +var ajax = require('web.ajax'); +var core = require('web.core'); +var Dashboard = require('web_settings_dashboard'); + +var _t = core._t; +var QWeb = core.qweb; + +Dashboard.Dashboard.include({ + /** + * @override + */ + load_apps: function (data) { + var _super = this._super.bind(this); + return ajax.jsonRpc('/web/dataset/call_kw', 'call', { + model: 'iap.account', + method: 'get_account_url', + args: [], + kwargs: {}, + }).then(function (url) { + data.apps.url = url; + return _super(data); + }); + }, +}); + +}); diff --git a/addons/iap/static/src/js/iap_credit.js b/addons/iap/static/src/js/iap_credit.js new file mode 100644 index 00000000000..37cddd72aa8 --- /dev/null +++ b/addons/iap/static/src/js/iap_credit.js @@ -0,0 +1,28 @@ +odoo.define('iap.redirect_odoo_credit_widget', function(require) { +"use strict"; + +var core = require('web.core'); +var framework = require('web.framework'); +var Widget = require('web.Widget'); +var QWeb = core.qweb; + + +var IapOdooCreditRedirect = Widget.extend({ + template: 'iap.redirect_to_odoo_credit', + events : { + "click .redirect_confirm" : "odoo_redirect", + }, + init: function (parent, action) { + this._super(parent, action); + this.url = action.params.url; + }, + + odoo_redirect: function () { + window.open(this.url, '_blank'); + this.do_action({type: 'ir.actions.act_window_close'}); + // framework.redirect(this.url); + }, + +}); +core.action_registry.add('iap_odoo_credit_redirect', IapOdooCreditRedirect); +}); |
