[MERGE] Latest trunk.

bzr revid: vta@openerp.com-20121012114711-5msihfk40e42n6iz
This commit is contained in:
vta vta@openerp.com 2012-10-12 13:47:11 +02:00
commit 60cc377c33
4 changed files with 32 additions and 37 deletions

View File

@ -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;
@ -1039,7 +1041,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();

View File

@ -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();
},
@ -785,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() {
@ -800,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 {
@ -957,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) {
@ -1097,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(); });
}}
@ -1661,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];
@ -2376,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.datetime_changed();
});
this.picker({
onClose: this.on_picker_select,
onSelect: this.on_picker_select,
@ -2444,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() {
datetime_changed: function() {
if (this.is_valid_()) {
this.set_value_from_ui_();
this.trigger("datetime_changed");
}
}
});
@ -2470,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);
@ -3369,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")) {
@ -3384,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()
}
@ -4639,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() {
@ -4660,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')});
@ -4672,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')});

View File

@ -525,19 +525,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 +602,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'];
@ -652,14 +652,6 @@ instance.web.ViewManager = instance.web.Widget.extend({
controller.do_search(results.domain, results.context, groupby || []);
});
},
/**
* 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
*/
@ -1266,8 +1258,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() {

View File

@ -57,7 +57,7 @@ instance.web.DiagramView = instance.web.View.extend({
this.$el.find('div.oe_diagram_pager button[data-pager-action]').click(function() {
var action = $(this).data('pager-action');
self.on_pager_action(action);
self.execute_pager_action(action);
});
this.do_update_pager();
@ -347,7 +347,7 @@ instance.web.DiagramView = instance.web.View.extend({
});
},
on_pager_action: function(action) {
execute_pager_action: function(action) {
switch (action) {
case 'first':
this.dataset.index = 0;
@ -380,7 +380,7 @@ instance.web.DiagramView = instance.web.View.extend({
do_show: function() {
this.do_push_state({});
return $.when(this._super(), this.on_pager_action('reload'));
return $.when(this._super(), this.execute_pager_action('reload'));
}
});
};