[MERGE] Merge With Trunk
authorYogesh (OpenERP) <ysa@tinyerp.com>
Fri, 22 Jul 2011 13:33:49 +0000 (19:03 +0530)
committerYogesh (OpenERP) <ysa@tinyerp.com>
Fri, 22 Jul 2011 13:33:49 +0000 (19:03 +0530)
bzr revid: ysa@tinyerp.com-20110722133349-izodauajpwgoxhgd

1  2 
addons/base/static/src/js/chrome.js
addons/base/static/src/js/views.js

@@@ -137,57 -137,109 +137,109 @@@ openerp.base.Registry = openerp.base.Cl
  });
  
  /**
-  * Generates an inherited class that replaces all the methods by null methods (methods
-  * that does nothing and always return undefined).
-  *
-  * @param {Class} claz
-  * @param {dict} add Additional functions to override.
-  * @return {Class}
+  * OpenERP session aware controller
+  * a controller takes an already existing dom element and manage it
   */
- openerp.base.generate_null_object_class = function(claz, add) {
-     var newer = {};
-     var copy_proto = function(prototype) {
-         for (var name in prototype) {
-             if(typeof prototype[name] == "function") {
-                 newer[name] = function() {};
-             }
-         }
-         if (prototype.prototype)
-             copy_proto(prototype.prototype);
-     };
-     copy_proto(claz.prototype);
-     newer.init = openerp.base.BasicController.prototype.init;
-     var tmpclass = claz.extend(newer);
-     return tmpclass.extend(add || {});
- };
- openerp.base.Notification =  openerp.base.BasicController.extend({
+ openerp.base.Controller = openerp.base.Controller.extend( /** @lends openerp.base.Controller# */{
      init: function(parent, element_id) {
          this._super(parent, element_id);
-         this.$element.notify({
-             speed: 500,
-             expires: 1500
-         });
+         if(this.controller_parent && this.controller_parent.session) {
+             this.session = this.controller_parent.session;
+         }
      },
-     notify: function(title, text) {
-         this.$element.notify('create', {
-             title: title,
-             text: text
-         });
+     /**
+      * Performs a JSON-RPC call
+      *
+      * @param {String} url endpoint url
+      * @param {Object} data RPC parameters
+      * @param {Function} success RPC call success callback
+      * @param {Function} error RPC call error callback
+      * @returns {jQuery.Deferred} deferred object for the RPC call
+      */
+     rpc: function(url, data, success, error) {
+         return this.session.rpc(url, data, success, error);
      },
-     warn: function(title, text) {
-         this.$element.notify('create', 'oe_notification_alert', {
-             title: title,
-             text: text
-         });
+     do_action: function(action, on_finished) {
+         return this.parent.do_action(action, on_finished);
+     }
+ });
+ /**
+  * OpenERP session aware widget
+  * A widget is a controller that doesnt take an element_id
+  * it render its own html render() that you should insert into the dom
+  * and bind it at start()
+  */
+ openerp.base.BaseWidget = openerp.base.Controller.extend({
+     /**
+      * The name of the QWeb template that will be used for rendering. Must be
+      * redefined in subclasses or the render() method can not be used.
 -     * 
++     *
+      * @type string
+      */
+     template: null,
+     /**
+      * The prefix used to generate an id automatically. Should be redefined in
+      * subclasses. If it is not defined, a default identifier will be used.
 -     * 
++     *
+      * @type string
+      */
+     identifier_prefix: 'generic-identifier',
+     /**
+      * Base class for widgets. Handle rendering (based on a QWeb template),
+      * identifier generation, parenting and destruction of the widget.
+      * Also initialize the identifier.
+      *
+      * @constructs
+      * @params {openerp.base.search.BaseWidget} parent The parent widget.
+      */
+     init: function (parent) {
+         this._super(parent);
+         this.make_id(this.identifier_prefix);
+     },
+     /**
+      * Sets and returns a globally unique identifier for the widget.
+      *
+      * If a prefix is appended, the identifier will be appended to it.
+      *
+      * @params sections prefix sections, empty/falsy sections will be removed
+      */
+     make_id: function () {
+         this.element_id = _.uniqueId(_.toArray(arguments).join('_'));
+         return this.element_id;
+     },
+     /**
+      * Render the widget. This.template must be defined.
+      * The content of the current object is passed as context to the template.
 -     * 
++     *
+      * @param {object} additional Additional context arguments to pass to the template.
+      */
+     render: function (additional) {
+         return QWeb.render(this.template, _.extend({}, this, additional != null ? additional : {}));
+     },
+     /**
+      * "Starts" the widgets. Called at the end of the rendering, this allows
+      * to get a jQuery object referring to the DOM ($element attribute).
+      */
+     start: function () {
+         this._super();
+         var tmp = document.getElementById(this.element_id);
+         this.$element = tmp ? $(tmp) : null;
+     },
+     /**
+      * "Stops" the widgets. Called when the view destroys itself, this
+      * lets the widgets clean up after themselves.
+      */
+     stop: function () {
+         if(this.$element != null) {
+             this.$element.remove();
+         }
      }
  });
  
- // Session should be a Class not Controller
- openerp.base.Session = openerp.base.BasicController.extend( /** @lends openerp.base.Session# */{
+ openerp.base.Session = openerp.base.Controller.extend( /** @lends openerp.base.Session# */{
      /**
       * @constructs
-      * @extends openerp.base.BasicController
       * @param element_id to use for exception reporting
       * @param server
       * @param port
      }
  });
  
- /**
-  * OpenERP session aware controller
-  * a controller takes an already existing dom element and manage it
-  */
- openerp.base.Controller = openerp.base.BasicController.extend( /** @lends openerp.base.Controller# */{
-     /**
-      * @constructs
-      * @extends openerp.base.BasicController
-      */
+ openerp.base.Notification =  openerp.base.Controller.extend({
      init: function(parent, element_id) {
          this._super(parent, element_id);
-         if(this.parent && this.parent.session) {
-             this.session = this.parent.session;
-         }
-     },
-     /**
-      * Performs a JSON-RPC call
-      *
-      * @param {String} url endpoint url
-      * @param {Object} data RPC parameters
-      * @param {Function} success RPC call success callback
-      * @param {Function} error RPC call error callback
-      * @returns {jQuery.Deferred} deferred object for the RPC call
-      */
-     rpc: function(url, data, success, error) {
-         return this.session.rpc(url, data, success, error);
-     },
-     do_action: function(action, on_finished) {
-         return this.parent.do_action(action, on_finished);
-     }
- });
- /**
-  * OpenERP session aware widget
-  * A widget is a controller that doesnt take an element_id
-  * it render its own html render() that you should insert into the dom
-  * and bind it a start()
-  */
- openerp.base.BaseWidget = openerp.base.Controller.extend({
-     /**
-      * The name of the QWeb template that will be used for rendering. Must be
-      * redefined in subclasses or the render() method can not be used.
-      *
-      * @type string
-      */
-     template: null,
-     /**
-      * The prefix used to generate an id automatically. Should be redefined in
-      * subclasses. If it is not defined, a default identifier will be used.
-      *
-      * @type string
-      */
-     identifier_prefix: 'generic-identifier',
-     /**
-      * Base class for widgets. Handle rendering (based on a QWeb template),
-      * identifier generation, parenting and destruction of the widget.
-      * Also initialize the identifier.
-      *
-      * @constructs
-      * @params {openerp.base.search.BaseWidget} parent The parent widget.
-      */
-     init: function (parent) {
-         this._super(parent);
-         this.make_id(this.identifier_prefix);
-     },
-     /**
-      * Sets and returns a globally unique identifier for the widget.
-      *
-      * If a prefix is appended, the identifier will be appended to it.
-      *
-      * @params sections prefix sections, empty/falsy sections will be removed
-      */
-     make_id: function () {
-         this.element_id = _.uniqueId(_.toArray(arguments).join('_'));
-         return this.element_id;
-     },
-     /**
-      * "Starts" the widgets. Called at the end of the rendering, this allows
-      * to get a jQuery object referring to the DOM ($element attribute).
-      */
-     start: function () {
-         this._super();
-         var tmp = document.getElementById(this.element_id);
-         this.$element = tmp ? $(tmp) : null;
+         this.$element.notify({
+             speed: 500,
+             expires: 1500
+         });
      },
-     /**
-      * "Stops" the widgets. Called when the view destroys itself, this
-      * lets the widgets clean up after themselves.
-      */
-     stop: function () {
-         if(this.$element != null) {
-             this.$element.remove();
-         }
+     notify: function(title, text) {
+         this.$element.notify('create', {
+             title: title,
+             text: text
+         });
      },
-     /**
-      * Render the widget. This.template must be defined.
-      * The content of the current object is passed as context to the template.
-      *
-      * @param {object} additional Additional context arguments to pass to the template.
-      */
-     render: function (additional) {
-         return QWeb.render(this.template, _.extend({}, this, additional != null ? additional : {}));
+     warn: function(title, text) {
+         this.$element.notify('create', 'oe_notification_alert', {
+             title: title,
+             text: text
+         });
      }
  });
  
@@@ -888,7 -857,7 +857,7 @@@ openerp.base.WebClient = openerp.base.C
          this.crashmanager =  new openerp.base.CrashManager(this);
          this.crashmanager.start(false);
  
-         // Do you autorize this ?
+         // Do you autorize this ? will be replaced by notify() in controller
          openerp.base.Controller.prototype.notification = new openerp.base.Notification(this, "oe_notification");
  
          this.header = new openerp.base.Header(this, "oe_header");
@@@ -18,6 -18,18 +18,18 @@@ openerp.base.ActionManager = openerp.ba
       * Process an action
       * Supported actions: act_window
       */
+     action_window: function() {
+     },
+     action_window_close: function() {
+     },
+     action_server: function() {
+     },
+     action_url: function() {
+     },
+     action_report: function() {
+     },
+     action_client: function() {
+     },
      do_action: function(action, on_closed) {
          var self = this;
          action.flags = _.extend({
@@@ -193,24 -205,11 +205,24 @@@ openerp.base.ViewManager =  openerp.bas
                  }
              }
          }
 +        if(this.flags && this.flags.sidebar) {
 +            if(this.$element.find('#exportview')){
 +                this.$element.find('#exportview').remove()
 +            }
 +            if(this.active_view == 'list' || this.active_view == 'form') {
 +                this.views[this.active_view].controller.$element.after(QWeb.render('ExportView'))
 +                this.$element.find('#exportview').click(function(ev) {
 +                    var export_view = new openerp.base.Export(self, self.dataset, self.views);
 +                    export_view.start(false);
 +                    ev.preventDefault();
 +                });
 +            }
 +        }
          return view_promise;
      },
      /**
       * Event launched when a controller has been inited.
 -     * 
 +     *
       * @param {String} view_type type of view
       * @param {String} view the inited controller
       */
@@@ -277,6 -276,7 +289,7 @@@ openerp.base.NullViewManager = openerp.
      }
  });
  
+ // TODO Will move to action Manager
  openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
      init: function(parent, element_id, action) {
          this.session = parent.session;
@@@ -417,7 -417,6 +430,7 @@@ openerp.base.Sidebar = openerp.base.Bas
  
  openerp.base.NullSidebar = openerp.base.generate_null_object_class(openerp.base.Sidebar);
  
 +/*
  openerp.base.Export = openerp.base.Dialog.extend({
      dialog_title: "Export",
      template: 'ExportDialog',
          this.$element.dialog("close");
      }
  });
 -
 +*/
  openerp.base.View = openerp.base.Controller.extend({
      /**
       * Fetches and executes the action identified by ``action_data``.
       * Directly set a view to use instead of calling fields_view_get. This method must
       * be called before start(). When an embedded view is set, underlying implementations
       * of openerp.base.View must use the provided view instead of any other one.
 -     * 
 +     *
       * @param embedded_view A view.
       */
      set_embedded_view: function(embedded_view) {