start: function () {
this._super.apply(this, arguments);
this.bind_events();
+ return $.when();
},
/* instantiate the compose message object and insert this on the DOM.
/**
* Returns the current active view if any.
*/
- if (this.viewmanager && this.viewmanager.views && 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
- };
- }
+ return (this.viewmanager && this.viewmanager.active_view);
},
set_value: function(value_) {
value_ = value_ || [];
save_any_view: function() {
var view = this.get_active_view();
if (view) {
- if (this.viewmanager.active_view === "form") {
+ if (this.viewmanager.active_view.type === "form") {
if (view.controller.is_initialized.state() !== 'resolved') {
return $.when(false);
}
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());
}
}
if (!view){
return true;
}
- switch (this.viewmanager.active_view) {
+ switch (this.viewmanager.active_view.type) {
case 'form':
return _(view.controller.fields).chain()
.invoke('is_valid')
template: 'One2Many.viewmanager',
init: function(parent, dataset, views, flags) {
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',
form: 'instance.web.form.One2ManyFormView',
kanban: 'instance.web.form.One2ManyKanbanView',
this.range_start = null;
this.range_stop = null;
this.selected_filters = [];
+
+ this.shown = $.Deferred();
},
set_default_options: function(options) {
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)
.call("check_access_rights", ["write", false])
.then(function (write_right) {
.call("check_access_rights", ["create", false])
.then(function (create_right) {
self.create_right = create_right;
- self.init_calendar().then(function() {
- $(window).trigger('resize');
- self.trigger('calendar_view_loaded', fv);
- self.ready.resolve();
- });
+ self.ready.resolve();
+ self.trigger('calendar_view_loaded', fv);
});
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 () {
//Documentation here : http://arshaw.com/fullcalendar/docs/
var self = this;
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;
if (! self.all_filters) {
self.all_filters = {}
return false;
},
- do_show: function() {
+ do_show: function() {
if (this.$buttons) {
this.$buttons.show();
}
this.do_push_state({});
+ this.shown.resolve();
return this._super();
},
do_hide: function () {
get_domain: function () {},
get_groupby: function () {},
};
+
+ this.view_loaded = $.Deferred();
},
view_loading: function (fields_view_get) {
if (self.widget_config.measures.length === 0) {
self.widget_config.measures.push('__count');
}
+ this.view_loaded.resolve();
},
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) {
this.ignore_do_search = false;
return;
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);
- return self.alive($.when(grouping)).done(function(groups) {
+ return self.alive($.when(grouping)).then(function(groups) {
self.remove_no_result();
if (groups) {
- self.do_process_groups(groups);
+ return self.do_process_groups(groups);
} else {
- self.do_process_dataset();
+ return self.do_process_dataset();
}
});
});
var self = this;
this.$el.find('table:first').show();
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.dataset.ids = [];
if (!groups.length) {
self.no_result();
- return false;
+ return $.when();
}
self.nb_records = 0;
var remaining = groups.length - 1,
var self = this;
this.$el.find('table:first').show();
this.$el.removeClass('oe_kanban_grouped').addClass('oe_kanban_ungrouped');
+ var def = $.Deferred();
this.add_group_mutex.exec(function() {
- var def = $.Deferred();
self.do_clear_groups();
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);
}).done(null, function() {
def.reject();
});
- return def;
});
+ return def;
},
do_reload: function() {
this.do_search(this.search_domain, this.search_context, this.search_group_by);
<div t-name="KanbanView.buttons" class="oe_kanban_buttons">
<t t-if="widget.options.action_buttons !== false">
<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')"/>
</button>
<span t-if="widget.is_action_enabled('group_create')" class="oe_alternative" style="display: none">
<span class="oe_fade">or</span>
<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>
</span>
</t>