Added customization in kanban view to better fit o2m

bzr revid: nicolas.vanhoren@openerp.com-20120604093103-lydwjek920m3zxoe
This commit is contained in:
niv-openerp 2012-06-04 11:31:03 +02:00
parent 6a528804f5
commit 72e17e620e
2 changed files with 21 additions and 5 deletions

View File

@ -2744,9 +2744,12 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
} }
view.options.not_interactible_on_create = true; view.options.not_interactible_on_create = true;
} else if (view.view_type === "kanban") { } else if (view.view_type === "kanban") {
view.options.confirm_on_delete = false;
if (self.get("effective_readonly")) { if (self.get("effective_readonly")) {
view.options.action_buttons = false; view.options.action_buttons = false;
view.options.quick_creatable = false; view.options.quick_creatable = false;
view.options.creatable = false;
view.options.read_only_mode = true;
} }
} }
views.push(view); views.push(view);

View File

@ -14,7 +14,13 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
number_of_color_schemes: 10, number_of_color_schemes: 10,
init: function (parent, dataset, view_id, options) { init: function (parent, dataset, view_id, options) {
this._super(parent, dataset, view_id, options); this._super(parent, dataset, view_id, options);
_.defaults(this.options, {"quick_creatable": true, "creatable": true, "create_text": undefined}); _.defaults(this.options, {
"quick_creatable": true,
"creatable": true,
"create_text": undefined,
"read_only_mode": false,
"confirm_on_delete": true,
});
this.fields_view = {}; this.fields_view = {};
this.fields_keys = []; this.fields_keys = [];
this.group_by = null; this.group_by = null;
@ -550,7 +556,8 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
render: function() { render: function() {
this.qweb_context = { this.qweb_context = {
record: this.record, record: this.record,
widget: this widget: this,
read_only_mode: this.view.options.read_only_mode,
}; };
for (var p in this) { for (var p in this) {
if (_.str.startsWith(p, 'kanban_')) { if (_.str.startsWith(p, 'kanban_')) {
@ -653,12 +660,18 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
}, },
do_action_delete: function($action) { do_action_delete: function($action) {
var self = this; var self = this;
if (confirm(_t("Are you sure you want to delete this record ?"))) { function do_it() {
return $.when(this.view.dataset.unlink([this.id])).then(function() { return $.when(self.view.dataset.unlink([self.id])).then(function() {
self.group.remove_record(self.id); self.group.remove_record(self.id);
self.destroy(); self.destroy();
}); });
} };
if (this.view.options.confirm_on_delete) {
if (confirm(_t("Are you sure you want to delete this record ?"))) {
return do_it();
}
} else
return do_it();
}, },
do_action_edit: function($action) { do_action_edit: function($action) {
var self = this; var self = this;