Added customization in kanban view to better fit o2m
authorniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 4 Jun 2012 09:31:03 +0000 (11:31 +0200)
committerniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 4 Jun 2012 09:31:03 +0000 (11:31 +0200)
bzr revid: nicolas.vanhoren@openerp.com-20120604093103-lydwjek920m3zxoe

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

index 809c707..0889f7d 100644 (file)
@@ -2744,9 +2744,12 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
                 }
                 view.options.not_interactible_on_create = true;
             } else if (view.view_type === "kanban") {
+                view.options.confirm_on_delete = false;
                 if (self.get("effective_readonly")) {
                     view.options.action_buttons = false;
                     view.options.quick_creatable = false;
+                    view.options.creatable = false;
+                    view.options.read_only_mode = true;
                 }
             }
             views.push(view);
index 13fd954..96487fa 100644 (file)
@@ -14,7 +14,13 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
     number_of_color_schemes: 10,
     init: function (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_keys = [];
         this.group_by = null;
@@ -550,7 +556,8 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
     render: function() {
         this.qweb_context = {
             record: this.record,
-            widget: this
+            widget: this,
+            read_only_mode: this.view.options.read_only_mode,
         };
         for (var p in this) {
             if (_.str.startsWith(p, 'kanban_')) {
@@ -653,12 +660,18 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
     },
     do_action_delete: function($action) {
         var self = this;
-        if (confirm(_t("Are you sure you want to delete this record ?"))) {
-            return $.when(this.view.dataset.unlink([this.id])).then(function() {
+        function do_it() {
+            return $.when(self.view.dataset.unlink([self.id])).then(function() {
                 self.group.remove_record(self.id);
                 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) {
         var self = this;