summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome.js13
-rw-r--r--addons/web/static/src/js/corelib.js4
-rw-r--r--addons/web/static/src/js/data.js3
-rw-r--r--addons/web/static/src/js/view_form.js86
-rw-r--r--addons/web/static/src/js/view_list_editable.js2
-rw-r--r--addons/web/static/src/js/views.js25
6 files changed, 67 insertions, 66 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index af6d4f0cf18..2b37ea9999a 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -627,6 +627,7 @@ instance.web.Reload = function(parent, params) {
hash = "#menu_id=" + menu_id;
}
var url = l.protocol + "//" + l.host + l.pathname + search + hash;
+ window.onerror = function() {};
window.location = url;
};
instance.web.client_actions.add("reload", "instance.web.Reload");
@@ -881,6 +882,7 @@ instance.web.UserMenu = instance.web.Widget.extend({
on_action: function() {
},
on_menu_logout: function() {
+ this.trigger('user_logout');
},
on_menu_settings: function() {
var self = this;
@@ -1019,15 +1021,13 @@ instance.web.WebClient = instance.web.Client.extend({
var state = $.bbq.getState(true);
var action = {
- 'type': 'ir.actions.client',
- 'tag': 'login',
- 'params': state
+ type: 'ir.actions.client',
+ tag: 'login',
+ _push_me: false,
};
this.action_manager.do_action(action);
this.action_manager.inner_widget.on('login_successful', this, function() {
- this.do_push_state(state);
- this._current_state = null; // ensure the state will be loaded
this.show_application(); // will load the state we just pushed
});
},
@@ -1039,7 +1039,7 @@ instance.web.WebClient = instance.web.Client.extend({
self.menu.on('menu_click', this, this.on_menu_action);
self.user_menu = new instance.web.UserMenu(self);
self.user_menu.replace(this.$el.find('.oe_user_menu_placeholder'));
- self.user_menu.on_menu_logout.add(this.proxy('on_logout'));
+ self.user_menu.on('user_logout', self, this.proxy('on_logout'));
self.user_menu.on_action.add(this.proxy('on_menu_action'));
self.user_menu.do_update();
self.bind_hashchange();
@@ -1103,6 +1103,7 @@ instance.web.WebClient = instance.web.Client.extend({
});
});
} else {
+ state._push_me = false; // no need to push state back...
this.action_manager.do_load_state(state, !!this._current_state);
}
}
diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js
index b5fbacc7927..8c38724b1d5 100644
--- a/addons/web/static/src/js/corelib.js
+++ b/addons/web/static/src/js/corelib.js
@@ -1440,6 +1440,10 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
},
});
+instance.web.py_eval = function(expr, context) {
+ return py.eval(expr, _.extend({}, context || {}, {"true": true, "false": false, "null": null}));
+};
+
}
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js
index ce85e0ac43f..8338ce8c7c0 100644
--- a/addons/web/static/src/js/data.js
+++ b/addons/web/static/src/js/data.js
@@ -280,7 +280,8 @@ instance.web.Model = instance.web.Class.extend({
kwargs = args;
args = [];
}
- return instance.session.rpc('/web/dataset/call_kw', {
+ var debug = instance.session.debug ? '/'+this.name+':'+method : '';
+ return instance.session.rpc('/web/dataset/call_kw' + debug, {
model: this.name,
method: method,
args: args,
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index afb5e258c0b..ee790d8f94a 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -431,7 +431,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
do_notify_change: function() {
this.$el.add(this.$buttons).addClass('oe_form_dirty');
},
- on_pager_action: function(action) {
+ execute_pager_action: function(action) {
if (this.can_be_discarded()) {
switch (action) {
case 'first':
@@ -448,6 +448,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
break;
}
this.reload();
+ this.trigger('pager_action_executed');
}
},
init_pager: function() {
@@ -464,7 +465,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
}
this.$pager.on('click','a[data-pager-action]',function() {
var action = $(this).data('pager-action');
- self.on_pager_action(action);
+ self.execute_pager_action(action);
});
this.do_update_pager();
},
@@ -747,7 +748,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
},
on_button_save: function() {
var self = this;
- return this.do_save().then(function(result) {
+ return this.save().then(function(result) {
+ self.trigger("save");
self.to_view_mode();
});
},
@@ -784,7 +786,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var def = $.Deferred();
$.when(this.has_been_loaded).then(function() {
self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) {
- return self.record_created({ result : new_id });
+ return self.record_created(new_id);
}).then(function() {
return self.to_edit_mode();
}).then(function() {
@@ -799,7 +801,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
$.when(this.has_been_loaded).then(function() {
if (self.datarecord.id && confirm(_t("Do you really want to delete this record?"))) {
self.dataset.unlink([self.datarecord.id]).then(function() {
- self.on_pager_action('next');
+ self.execute_pager_action('next');
def.resolve();
});
} else {
@@ -824,11 +826,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
* record or saving an existing one depending on whether the record
* already has an id property.
*
- * @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new
+ * @param {Boolean} [prepend_on_create=false] if ``save`` creates a new
* record, should that record be inserted at the start of the dataset (by
* default, records are added at the end)
*/
- do_save: function(prepend_on_create) {
+ save: function(prepend_on_create) {
var self = this;
return this.mutating_mutex.exec(function() { return self.is_initialized.pipe(function() {
try {
@@ -956,7 +958,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var self = this;
return this.reload_mutex.exec(function() {
if (self.dataset.index == null) {
- self.do_prev_view();
+ self.trigger("previous_view");
return $.Deferred().reject().promise();
}
if (self.dataset.index == null || self.dataset.index < 0) {
@@ -1000,7 +1002,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
},
recursive_save: function() {
var self = this;
- return $.when(this.do_save()).pipe(function(res) {
+ return $.when(this.save()).pipe(function(res) {
if (self.dataset.parent_view)
return self.dataset.parent_view.recursive_save();
});
@@ -1031,7 +1033,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
return true;
},
sidebar_context: function () {
- return this.do_save().pipe(_.bind(function() {return this.get_fields_values();}, this));
+ return this.save().pipe(_.bind(function() {return this.get_fields_values();}, this));
},
open_defaults_dialog: function () {
var self = this;
@@ -1096,7 +1098,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
field_to_set,
self.fields[field_to_set].get_value(),
all_users,
- false,
+ true,
condition || false
]).then(function () { d.close(); });
}}
@@ -1660,6 +1662,8 @@ instance.web.form.FormDialog = instance.web.Dialog.extend({
});
instance.web.form.compute_domain = function(expr, fields) {
+ if (! (expr instanceof Array))
+ return !! expr;
var stack = [];
for (var i = expr.length - 1; i >= 0; i--) {
var ex = expr[i];
@@ -2087,11 +2091,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
this.field = this.field_manager.get_field_desc(this.name);
this.widget = this.node.attrs.widget;
this.string = this.node.attrs.string || this.field.string || this.name;
- try {
- this.options = JSON.parse(this.node.attrs.options || '{}');
- } catch (e) {
- throw new Error(_.str.sprintf(_t("Widget options for field '%s' are not valid JSON."), this.name));
- }
+ this.options = instance.web.py_eval(this.node.attrs.options || '{}');
this.set({'value': false});
this.on("change:value", this, function() {
@@ -2379,7 +2379,10 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({
var self = this;
this.$input = this.$el.find('input.oe_datepicker_master');
this.$input_picker = this.$el.find('input.oe_datepicker_container');
- this.$input.change(this.on_change);
+ this.$input.change(function(){
+ self.change_datetime();
+ });
+
this.picker({
onClose: this.on_picker_select,
onSelect: this.on_picker_select,
@@ -2447,9 +2450,10 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({
format_client: function(v) {
return instance.web.format_value(v, {"widget": this.type_of_date});
},
- on_change: function() {
+ change_datetime: function() {
if (this.is_valid_()) {
this.set_value_from_ui_();
+ this.trigger("datetime_changed");
}
}
});
@@ -2473,7 +2477,7 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(instanc
initialize_content: function() {
if (!this.get("effective_readonly")) {
this.datewidget = this.build_widget();
- this.datewidget.on_change.add_last(_.bind(function() {
+ this.datewidget.on('datetime_changed', this, _.bind(function() {
this.set({'value': this.datewidget.get_value()});
}, this));
this.datewidget.appendTo(this.$el);
@@ -2877,7 +2881,7 @@ instance.web.form.CompletionFieldMixin = {
self.build_domain(),
new instance.web.CompoundContext(self.build_context(), context || {})
);
- pop.on_select_elements.add(function(element_ids) {
+ pop.on("select_elements",self,function(element_ids) {
self.add_id(element_ids[0]);
self.focus();
});
@@ -3372,7 +3376,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
var def = $.Deferred().then(function() {
self.initial_is_loaded.resolve();
});
- this.viewmanager.on_controller_inited.add_last(function(view_type, controller) {
+ this.viewmanager.on("controller_inited", self, function(view_type, controller) {
controller.o2m = self;
if (view_type == "list") {
if (self.get("effective_readonly")) {
@@ -3387,9 +3391,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
controller.on("load_record", self, function(){
once.resolve();
});
- controller.on_pager_action.add_first(function() {
- self.save_any_view();
- });
+ controller.on('pager_action_executed',self,self.save_any_view);
} else if (view_type == "graph") {
self.reload_current_view()
}
@@ -3524,7 +3526,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
if (!view.is_initialized.isResolved()) {
return false;
}
- var res = $.when(view.do_save());
+ var res = $.when(view.save());
if (!res.isResolved() && !res.isRejected()) {
console.warn("Asynchronous get_value() is not supported in form view.");
}
@@ -3598,7 +3600,7 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({
form_view_options: {'not_interactible_on_create':true},
readonly: self.o2m.get("effective_readonly")
});
- pop.on_select_elements.add_last(function() {
+ pop.on("select_elements", self, function() {
self.o2m.reload_current_view();
});
},
@@ -3684,7 +3686,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
self.o2m.build_domain(),
self.o2m.build_context()
);
- pop.on_select_elements.add_last(function() {
+ pop.on("select_elements", self, function() {
self.o2m.reload_current_view();
});
}
@@ -3720,7 +3722,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
var self = this;
this.ensure_saved().pipe(function () {
if (parent_form)
- return parent_form.do_save();
+ return parent_form.save();
else
return $.when();
}).then(function () {
@@ -3859,7 +3861,7 @@ instance.web.form.One2ManyFormView = instance.web.FormView.extend({
this._super(data);
var self = this;
this.$buttons.find('button.oe_form_button_create').click(function() {
- self.do_save().then(self.on_button_new);
+ self.save().then(self.on_button_new);
});
},
do_notify_change: function() {
@@ -4121,7 +4123,7 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in
this.m2m_field.build_context()
);
var self = this;
- pop.on_select_elements.add(function(element_ids) {
+ pop.on("select_elements", self, function(element_ids) {
_.each(element_ids, function(one_id) {
if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) {
self.dataset.set_ids([].concat(self.dataset.ids, [one_id]));
@@ -4236,7 +4238,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
new instance.web.CompoundDomain(this.build_domain(), ["!", ["id", "in", this.dataset.ids]]),
this.build_context()
);
- pop.on_select_elements.add(function(element_ids) {
+ pop.on("select_elements", self, function(element_ids) {
_.each(element_ids, function(one_id) {
if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) {
self.dataset.set_ids([].concat(self.dataset.ids, [one_id]));
@@ -4435,7 +4437,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({
}));
var $snbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save-new");
$snbutton.click(function() {
- $.when(self.view_form.do_save()).then(function() {
+ $.when(self.view_form.save()).then(function() {
self.view_form.reload_mutex.exec(function() {
self.view_form.on_button_new();
});
@@ -4443,7 +4445,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({
});
var $sbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save");
$sbutton.click(function() {
- $.when(self.view_form.do_save()).then(function() {
+ $.when(self.view_form.save()).then(function() {
self.view_form.reload_mutex.exec(function() {
self.check_exit();
});
@@ -4456,11 +4458,12 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({
self.view_form.do_show();
});
},
- on_select_elements: function(element_ids) {
+ elements_selected: function(element_ids) {
+ this.trigger("select_elements",element_ids);
},
check_exit: function(no_destroy) {
if (this.created_elements.length > 0) {
- this.on_select_elements(this.created_elements);
+ this.elements_selected(this.created_elements);
this.created_elements = [];
}
this.destroy();
@@ -4571,7 +4574,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
});
var $sbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-select");
$sbutton.click(function() {
- self.on_select_elements(self.selected_ids);
+ self.elements_selected(self.selected_ids);
self.destroy();
});
});
@@ -4613,7 +4616,7 @@ instance.web.form.SelectCreateListView = instance.web.ListView.extend({
this.popup.new_object();
},
select_record: function(index) {
- this.popup.on_select_elements([this.dataset.ids[index]]);
+ this.popup.elements_selected([this.dataset.ids[index]]);
this.popup.destroy();
},
do_select: function(ids, records) {
@@ -4641,6 +4644,7 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan
destroy_content: function() {
if (this.fm) {
this.fm.destroy();
+ this.fm = undefined;
}
},
initialize_content: function() {
@@ -4662,9 +4666,7 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan
modifiers: JSON.stringify({readonly: this.get('effective_readonly')}),
}});
this.selection.on("change:value", this, this.on_selection_changed);
- this.selection.setElement(this.$(".oe_form_view_reference_selection"));
- this.selection.renderElement();
- this.selection.start();
+ this.selection.appendTo(this.$(".oe_form_view_reference_selection"));
this.selection
.on('focused', null, function () {self.trigger('focused')})
.on('blurred', null, function () {self.trigger('blurred')});
@@ -4674,9 +4676,7 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan
modifiers: JSON.stringify({readonly: this.get('effective_readonly')}),
}});
this.m2o.on("change:value", this, this.data_changed);
- this.m2o.setElement(this.$(".oe_form_view_reference_m2o"));
- this.m2o.renderElement();
- this.m2o.start();
+ this.m2o.appendTo(this.$(".oe_form_view_reference_m2o"));
this.m2o
.on('focused', null, function () {self.trigger('focused')})
.on('blurred', null, function () {self.trigger('blurred')});
diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js
index fe0f525fe3f..4bf61895a09 100644
--- a/addons/web/static/src/js/view_list_editable.js
+++ b/addons/web/static/src/js/view_list_editable.js
@@ -724,7 +724,7 @@ openerp.web.list_editable = function (instance) {
save: function () {
var self = this;
return this.form
- .do_save(this.delegate.prepends_on_create())
+ .save(this.delegate.prepends_on_create())
.pipe(function (result) {
var created = result.created && !self.record.id;
if (created) {
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index f985e5f6dc8..cb4f440110d 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -164,6 +164,10 @@ instance.web.ActionManager = instance.web.Widget.extend({
state = state || {};
if (this.getParent() && this.getParent().do_push_state) {
if (this.inner_action) {
+ if (this.inner_action._push_me === false) {
+ // this action has been explicitly marked as not pushable
+ return;
+ }
state['title'] = this.inner_action.name;
if(this.inner_action.type == 'ir.actions.act_window') {
state['model'] = this.inner_action.res_model;
@@ -172,7 +176,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
state['action'] = this.inner_action.id;
} else if (this.inner_action.type == 'ir.actions.client') {
state['action'] = this.inner_action.tag;
- //state = _.extend(this.inner_action.params || {}, state);
+ state = _.extend(this.inner_action.params || {}, state);
}
}
if(!this.dialog) {
@@ -525,19 +529,19 @@ instance.web.ViewManager = instance.web.Widget.extend({
controller.set_embedded_view(view.embedded_view);
}
controller.on('switch_mode', self, this.switch_mode);
-
- controller.do_prev_view.add_last(this.on_prev_view);
+ controller.on('previous_view', self, this.prev_view);
+
var container = this.$el.find(".oe_view_manager_view_" + view_type);
var view_promise = controller.appendTo(container);
this.views[view_type].controller = controller;
this.views[view_type].deferred.resolve(view_type);
return $.when(view_promise).then(function() {
- self.on_controller_inited(view_type, controller);
if (self.searchview
&& self.flags.auto_search
&& view.controller.searchable !== false) {
self.searchview.ready.then(self.searchview.do_search);
}
+ self.trigger("controller_inited",view_type,controller);
});
},
set_title: function(title) {
@@ -602,7 +606,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
* @param {String} [options.default=null] view to switch to if no previous view
* @returns {$.Deferred} switching end signal
*/
- on_prev_view: function (options) {
+ prev_view: function (options) {
options = options || {};
var current_view = this.views_history.pop();
var previous_view = this.views_history[this.views_history.length - 1] || options['default'];
@@ -653,14 +657,6 @@ instance.web.ViewManager = instance.web.Widget.extend({
});
},
/**
- * Event launched when a controller has been inited.
- *
- * @param {String} view_type type of view
- * @param {String} view the inited controller
- */
- on_controller_inited: function(view_type, view) {
- },
- /**
* Called when one of the view want to execute an action
*/
on_action: function(action) {
@@ -1266,8 +1262,7 @@ instance.web.View = instance.web.Widget.extend({
* @param {Boolean} [options.created=false] resource was created
* @param {String} [options.default=null] view to switch to if no previous view
*/
- do_prev_view: function (options) {
- },
+
do_search: function(view) {
},
on_sidebar_export: function() {