[FIX] web_kanban: in non-grouped kanban, on switch to form, display first record
authorDenis Ledoux <dle@odoo.com>
Thu, 7 Aug 2014 16:04:13 +0000 (18:04 +0200)
committerDenis Ledoux <dle@odoo.com>
Thu, 7 Aug 2014 16:04:13 +0000 (18:04 +0200)
in view_form.js, in do_show method, if the dataset index is not set, the on_button_new method is triggered, opening a new record
In regular kanbans (non-grouped kanban), the dataset index wasn't set, and, therefore, when switching to the view mode, it opened a form for a new record instead of opening the first record of the list, like this is the case for the view list and the grouped kanban

addons/web_kanban/static/src/js/kanban.js

index de263d3..b7cc68f 100644 (file)
@@ -288,6 +288,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
             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);
+                if (!_.isEmpty(self.dataset.ids) && (self.dataset.index === null || self.dataset.index >= self.dataset.ids.length)) {
+                    self.dataset.index = 0;
+                }
                 self.do_add_groups([kgroup]).done(function() {
                     if (_.isEmpty(records)) {
                         self.no_result();