[FIX] fixes many issues with the various views
the views don't always return a proper promise, or were somewhat fragile and broke with the changes in the view manager.
This commit is contained in:
@@ -1278,6 +1278,7 @@ openerp.mail = function (session) {
|
|||||||
start: function () {
|
start: function () {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.bind_events();
|
this.bind_events();
|
||||||
|
return $.when();
|
||||||
},
|
},
|
||||||
|
|
||||||
/* instantiate the compose message object and insert this on the DOM.
|
/* instantiate the compose message object and insert this on the DOM.
|
||||||
|
|||||||
@@ -4143,14 +4143,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
|
|||||||
/**
|
/**
|
||||||
* Returns the current active view if any.
|
* Returns the current active view if any.
|
||||||
*/
|
*/
|
||||||
if (this.viewmanager && this.viewmanager.views && this.viewmanager.active_view &&
|
return (this.viewmanager && this.viewmanager.active_view);
|
||||||
this.viewmanager.views[this.viewmanager.active_view] &&
|
|
||||||
this.viewmanager.views[this.viewmanager.active_view].controller) {
|
|
||||||
return {
|
|
||||||
type: this.viewmanager.active_view,
|
|
||||||
controller: this.viewmanager.views[this.viewmanager.active_view].controller
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
set_value: function(value_) {
|
set_value: function(value_) {
|
||||||
value_ = value_ || [];
|
value_ = value_ || [];
|
||||||
@@ -4242,12 +4235,12 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
|
|||||||
save_any_view: function() {
|
save_any_view: function() {
|
||||||
var view = this.get_active_view();
|
var view = this.get_active_view();
|
||||||
if (view) {
|
if (view) {
|
||||||
if (this.viewmanager.active_view === "form") {
|
if (this.viewmanager.active_view.type === "form") {
|
||||||
if (view.controller.is_initialized.state() !== 'resolved') {
|
if (view.controller.is_initialized.state() !== 'resolved') {
|
||||||
return $.when(false);
|
return $.when(false);
|
||||||
}
|
}
|
||||||
return $.when(view.controller.save());
|
return $.when(view.controller.save());
|
||||||
} else if (this.viewmanager.active_view === "list") {
|
} else if (this.viewmanager.active_view.type === "list") {
|
||||||
return $.when(view.controller.ensure_saved());
|
return $.when(view.controller.ensure_saved());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4258,7 +4251,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
|
|||||||
if (!view){
|
if (!view){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
switch (this.viewmanager.active_view) {
|
switch (this.viewmanager.active_view.type) {
|
||||||
case 'form':
|
case 'form':
|
||||||
return _(view.controller.fields).chain()
|
return _(view.controller.fields).chain()
|
||||||
.invoke('is_valid')
|
.invoke('is_valid')
|
||||||
@@ -4275,7 +4268,7 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({
|
|||||||
template: 'One2Many.viewmanager',
|
template: 'One2Many.viewmanager',
|
||||||
init: function(parent, dataset, views, flags) {
|
init: function(parent, dataset, views, flags) {
|
||||||
this._super(parent, dataset, views, _.extend({}, flags, {$sidebar: false}));
|
this._super(parent, dataset, views, _.extend({}, flags, {$sidebar: false}));
|
||||||
this.registry = this.registry.extend({
|
this.registry = instance.web.views.extend({
|
||||||
list: 'instance.web.form.One2ManyListView',
|
list: 'instance.web.form.One2ManyListView',
|
||||||
form: 'instance.web.form.One2ManyFormView',
|
form: 'instance.web.form.One2ManyFormView',
|
||||||
kanban: 'instance.web.form.One2ManyKanbanView',
|
kanban: 'instance.web.form.One2ManyKanbanView',
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ openerp.web_calendar = function(instance) {
|
|||||||
this.range_start = null;
|
this.range_start = null;
|
||||||
this.range_stop = null;
|
this.range_stop = null;
|
||||||
this.selected_filters = [];
|
this.selected_filters = [];
|
||||||
|
|
||||||
|
this.shown = $.Deferred();
|
||||||
},
|
},
|
||||||
|
|
||||||
set_default_options: function(options) {
|
set_default_options: function(options) {
|
||||||
@@ -229,6 +231,7 @@ openerp.web_calendar = function(instance) {
|
|||||||
this.info_fields.push(fv.arch.children[fld].attrs.name);
|
this.info_fields.push(fv.arch.children[fld].attrs.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.shown.done(this._do_show_init.bind(this));
|
||||||
var edit_check = new instance.web.Model(this.dataset.model)
|
var edit_check = new instance.web.Model(this.dataset.model)
|
||||||
.call("check_access_rights", ["write", false])
|
.call("check_access_rights", ["write", false])
|
||||||
.then(function (write_right) {
|
.then(function (write_right) {
|
||||||
@@ -238,15 +241,18 @@ openerp.web_calendar = function(instance) {
|
|||||||
.call("check_access_rights", ["create", false])
|
.call("check_access_rights", ["create", false])
|
||||||
.then(function (create_right) {
|
.then(function (create_right) {
|
||||||
self.create_right = create_right;
|
self.create_right = create_right;
|
||||||
self.init_calendar().then(function() {
|
self.ready.resolve();
|
||||||
$(window).trigger('resize');
|
self.trigger('calendar_view_loaded', fv);
|
||||||
self.trigger('calendar_view_loaded', fv);
|
|
||||||
self.ready.resolve();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
return $.when(edit_check, init);
|
return $.when(edit_check, init);
|
||||||
},
|
},
|
||||||
|
_do_show_init: function () {
|
||||||
|
var self = this;
|
||||||
|
this.init_calendar().then(function() {
|
||||||
|
$(window).trigger('resize');
|
||||||
|
self.trigger('calendar_view_loaded', self.fields_view);
|
||||||
|
});
|
||||||
|
},
|
||||||
get_fc_init_options: function () {
|
get_fc_init_options: function () {
|
||||||
//Documentation here : http://arshaw.com/fullcalendar/docs/
|
//Documentation here : http://arshaw.com/fullcalendar/docs/
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -647,7 +653,13 @@ openerp.web_calendar = function(instance) {
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
do_search: function(domain, context, _group_by) {
|
do_search: function (domain, context, _group_by) {
|
||||||
|
var self = this;
|
||||||
|
this.shown.done(function () {
|
||||||
|
self._do_search(domain, context, _group_by);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
_do_search: function(domain, context, _group_by) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (! self.all_filters) {
|
if (! self.all_filters) {
|
||||||
self.all_filters = {}
|
self.all_filters = {}
|
||||||
@@ -859,6 +871,7 @@ openerp.web_calendar = function(instance) {
|
|||||||
this.$buttons.show();
|
this.$buttons.show();
|
||||||
}
|
}
|
||||||
this.do_push_state({});
|
this.do_push_state({});
|
||||||
|
this.shown.resolve();
|
||||||
return this._super();
|
return this._super();
|
||||||
},
|
},
|
||||||
do_hide: function () {
|
do_hide: function () {
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
|||||||
get_domain: function () {},
|
get_domain: function () {},
|
||||||
get_groupby: function () {},
|
get_groupby: function () {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.view_loaded = $.Deferred();
|
||||||
},
|
},
|
||||||
|
|
||||||
view_loading: function (fields_view_get) {
|
view_loading: function (fields_view_get) {
|
||||||
@@ -72,9 +74,17 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
|||||||
if (self.widget_config.measures.length === 0) {
|
if (self.widget_config.measures.length === 0) {
|
||||||
self.widget_config.measures.push('__count');
|
self.widget_config.measures.push('__count');
|
||||||
}
|
}
|
||||||
|
this.view_loaded.resolve();
|
||||||
},
|
},
|
||||||
|
|
||||||
do_search: function (domain, context, group_by) {
|
do_search: function (domain, context, group_by) {
|
||||||
|
var self = this;
|
||||||
|
this.view_loaded.done(function () {
|
||||||
|
self._do_search(domain, context, group_by);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
_do_search: function (domain, context, group_by) {
|
||||||
if (this.ignore_do_search) {
|
if (this.ignore_do_search) {
|
||||||
this.ignore_do_search = false;
|
this.ignore_do_search = false;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -252,12 +252,12 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
|||||||
self.fields_keys = _.unique(self.fields_keys.concat(grouping_fields));
|
self.fields_keys = _.unique(self.fields_keys.concat(grouping_fields));
|
||||||
}
|
}
|
||||||
var grouping = new instance.web.Model(self.dataset.model, context, domain).query(self.fields_keys).group_by(grouping_fields);
|
var grouping = new instance.web.Model(self.dataset.model, context, domain).query(self.fields_keys).group_by(grouping_fields);
|
||||||
return self.alive($.when(grouping)).done(function(groups) {
|
return self.alive($.when(grouping)).then(function(groups) {
|
||||||
self.remove_no_result();
|
self.remove_no_result();
|
||||||
if (groups) {
|
if (groups) {
|
||||||
self.do_process_groups(groups);
|
return self.do_process_groups(groups);
|
||||||
} else {
|
} else {
|
||||||
self.do_process_dataset();
|
return self.do_process_dataset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -266,12 +266,12 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
|||||||
var self = this;
|
var self = this;
|
||||||
this.$el.find('table:first').show();
|
this.$el.find('table:first').show();
|
||||||
this.$el.removeClass('oe_kanban_ungrouped').addClass('oe_kanban_grouped');
|
this.$el.removeClass('oe_kanban_ungrouped').addClass('oe_kanban_grouped');
|
||||||
this.add_group_mutex.exec(function() {
|
return this.add_group_mutex.exec(function() {
|
||||||
self.do_clear_groups();
|
self.do_clear_groups();
|
||||||
self.dataset.ids = [];
|
self.dataset.ids = [];
|
||||||
if (!groups.length) {
|
if (!groups.length) {
|
||||||
self.no_result();
|
self.no_result();
|
||||||
return false;
|
return $.when();
|
||||||
}
|
}
|
||||||
self.nb_records = 0;
|
self.nb_records = 0;
|
||||||
var remaining = groups.length - 1,
|
var remaining = groups.length - 1,
|
||||||
@@ -306,8 +306,8 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
|||||||
var self = this;
|
var self = this;
|
||||||
this.$el.find('table:first').show();
|
this.$el.find('table:first').show();
|
||||||
this.$el.removeClass('oe_kanban_grouped').addClass('oe_kanban_ungrouped');
|
this.$el.removeClass('oe_kanban_grouped').addClass('oe_kanban_ungrouped');
|
||||||
|
var def = $.Deferred();
|
||||||
this.add_group_mutex.exec(function() {
|
this.add_group_mutex.exec(function() {
|
||||||
var def = $.Deferred();
|
|
||||||
self.do_clear_groups();
|
self.do_clear_groups();
|
||||||
self.dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit }).done(function(records) {
|
self.dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit }).done(function(records) {
|
||||||
var kgroup = new instance.web_kanban.KanbanGroup(self, records, null, self.dataset);
|
var kgroup = new instance.web_kanban.KanbanGroup(self, records, null, self.dataset);
|
||||||
@@ -326,8 +326,8 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
|||||||
}).done(null, function() {
|
}).done(null, function() {
|
||||||
def.reject();
|
def.reject();
|
||||||
});
|
});
|
||||||
return def;
|
|
||||||
});
|
});
|
||||||
|
return def;
|
||||||
},
|
},
|
||||||
do_reload: function() {
|
do_reload: function() {
|
||||||
this.do_search(this.search_domain, this.search_context, this.search_group_by);
|
this.do_search(this.search_domain, this.search_context, this.search_group_by);
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
<div t-name="KanbanView.buttons" class="oe_kanban_buttons">
|
<div t-name="KanbanView.buttons" class="oe_kanban_buttons">
|
||||||
<t t-if="widget.options.action_buttons !== false">
|
<t t-if="widget.options.action_buttons !== false">
|
||||||
<t t-if="widget.is_action_enabled('create')">
|
<t t-if="widget.is_action_enabled('create')">
|
||||||
<button type="button" class="oe_kanban_button_new oe_highlight">
|
<button type="button" class="oe_kanban_button_new btn btn-primary">
|
||||||
<t t-esc="widget.options.create_text || _t('Create')"/>
|
<t t-esc="widget.options.create_text || _t('Create')"/>
|
||||||
</button>
|
</button>
|
||||||
<span t-if="widget.is_action_enabled('group_create')" class="oe_alternative" style="display: none">
|
<span t-if="widget.is_action_enabled('group_create')" class="oe_alternative" style="display: none">
|
||||||
<span class="oe_fade">or</span>
|
<span class="oe_fade">or</span>
|
||||||
<div class="oe_bounce_container">
|
<div class="oe_bounce_container">
|
||||||
<a href="#" class="oe_bold oe_kanban_add_column">Add a new column</a>
|
<a href="#" class="oe_kanban_add_column text-info">Add a new column</a>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
|
|||||||
Reference in New Issue
Block a user