[imp] added slow create
authorniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 14 May 2012 15:51:44 +0000 (17:51 +0200)
committerniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 14 May 2012 15:51:44 +0000 (17:51 +0200)
bzr revid: nicolas.vanhoren@openerp.com-20120514155144-4lb9la1o0qv5k18o

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

index 891a68f..9940c30 100644 (file)
@@ -680,15 +680,33 @@ instance.web_kanban.QuickCreate = instance.web.Widget.extend({
      */
     quick_add: function () {
         var self = this;
-        // FIXME: what if name_create fails?
+        self.$input.val("");
         this._dataset.call(
             'name_create', [self.$input.val(), new instance.web.CompoundContext(
                     this._dataset.get_context(), this._context)])
-            .then(function(record) {
-                self.$input.val("");
+            .pipe(function(record) {
                 self.trigger('added', record);
+            }, function() {
+                return self.slow_create();
             });
     },
+    slow_create: function() {
+        var self = this;
+        var pop = new instance.web.form.SelectCreatePopup(this);
+        pop.select_element(
+            self.field.relation,
+            {
+                title: _t("Create: ") + (this.string || this.name),
+                initial_view: "form",
+                disable_multiple_selection: true
+            },
+            undefined,
+            new instance.web.CompoundContext(self.build_context(), {"default_name": self.$input.val("")})
+        );
+        pop.on_select_elements.add(function(element_ids) {
+            self.trigger('added', element_ids);
+        });
+    }
 });
 };
 
index 7db4345..29bb810 100644 (file)
@@ -69,7 +69,7 @@
     </table>
 </t>
 <div t-name="KanbanView.quick_create" class="oe_kanban_quick_create">
-    <input t-att-placeholder="_t('Type name')"/>
+    <input t-att-placeholder="_t('Type name to create')"/>
     <t t-if="widget._buttons">
         <button class="oe-kanban-quick_create_add">Add</button>
         <button class="oe-kanban-quick_create_close">Close</button>