summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/form_widgets.js
diff options
context:
space:
mode:
authorAdrien Dieudonne <adr@odoo.com>2015-10-01 10:29:25 +0200
committerAntony Lesuisse <al@openerp.com>2015-10-01 12:01:10 +0200
commit7d7a73241b2f0e0718ce805a136e51a251e15fc5 (patch)
tree719ef3b7c863a7162591c90165a977ea2b35ba8a /addons/web/static/src/js/views/form_widgets.js
parent622b96957d5944604408f4fc5a51564a4473fed1 (diff)
[FIX] enterprise settings upgrade widgets
Diffstat (limited to 'addons/web/static/src/js/views/form_widgets.js')
-rw-r--r--addons/web/static/src/js/views/form_widgets.js119
1 files changed, 72 insertions, 47 deletions
diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js
index 958ed51706f..806fea43deb 100644
--- a/addons/web/static/src/js/views/form_widgets.js
+++ b/addons/web/static/src/js/views/form_widgets.js
@@ -1633,58 +1633,47 @@ var FieldToggleBoolean = common.AbstractField.extend({
This widget is intended to be used in config settings.
When checked, an upgrade popup is showed to the user.
*/
-var UpgradeBoolean = FieldBoolean.extend({
- template: "FieldUpgradeBoolean",
+
+var AbstractFieldUpgrade = {
events: {
- 'click input': 'click_on_input',
+ 'click input': 'on_click_input',
},
-
- init: function() {
+
+ start: function() {
this._super.apply(this, arguments);
+
+ this.get_enterprise_label().after($("<span>", {
+ text: "Enterprise",
+ 'class': "label label-primary oe_inline"
+ }));
},
-
- click_on_input: function(event) {
- var self = this;
-
- if(this.$checkbox.prop("checked")) {
-
- var message = _t('You need to upgrade to Odoo Enterprise to activate this feature.');
-
- var buttons = [
- {
- text: _t("Upgrade now"),
- classes: 'btn-primary',
- close: true,
- click: this.confirm_upgrade,
- },
- {
- text: _t("Cancel"),
- close: true,
- },
- ];
-
- var dialog = new Dialog(this, {
- size: 'medium',
- buttons: buttons,
- $content: $('<div>', {
- text: message,
- }),
- title: _t("Odoo Enterprise"),
- }).open();
-
- dialog.on('closed', this, function() {
- this.$checkbox.prop("checked", false);
- });
- }
- },
-
- render_value: function() {
- this._super();
- this.$el.append(" <span class='label label-primary oe_inline'>Enterprise</span>");
+
+ open_dialog: function() {
+ var message = _t('You need to upgrade to Odoo Enterprise to activate this feature.');
+ var buttons = [
+ {
+ text: _t("Upgrade now"),
+ classes: 'btn-primary',
+ close: true,
+ click: this.confirm_upgrade,
+ },
+ {
+ text: _t("Cancel"),
+ close: true,
+ },
+ ];
+
+ return new Dialog(this, {
+ size: 'medium',
+ buttons: buttons,
+ $content: $('<div>', {
+ text: message,
+ }),
+ title: _t("Odoo Enterprise"),
+ }).open();
},
-
+
confirm_upgrade: function() {
- var self = this;
new Model("res.users").call("read", [session.uid, ["partner_id"]]).done(function(data) {
if(data.partner_id) {
new Model("res.partner").call("read", [data.partner_id[0], ["name", "lang", "country_id", "email", "phone"]]).done(function(data) {
@@ -1702,8 +1691,43 @@ var UpgradeBoolean = FieldBoolean.extend({
}
});
},
+
+ get_enterprise_label: function() {},
+ on_click_input: function() {},
+};
+
+var UpgradeBoolean = FieldBoolean.extend(AbstractFieldUpgrade, {
+ template: "FieldUpgradeBoolean",
+
+ get_enterprise_label: function() {
+ return this.$label;
+ },
+
+ on_click_input: function(event) {
+ if(this.$checkbox.prop("checked")) {
+ this.open_dialog().on('closed', this, function() {
+ this.$checkbox.prop("checked", false);
+ });
+ }
+ },
+});
+
+var UpgradeRadio = FieldRadio.extend(AbstractFieldUpgrade, {
+
+ get_enterprise_label: function() {
+ return this.$('label').last();
+ },
+
+ on_click_input: function(event) {
+ if($(event.target).val() == 1) {
+ this.open_dialog().on('closed', this, function() {
+ this.$('input').first().prop("checked", true);
+ });
+ }
+ },
});
+
/**
* Registry of form fields, called by :js:`instance.web.FormView`.
*
@@ -1740,7 +1764,8 @@ core.form_widget_registry
.add('statinfo', StatInfo)
.add('timezone_mismatch', TimezoneMismatch)
.add('label_selection', LabelSelection)
- .add('upgrade_boolean', UpgradeBoolean);
+ .add('upgrade_boolean', UpgradeBoolean)
+ .add('upgrade_radio', UpgradeRadio);
/**