[MERGE]Merge with trunk upto revision no 750.

bzr revid: kch@tinyerp.com-20110809062529-w88bfh3nstwtnf3g
This commit is contained in:
Kunal Chavda (OpenERP)
2011-08-09 11:55:29 +05:30
6 changed files with 42 additions and 38 deletions
+10 -10
View File
@@ -305,10 +305,10 @@ openerp.base.Notification = openerp.base.Widget.extend({
openerp.base.Dialog = openerp.base.OldWidget.extend({
dialog_title: "",
identifier_prefix: 'dialog',
init: function (parent, options) {
init: function (parent, dialog_options) {
var self = this;
this._super(parent);
this.options = {
this.dialog_options = {
modal: true,
width: 'auto',
min_width: 0,
@@ -324,11 +324,11 @@ openerp.base.Dialog = openerp.base.OldWidget.extend({
};
for (var f in this) {
if (f.substr(0, 10) == 'on_button_') {
this.options.buttons[f.substr(10)] = this[f];
this.dialog_options.buttons[f.substr(10)] = this[f];
}
}
if (options) {
this.set_options(options);
if (dialog_options) {
this.set_options(dialog_options);
}
},
set_options: function(options) {
@@ -351,7 +351,7 @@ openerp.base.Dialog = openerp.base.OldWidget.extend({
if (!options.title && this.dialog_title) {
options.title = this.dialog_title;
}
_.extend(this.options, options);
_.extend(this.dialog_options, options);
},
get_width: function(val) {
return this.get_size(val.toString(), $(window.top).width());
@@ -369,19 +369,19 @@ openerp.base.Dialog = openerp.base.OldWidget.extend({
}
},
start: function (auto_open) {
this.$dialog = $('<div id="' + this.element_id + '"></div>').dialog(this.options);
this.$dialog = $('<div id="' + this.element_id + '"></div>').dialog(this.dialog_options);
if (auto_open !== false) {
this.open();
}
this._super();
},
open: function(options) {
open: function(dialog_options) {
// TODO fme: bind window on resize
if (this.template) {
this.$element.html(this.render());
}
this.set_options(options);
this.$dialog.dialog(this.options).dialog('open');
this.set_options(dialog_options);
this.$dialog.dialog(this.dialog_options).dialog('open');
},
close: function() {
// Closes the dialog but leave it in a state where it could be opened again.
+8 -7
View File
@@ -19,7 +19,7 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormVi
*/
init: function(parent, element_id, dataset, view_id, options) {
this._super(parent, element_id);
this.set_default_options();
this.set_default_options(options);
this.dataset = dataset;
this.model = dataset.model;
this.view_id = view_id;
@@ -36,7 +36,6 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormVi
this.registry = openerp.base.form.widgets;
this.has_been_loaded = $.Deferred();
this.$form_header = null;
this.options = options || {};
_.defaults(this.options, {"always_show_new_button": true});
},
start: function() {
@@ -156,7 +155,7 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormVi
if (this.sidebar) {
this.sidebar.attachments.do_update();
}
if (this.default_focus_field) {
if (this.default_focus_field && !this.embedded_view) {
this.default_focus_field.focus();
}
},
@@ -1634,14 +1633,16 @@ openerp.base.form.FieldOne2Many = openerp.base.form.Field.extend({
modes = !!modes ? modes.split(",") : ["tree", "form"];
var views = [];
_.each(modes, function(mode) {
var view = {view_id: false, view_type: mode == "tree" ? "list" : mode};
var view = {
view_id: false,
view_type: mode == "tree" ? "list" : mode,
options: { sidebar : false }
};
if (self.field.views && self.field.views[mode]) {
view.embedded_view = self.field.views[mode];
}
if(view.view_type === "list") {
view.options = {
'selectable': self.multi_selection
};
view.options.selectable = self.multi_selection;
}
views.push(view);
});
+5 -12
View File
@@ -85,8 +85,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
* the default behaviors and possible options for the list view.
*
* @constructs
* @param view_manager
* @param session An OpenERP session object
* @param parent parent object
* @param element_id the id of the DOM elements this view should link itself to
* @param {openerp.base.DataSet} dataset the dataset the view should work with
* @param {String} view_id the listview's identifier, if any
@@ -102,16 +101,13 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
*/
init: function(parent, element_id, dataset, view_id, options) {
this._super(parent, element_id);
this.set_default_options();
this.view_manager = parent || new openerp.base.NullViewManager();
this.set_default_options(_.extend({}, this.defaults, options || {}));
this.dataset = dataset;
this.model = dataset.model;
this.view_id = view_id;
this.columns = [];
this.options = _.extend({}, this.defaults, options || {});
this.set_groups(new openerp.base.ListView.Groups(this));
if (this.dataset instanceof openerp.base.DataSetStatic) {
@@ -123,7 +119,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
/**
* Retrieves the view's number of records per page (|| section)
*
* options > defaults > view_manager.action.limit > indefinite
* options > defaults > indefinite
*
* @returns {Number|null}
*/
@@ -131,7 +127,6 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
if (this._limit === undefined) {
this._limit = (this.options.limit
|| this.defaults.limit
|| (this.view_manager.action || {}).limit
|| null);
}
return this._limit;
@@ -267,7 +262,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
})
.val(self._limit || 'NaN');
});
if (this.options.sidebar && this.options.sidebar_id) {
if (!this.sidebar && this.options.sidebar && this.options.sidebar_id) {
this.sidebar = new openerp.base.Sidebar(this, this.options.sidebar_id);
this.sidebar.start();
this.sidebar.add_toolbar(data.fields_view.toolbar);
@@ -389,9 +384,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
view = view || 'form';
this.dataset.index = index;
_.delay(_.bind(function () {
if(this.view_manager) {
this.view_manager.on_mode_switch(view);
}
this.do_switch_view(view);
}, this));
},
do_show: function () {
+13 -3
View File
@@ -130,13 +130,17 @@ openerp.base.ViewManager = openerp.base.Widget.extend({
this.$element.find('.oe_vm_switch button').click(function() {
self.on_mode_switch($(this).data('view-type'));
});
var views_ids = {};
_.each(this.views_src, function(view) {
self.views[view.view_type] = $.extend({}, view, {
controller : null,
options : _.extend({
sidebar_id : self.element_id + '_sidebar_' + view.view_type
}, self.flags)
sidebar_id : self.element_id + '_sidebar_' + view.view_type,
action : self.action,
action_views_ids : views_ids
}, self.flags, view.options || {})
});
views_ids[view.view_type] = view.view_id;
});
if (this.flags.views_switcher === false) {
this.$element.find('.oe_vm_switch').hide();
@@ -165,6 +169,7 @@ openerp.base.ViewManager = openerp.base.Widget.extend({
if (view.embedded_view) {
controller.set_embedded_view(view.embedded_view);
}
controller.do_switch_view.add_last(this.on_mode_switch);
if (view_type === 'list' && this.flags.search_view === false && this.action && this.action['auto_search']) {
// In case the search view is not instantiated: manually call ListView#search
var domains = !_(self.action.domain).isEmpty()
@@ -447,7 +452,9 @@ openerp.base.View = openerp.base.Widget.extend({
_.defaults(this.options, {
// All possible views options should be defaulted here
sidebar_id: null,
sidebar: true
sidebar: true,
action: null,
action_views_ids: {}
});
},
/**
@@ -510,6 +517,9 @@ openerp.base.View = openerp.base.Widget.extend({
*/
set_embedded_view: function(embedded_view) {
this.embedded_view = embedded_view;
this.options.sidebar = false;
},
do_switch_view: function(view) {
},
set_common_sidebar_sections: function(sidebar) {
sidebar.add_section('customize', "Customize", [
@@ -9,7 +9,7 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
// Dhtmlx scheduler ?
init: function(parent, element_id, dataset, view_id, options) {
this._super(parent, element_id);
this.set_default_options();
this.set_default_options(options);
this.dataset = dataset;
this.model = dataset.model;
this.view_id = view_id;
@@ -276,10 +276,10 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
do_delete_event: function(event_id, event_obj) {
// dhtmlx sends this event even when it does not exist in openerp.
// Eg: use cancel in dhtmlx new event dialog
if (_.indexOf(this.dataset.ids, event_id) > -1) {
this.dataset.unlink(parseInt(event_id, 10, function() {
if (_.indexOf(this.dataset.ids, parseInt(event_id, 10)) > -1) {
this.dataset.unlink(parseInt(event_id, 10), function() {
self.refresh_minical();
}));
});
}
},
get_event_data: function(event_obj) {
@@ -244,8 +244,8 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
return QWeb.render(this.template, this);
},
do_reload: function() {
this.view.view_manager.stop();
this.view.view_manager.start();
this.view.widget_parent.stop();
this.view.widget_parent.start();
}
});
openerp.base.form.DashBoardLegacy = openerp.base.form.DashBoard.extend({