merge upstream
authorChristophe Simonis <chs@openerp.com>
Fri, 18 Nov 2011 13:26:06 +0000 (14:26 +0100)
committerChristophe Simonis <chs@openerp.com>
Fri, 18 Nov 2011 13:26:06 +0000 (14:26 +0100)
bzr revid: chs@openerp.com-20111117125432-zhfrcyrtwy9b9cv8
bzr revid: chs@openerp.com-20111118132606-6gh7zmrx7606w8fv

1  2 
addons/web/common/http.py
addons/web/static/src/js/core.js
addons/web/static/src/xml/base.xml

Simple merge
@@@ -346,37 -350,17 +350,38 @@@ openerp.web.Connection = openerp.web.Ca
       * @param {String} [server] JSON-RPC endpoint hostname
       * @param {String} [port] JSON-RPC endpoint port
       */
 -    init: function(server, port) {
 +    init: function() {
 +
 +        // FIXME need to be a real singleton.
 +        //       create more than one Connection on the same instance will not works
 +
          this._super();
 -        this.server = (server == undefined) ? location.hostname : server;
 -        this.port = (port == undefined) ? location.port : port;
 -        this.rpc_mode = (server == location.hostname) ? "ajax" : "jsonp";
 -        this.debug = (window.location.search.indexOf('?debug') !== -1);
 +        this.server = null;
 +        this.debug = ($.deparam($.param.querystring()).debug != undefined);
 +        // TODO: session should have an optional name indicating that they'll
 +        //       be saved to (and revived from) cookies
 +        this.name = 'session';
 +    },
 +
 +    bind: function(server, continuation) {
 +
 +        if(_.isFunction(server)) {
 +            continuation = server;
 +            server = null;
 +        }
 +
 +        if (this.server) {
 +            throw new Error("Connection already bound to " + this.server);
 +        } 
 +        var hostname = _.str.sprintf('%s//%s', location.protocol, location.host);
 +        this.server = _.str.rtrim((!server) ? hostname : server, '/');
 +        this.rpc_mode = (this.server == hostname) ? "oe-json" : "oe-jsonp";
          this.session_id = false;
          this.uid = false;
+         this.username = false;
          this.user_context= {};
          this.db = false;
 +        this.module_loading = $.Deferred();
          this.module_list = [];
          this.module_loaded = {"web": true};
          this.context = {};
          var self = this;
          var params = { db: db, login: login, password: password };
          return this.rpc("/web/session/login", params, function(result) {
-             self.session_id = result.session_id;
-             self.uid = result.uid;
-             self.user_context = result.context;
-             self.db = result.db;
+             _.extend(self, {
+                 session_id: result.session_id,
+                 uid: result.uid,
+                 user_context: result.context,
+                 db: result.db,
+                 username: result.login
+             });
              self.session_save();
 -            self.on_session_valid();
 +
 +            self.on_session_valid(success_callback);
              return true;
 -        }).then(success_callback);
 +        //}).done(success_callback);
 +        });
      },
      login: function() { this.session_login.apply(this, arguments); },
      /**
          var self = this;
          this.session_id = this.get_cookie('session_id');
          return this.rpc("/web/session/get_session_info", {}).then(function(result) {
-             self.uid = result.uid;
-             self.user_context = result.context;
-             self.db = result.db;
+             _.extend(self, {
+                 uid: result.uid,
+                 user_context: result.context,
+                 db: result.db,
+                 username: result.login
+             });
              if (self.uid)
 -                self.on_session_valid();
 +                self.on_session_valid(continuation);
              else
 -                self.on_session_invalid();
 +                self.on_session_invalid(continuation);
          }, function() {
 -            self.on_session_invalid();
 +            self.on_session_invalid(continuation);
          });
      },
      /**
  </t>
  <t t-name="web.datetimepicker">
      <div class="oe_datepicker_root">
-         <input type="text" size="1" style="width: 100%"/>
+         <input type="text" size="1" style="width: 100%"
+             t-att-name="widget.name"
+             t-attf-class="oe_datepicker_master field_#{widget.type_of_date}"
+         />
 -        <img class="oe_input_icon oe_datepicker_trigger" src="/web/static/src/img/ui/field_calendar.png"
 +        <img class="oe_input_icon oe_datepicker_trigger" t-att-src='widget.session.server + "/web/static/src/img/ui/field_calendar.png"'
               title="Select date" width="16" height="16" border="0"/>
-         <div class="oe_datepicker ui-widget-content ui-corner-all" style="display: none; position: absolute; z-index: 1;">
-             <div class="oe_datepicker_container"/>
-             <button type="button" class="oe_datepicker_close ui-state-default ui-priority-primary ui-corner-all" style="float: right;">Done</button>
-         </div>
+         <input type="text" size="1" class="oe_datepicker_container" disabled="disabled"/>
      </div>
  </t>
  <t t-name="FieldSelection">
      </table>
  </t>
  <t t-name="WidgetButton">
-     <button type="button" style="width: 100%" class="button">
+     <button type="button" class="oe_button">
 -        <img t-if="widget.node.attrs.icon" t-att-src="'/web/static/src/img/icons/' + widget.node.attrs.icon + '.png'" width="16" height="16"/>
 +        <img t-if="widget.node.attrs.icon" t-att-src="widget.session.server + '/web/static/src/img/icons/' + widget.node.attrs.icon + '.png'" width="16" height="16"/>
          <span t-if="widget.string"><t t-esc="widget.string"/></span>
      </button>
  </t>
          t-att-title="attrs.help"
          t-att-class="classes.join(' ')"
          t-att-autofocus="attrs.default_focus === '1' ? 'autofocus' : undefined">
-     <img t-if="attrs.icon" t-att-src="widget.session.server + '/web/static/src/img/icons/' + attrs.icon + '.png'" width="16" height="16"/>
-     <br t-if="attrs.icon and attrs.string"/>
 -    <img t-att-src="'/web/static/src/img/icons/' + (attrs.icon || 'gtk-home') + '.png'" width="16" height="16"/>
++    <img t-att-src="widget.session.server + '/web/static/src/img/icons/' + (attrs.icon || 'gtk-home') + '.png'" width="16" height="16"/>
+     <br t-if="attrs.string"/>
      <t t-esc="attrs.string"/>
  </button>
  <span t-name="SearchView.filters" class="filter_label_group"