[ADD] Add sticky option to do_warn() and do_notify()
authorFabien Meghazi <fme@openerp.com>
Mon, 13 Feb 2012 12:38:05 +0000 (13:38 +0100)
committerFabien Meghazi <fme@openerp.com>
Mon, 13 Feb 2012 12:38:05 +0000 (13:38 +0100)
[IMP] Form view uses a notification when a record is not found in the database

bzr revid: fme@openerp.com-20120213123805-4dqg4oioous25nuo

addons/web/static/src/js/chrome.js
addons/web/static/src/js/view_form.js

index 18020d9..0a19f2c 100644 (file)
@@ -20,17 +20,27 @@ openerp.web.Notification =  openerp.web.OldWidget.extend(/** @lends openerp.web.
             expires: 2500
         });
     },
-    notify: function(title, text) {
+    notify: function(title, text, sticky) {
+        sticky = !!sticky;
+        var opts = {};
+        if (sticky) {
+            opts.expires = false;
+        }
         this.$element.notify('create', {
             title: title,
             text: text
-        });
+        }, opts);
     },
-    warn: function(title, text) {
+    warn: function(title, text, sticky) {
+        sticky = !!sticky;
+        var opts = {};
+        if (sticky) {
+            opts.expires = false;
+        }
         this.$element.notify('create', 'oe_notification_alert', {
             title: title,
             text: text
-        });
+        }, opts);
     }
 
 });
index 3f9c3e0..c1eea01 100644 (file)
@@ -173,7 +173,8 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
     on_record_loaded: function(record) {
         var self = this, set_values = [];
         if (!record) {
-            throw new Error("Form: No record received");
+            this.do_warn("Form", "The record could not be found in the database.", true);
+            return $.Deferred().reject();
         }
         this.datarecord = record;