diff --git a/addons/web/common/http.py b/addons/web/common/http.py index 3f6c96d1f42..0186fd985cc 100644 --- a/addons/web/common/http.py +++ b/addons/web/common/http.py @@ -20,6 +20,7 @@ def session(request, storage_path, session_cookie='sessionid'): else: request.session = session_store.new() - yield request.session - - session_store.save(request.session) + try: + yield request.session + finally: + session_store.save(request.session) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 4645c55f692..d7624493fdc 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -221,17 +221,11 @@ label.error { height: 100%; background: #f0eeee; } +.openerp .oe-application-container { + height: 100%; +} /* Menu */ -.openerp .sf-menu { - margin-bottom: 0; -} -/* -.sf-menu a { - padding: 5px 5px; -} -*/ - .openerp .menu { height: 34px; background: #cc4e45; /* Old browsers */ @@ -253,7 +247,7 @@ label.error { height: 20px; margin: 3px 2px; padding: 0 8px; - + background: #bd5e54; /* Old browsers */ background: -moz-linear-gradient(top, #bd5e54 0%, #90322a 60%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bd5e54), color-stop(60%,#90322a)); /* Chrome,Safari4+ */ @@ -291,13 +285,38 @@ label.error { background: linear-gradient(top, #c6c6c6 0%,#5c5c5c 7%,#969595 86%); /* W3C */ /* for ie */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#5c5c5c', endColorstr='#969595',GradientType=0 ); /* IE6-9 */ - color: #fff; } -.openerp .oe-application-container { - height: 100%; -} /* Secondary Menu */ +.openerp .secondary_menu .oe_toggle_secondary_menu { + position: absolute; + cursor: pointer; + border-left: 1px solid #282828; + width: 21px; + height: 21px; + z-index: 10; + background: transparent; + color: white; + text-shadow: 0 1px 0 #333; + text-align: center; + font-size: 18px; + line-height: 14px; + right: 0; +} +.openerp .secondary_menu.oe_folded .oe_toggle_secondary_menu { + position: static; + border-left: none; + border-bottom: 1px solid #282828; + width: 21px; + height: 21px; + background: #818181; +} +.openerp .secondary_menu.oe_folded .oe_toggle_secondary_menu span.oe_menu_fold { + display: none; +} +.openerp .secondary_menu.oe_unfolded .oe_toggle_secondary_menu span.oe_menu_unfold { + display: none; +} .openerp .secondary_menu { width: 200px; min-width: 200px; @@ -306,15 +325,34 @@ label.error { background: #5A5858; vertical-align: top; height: 100%; + position: relative; } -.openerp .secondary_menu .menu_content { - padding: 0; - border: none; - background: none; - overflow: hidden; +.openerp .secondary_menu.oe_folded { + width: 20px; + min-width: 20px; + position: static; } -.openerp .secondary_menu h3 { - padding: 0 0 2px; +.openerp .secondary_menu.oe_folded .oe_secondary_menu.active { + position: absolute; + z-index: 100; + border: 4px solid #585858; + border: 4px solid rgba(88, 88, 88, .5); + border-radius: 4px; + min-width: 200px; +} +.openerp .secondary_menu a { + display: block; + padding: 0 5px 2px 5px; + line-height: 20px; + text-decoration: none; + white-space: nowrap; + color: white; + text-shadow: 0 1px 0 #333; +} +.openerp .oe_secondary_submenu { + background: #5A5858; +} +.openerp .secondary_menu a.oe_secondary_menu_item { background: #949292; /* Old browsers */ background: -moz-linear-gradient(top, #949292 0%, #6d6b6b 87%, #282828 99%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#949292), color-stop(87%,#6d6b6b), color-stop(99%,#282828)); /* Chrome,Safari4+ */ @@ -325,34 +363,13 @@ label.error { background: linear-gradient(top, #949292 0%,#6d6b6b 87%,#282828 99%); /* W3C */ /* for ie9 */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#949292', endColorstr='#5B5A5A',GradientType=0 ); /* IE6-9 */ - border: none; - /* overriding jquery ui */ - -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; -} -.openerp .secondary_menu h4 { - padding: 0 0 2px 10px; - border: none; - background: none; -} -.openerp .secondary_menu h3 span, .openerp .secondary_menu h4 span { - left: 0 !important; -} -.openerp .secondary_menu a { - display: block; - height: 20px; - padding: 0 5px; - line-height: 20px; white-space: nowrap; color: white; - text-decoration: none; text-shadow: 0 1px 0 #333; } -.openerp .secondary_menu a.leaf:hover, -.openerp .secondary_menu a.leaf:active, -.openerp .secondary_menu a.leaf.active, -.openerp .secondary_menu h4:hover, -.openerp .secondary_menu h4:active, -.openerp .secondary_menu h4.active { +.openerp a.oe_secondary_submenu_item:hover, +.openerp a.oe_secondary_submenu_item.leaf.active { + display: block; background: #ffffff; /* Old browsers */ background: -moz-linear-gradient(top, #ffffff 0%, #d8d8d8 11%, #afafaf 86%, #333333 91%, #5a5858 96%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(11%,#d8d8d8), color-stop(86%,#afafaf), color-stop(91%,#333333), color-stop(96%,#5a5858)); /* Chrome,Safari4+ */ @@ -361,22 +378,17 @@ label.error { background: -ms-linear-gradient(top, #ffffff 0%,#d8d8d8 11%,#afafaf 86%,#333333 91%,#5a5858 96%); /* IE10+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#5A5858',GradientType=0 ); /* IE6-9 */ background: linear-gradient(top, #ffffff 0%,#d8d8d8 11%,#afafaf 86%,#333333 91%,#5a5858 96%); /* W3C */ - /* overriding jquery ui */ - -moz-border-radius-topright: 0; -webkit-border-top-right-radius: 0; border-top-right-radius: 0; + padding: 0 5px 2px 5px; + line-height: 20px; color: #3f3d3d; + text-decoration: none; text-shadow: #fff 0 1px 0; - border: none !important; } - -.openerp .secondary_menu h4:hover a, -.openerp .secondary_menu h4:active a, -.openerp .secondary_menu h4.active a { - color: #3f3d3d; - text-shadow: #fff 0 1px 0; - border: none !important; +.openerp a.oe_secondary_submenu_item.submenu.opened span:before { + content: "\25be"; } -.openerp div.submenu_accordion div.menu_content a span { - padding-left: 20px; +.openerp a.oe_secondary_submenu_item.submenu span:before { + content: "\25b8"; } /* Header */ diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index d114f485c62..8a8962fd27b 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -776,74 +776,132 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ this.secondary_menu_id = secondary_menu_id; this.$secondary_menu = $("#" + secondary_menu_id).hide(); this.menu = false; + this.folded = false; + if (window.localStorage) { + this.folded = localStorage.getItem('oe_menu_folded') === 'true'; + } + this.float_timeout = 700; }, start: function() { + this.$secondary_menu.addClass(this.folded ? 'oe_folded' : 'oe_unfolded'); + this.reload(); + }, + reload: function() { this.rpc("/web/menu/load", {}, this.on_loaded); }, on_loaded: function(data) { this.data = data; - this.$element.html(QWeb.render("Menu", this.data)); - for (var i = 0; i < this.data.data.children.length; i++) { - var v = { menu : this.data.data.children[i] }; - this.$secondary_menu.append(QWeb.render("Menu.secondary", v)); - } - this.$secondary_menu.find("div.menu_accordion").accordion({ - animated : false, - autoHeight : false, - icons : false - }); - this.$secondary_menu.find("div.submenu_accordion").accordion({ - animated : false, - autoHeight : false, - active: false, - collapsible: true, - header: 'h4' - }); - + this.$element.html(QWeb.render("Menu", { widget : this })); + this.$secondary_menu.html(QWeb.render("Menu.secondary", { widget : this })); this.$element.add(this.$secondary_menu).find("a").click(this.on_menu_click); + this.$secondary_menu.find('.oe_toggle_secondary_menu').click(this.on_toggle_fold); + }, + on_toggle_fold: function() { + this.$secondary_menu.toggleClass('oe_folded').toggleClass('oe_unfolded'); + if (this.folded) { + this.$secondary_menu.find('.oe_secondary_menu.active').show(); + } else { + this.$secondary_menu.find('.oe_secondary_menu').hide(); + } + this.folded = !this.folded; + if (window.localStorage) { + localStorage.setItem('oe_menu_folded', this.folded.toString()); + } }, on_menu_click: function(ev, id) { id = id || 0; - var $menu, $parent, $secondary; + var $clicked_menu, manual = false; if (id) { // We can manually activate a menu with it's id (for hash url mapping) - $menu = this.$element.find('a[data-menu=' + id + ']'); - if (!$menu.length) { - $menu = this.$secondary_menu.find('a[data-menu=' + id + ']'); + manual = true; + $clicked_menu = this.$element.find('a[data-menu=' + id + ']'); + if (!$clicked_menu.length) { + $clicked_menu = this.$secondary_menu.find('a[data-menu=' + id + ']'); } } else { - $menu = $(ev.currentTarget); - id = $menu.data('menu'); - } - if (this.$secondary_menu.has($menu).length) { - $secondary = $menu.parents('.menu_accordion'); - $parent = this.$element.find('a[data-menu=' + $secondary.data('menu-parent') + ']'); - } else { - $parent = $menu; - $secondary = this.$secondary_menu.find('.menu_accordion[data-menu-parent=' + $menu.attr('data-menu') + ']'); + $clicked_menu = $(ev.currentTarget); + id = $clicked_menu.data('menu'); } - this.$secondary_menu.find('.menu_accordion').hide(); - // TODO: ui-accordion : collapse submenus and expand the good one - $secondary.show(); - - if (id) { + if (this.do_menu_click($clicked_menu, manual) && id) { this.session.active_id = id; - this.rpc('/web/menu/action', {'menu_id': id}, - this.on_menu_action_loaded); + this.rpc('/web/menu/action', {'menu_id': id}, this.on_menu_action_loaded); } + ev.stopPropagation(); + return false; + }, + do_menu_click: function($clicked_menu, manual) { + var $sub_menu, $main_menu, + active = $clicked_menu.is('.active'), + sub_menu_visible = false; + + if (this.$secondary_menu.has($clicked_menu).length) { + $sub_menu = $clicked_menu.parents('.oe_secondary_menu'); + $main_menu = this.$element.find('a[data-menu=' + $sub_menu.data('menu-parent') + ']'); + } else { + $sub_menu = this.$secondary_menu.find('.oe_secondary_menu[data-menu-parent=' + $clicked_menu.attr('data-menu') + ']'); + $main_menu = $clicked_menu; + } + + sub_menu_visible = $sub_menu.is(':visible'); + this.$secondary_menu.find('.oe_secondary_menu').hide(); $('.active', this.$element.add(this.$secondary_menu.show())).removeClass('active'); - $parent.addClass('active'); - $menu.addClass('active'); - $menu.parent('h4').addClass('active'); + $main_menu.add($clicked_menu).add($sub_menu).addClass('active'); - if (this.$secondary_menu.has($menu).length) { - return !$menu.is(".leaf"); - } else { - return false; + if (!(this.folded && manual)) { + this.do_show_secondary($sub_menu, $main_menu); } + + if ($main_menu != $clicked_menu) { + if ($clicked_menu.is('.submenu')) { + $sub_menu.find('.submenu.opened').each(function() { + if (!$(this).next().has($clicked_menu).length && !$(this).is($clicked_menu)) { + $(this).removeClass('opened').next().hide(); + } + }); + $clicked_menu.toggleClass('opened').next().toggle(); + } else if ($clicked_menu.is('.leaf')) { + $sub_menu.toggle(!this.folded); + return true; + } + } else if (this.folded) { + if (active && sub_menu_visible) { + $sub_menu.hide(); + return true; + } + } else { + return true; + } + return false; + }, + do_show_secondary: function($sub_menu, $main_menu) { + var self = this; + if (this.folded) { + var css = $main_menu.position(), + fold_width = this.$secondary_menu.width() + 2, + window_width = $(window).width(); + css.top += 33; + css.left -= Math.round(($sub_menu.width() - $main_menu.width()) / 2); + css.left = css.left < fold_width ? fold_width : css.left; + if ((css.left + $sub_menu.width()) > window_width) { + delete(css.left); + css.right = 1; + } + $sub_menu.css(css); + $sub_menu.mouseenter(function() { + clearTimeout($sub_menu.data('timeoutId')); + }).mouseleave(function(evt) { + var timeoutId = setTimeout(function() { + if (self.folded) { + $sub_menu.hide(); + } + }, self.float_timeout); + $sub_menu.data('timeoutId', timeoutId); + }); + } + $sub_menu.show(); }, on_menu_action_loaded: function(data) { var self = this; diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index b0dc4fcc289..925490b7459 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -82,7 +82,12 @@ openerp.web.parse_value = function (value, descriptor, value_if_empty) { } switch (descriptor.widget || descriptor.type) { case 'integer': - var tmp = Number(value); + var tmp; + do { + tmp = value; + value = value.replace(openerp.web._t.database.parameters.thousands_sep, ""); + } while(tmp !== value); + tmp = Number(value); if (isNaN(tmp)) throw value + " is not a correct integer"; return tmp; diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 5db66ab7260..94143d4bbfa 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -327,7 +327,8 @@ openerp.web.SearchView = openerp.web.Widget.extend(/** @lends openerp.web.Search this.notification.notify("Invalid Search", "triggered from search view"); }, do_clear: function () { - $('.filter_label').removeClass('enabled'); + this.$element.find('.filter_label').removeClass('enabled'); + this.enabled_filters.splice(0); var string = $('a.searchview_group_string'); _.each(string, function(str){ $(str).closest('div.searchview_group').removeClass("expanded").addClass('folded'); @@ -542,6 +543,7 @@ openerp.web.search.FilterGroup = openerp.web.search.Input.extend(/** @lends open var domains = _(this.filters).chain() .filter(function (filter) { return filter.is_enabled(); }) .map(function (filter) { return filter.attrs.domain; }) + .reject(_.isEmpty) .value(); if (!domains.length) { return; } @@ -720,7 +722,11 @@ openerp.web.search.NumberField = openerp.web.search.Field.extend(/** @lends open openerp.web.search.IntegerField = openerp.web.search.NumberField.extend(/** @lends openerp.web.search.IntegerField# */{ error_message: "not a valid integer", parse: function (value) { - return parseInt(value, 10); + try { + return openerp.web.parse_value(value, {'widget': 'integer'}); + } catch (e) { + return NaN; + } } }); /** @@ -730,7 +736,11 @@ openerp.web.search.IntegerField = openerp.web.search.NumberField.extend(/** @len openerp.web.search.FloatField = openerp.web.search.NumberField.extend(/** @lends openerp.web.search.FloatField# */{ error_message: "not a valid number", parse: function (value) { - return parseFloat(value); + try { + return openerp.web.parse_value(value, {'widget': 'float'}); + } catch (e) { + return NaN; + } } }); /** @@ -1168,11 +1178,11 @@ openerp.web.search.ExtendedSearchProposition.Integer = openerp.web.OldWidget.ext {value: "<=", text: "less or equal than"} ], get_value: function() { - var value = parseFloat(this.$element.val()); - if(value != 0 && !value) { + try { + return openerp.web.parse_value(this.$element.val(), {'widget': 'integer'}); + } catch (e) { return ""; } - return Math.round(value); } }); openerp.web.search.ExtendedSearchProposition.Float = openerp.web.OldWidget.extend({ @@ -1187,11 +1197,11 @@ openerp.web.search.ExtendedSearchProposition.Float = openerp.web.OldWidget.exten {value: "<=", text: "less or equal than"} ], get_value: function() { - var value = parseFloat(this.$element.val()); - if(value != 0 && !value) { + try { + return openerp.web.parse_value(this.$element.val(), {'widget': 'float'}); + } catch (e) { return ""; } - return value; } }); openerp.web.search.ExtendedSearchProposition.Selection = openerp.web.OldWidget.extend({ diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index b5a5a3d8c10..beb2c3ac0a9 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -182,9 +182,11 @@ openerp.web.list_editable = function (openerp) { self.edition_id = record_id; self.edition_form = _.extend(new openerp.web.ListEditableFormView(self, self.dataset, false), { form_template: 'ListView.row.form', - registry: openerp.web.list.form.widgets + registry: openerp.web.list.form.widgets, + $element: $new_row }); - self.edition_form.appendTo($("#" + $new_row.attr('id'))); + // HA HA + self.edition_form.appendTo(); $.when(self.edition_form.on_loaded(self.get_form_fields_view())).then(function () { // put in $.when just in case FormView.on_loaded becomes asynchronous $new_row.find('td') @@ -335,6 +337,9 @@ openerp.web.list_editable = function (openerp) { }); openerp.web.ListEditableFormView = openerp.web.FormView.extend({ - init_view: function() {} + init_view: function() {}, + _render_and_insert: function () { + return this.start(); + } }); }; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index da5f2e0638e..3870ef43b67 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -38,11 +38,17 @@
| + | +
+
+
+ |
+
|
-
- |
-
|
+
+ |
+