diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 2771c658270..a6b5fa63918 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -151,8 +151,15 @@ def ensure_db(redirect='/web/database/selector'): # may depend on data injected by the database route dispatcher. # Thus, we redirect the user to the same page but with the session cookie set. # This will force using the database route dispatcher... + r = request.httprequest + url_redirect = r.base_url + if r.query_string: + # Can't use werkzeug.wrappers.BaseRequest.url with encoded hashes: + # https://github.com/amigrave/werkzeug/commit/b4a62433f2f7678c234cdcac6247a869f90a7eb7 + url_redirect += '?' + r.query_string + response = werkzeug.utils.redirect(url_redirect, 302) request.session.db = db - abort_and_redirect(request.httprequest.url) + abort_and_redirect(url_redirect) # if db not provided, use the session one if not db: @@ -649,6 +656,9 @@ class Home(http.Controller): ensure_db() if request.session.uid: + if kw.get('redirect'): + return werkzeug.utils.redirect(kw.get('redirect'), 303) + headers = { 'Cache-Control': 'no-cache', 'Content-Type': 'text/html; charset=utf-8', @@ -661,6 +671,9 @@ class Home(http.Controller): def web_login(self, redirect=None, **kw): ensure_db() + if request.httprequest.method == 'GET' and redirect and request.session.uid: + return http.redirect_with_hash(redirect) + if not request.uid: request.uid = openerp.SUPERUSER_ID @@ -1202,11 +1215,14 @@ class DataSet(http.Controller): def _call_kw(self, model, method, args, kwargs): # Temporary implements future display_name special field for model#read() - if method == 'read' and kwargs.get('context', {}).get('future_display_name'): + if method in ('read', 'search_read') and kwargs.get('context', {}).get('future_display_name'): if 'display_name' in args[1]: - names = dict(request.session.model(model).name_get(args[0], **kwargs)) + if method == 'read': + names = dict(request.session.model(model).name_get(args[0], **kwargs)) + else: + names = dict(request.session.model(model).name_search('', args[0], **kwargs)) args[1].remove('display_name') - records = request.session.model(model).read(*args, **kwargs) + records = getattr(request.session.model(model), method)(*args, **kwargs) for record in records: record['display_name'] = \ names.get(record['id']) or "%s#%d" % (model, (record['id'])) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 66bfaca7c6e..3125d9e938b 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1284,12 +1284,14 @@ width: 100%; } .openerp .oe_view_manager .oe_view_manager_body { - display: table-row; height: inherit; } .openerp .oe_view_manager .oe_view_manager_view_kanban:not(:empty) { height: inherit; } +.openerp .oe_view_manager[data-view-type=kanban] .oe_view_manager_body { + display: table-row; +} .openerp .oe_view_manager table.oe_view_manager_header { border-collapse: separate; width: 100%; @@ -2398,6 +2400,7 @@ } .openerp .oe_hidden_input_file { position: relative; + overflow-x: hidden; } .openerp .oe_hidden_input_file input.oe_form_binary_file { z-index: 0; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 7110349557a..ca77310b0d9 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1068,10 +1068,12 @@ $sheet-padding: 16px height: inherit width: 100% .oe_view_manager_body - display: table-row height: inherit .oe_view_manager_view_kanban:not(:empty) height: inherit + &[data-view-type=kanban] + .oe_view_manager_body + display: table-row table.oe_view_manager_header border-collapse: separate @@ -1951,6 +1953,7 @@ $sheet-padding: 16px // Position: relative is used for the hidden input[type=file] // Do not remove it anymore ! position: relative + overflow-x: hidden input.oe_form_binary_file z-index: 0 line-height: 0 diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 8e5df84e2c3..de56927799e 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -105,9 +105,6 @@ instance.web.Dialog = instance.web.Widget.extend({ autoOpen: false, position: [false, 40], buttons: null, - beforeClose: function () { - self.trigger("closing"); - }, resizeStop: function() { self.trigger("resized"); }, @@ -208,8 +205,9 @@ instance.web.Dialog = instance.web.Widget.extend({ /** Closes the popup, if destroy_on_close was passed to the constructor, it is also destroyed. */ - close: function() { + close: function(reason) { if (this.dialog_inited && this.$el.is(":data(dialog)")) { + this.trigger("closing", reason); this.$el.dialog('close'); } }, @@ -225,14 +223,14 @@ instance.web.Dialog = instance.web.Widget.extend({ /** Destroys the popup, also closes it. */ - destroy: function () { + destroy: function (reason) { this.$buttons.remove(); _.each(this.getChildren(), function(el) { el.destroy(); }); if (! this.__tmp_dialog_closing) { this.__tmp_dialog_destroying = true; - this.close(); + this.close(reason); this.__tmp_dialog_destroying = undefined; } if (this.dialog_inited && !this.isDestroyed() && this.$el.is(":data(dialog)")) { @@ -256,7 +254,7 @@ instance.web.CrashManager = instance.web.Class.extend({ new (handler)(this, error).display(); return; } - if (error.data.name === "openerp.http.SessionExpiredException") { + if (error.data.name === "openerp.http.SessionExpiredException" || error.data.name === "werkzeug.exceptions.Forbidden") { this.show_warning({type: "Session Expired", data: { message: _t("Your OpenERP session expired. Please refresh the current web page.") }}); return; } @@ -1264,9 +1262,9 @@ instance.web.WebClient = instance.web.Client.extend({ }; self.action_manager.do_action(result); var form = self.action_manager.dialog_widget.views.form.controller; - form.on("on_button_cancel", self.action_manager.dialog, self.action_manager.dialog.close); + form.on("on_button_cancel", self.action_manager, self.action_manager.dialog_stop); form.on('record_saved', self, function() { - self.action_manager.dialog.close(); + self.action_manager.dialog_stop(); self.update_logo(); }); }); diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index b92ca1d3ba5..90c84ba9cda 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -271,7 +271,12 @@ instance.web.Session.include( /** @lends instance.web.Session# */{ for(var i=0; i - width: 83px;