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 3accd712a57..124279bc0a0 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..fd3ea690245 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -581,7 +581,6 @@ openerp.web.Header = openerp.web.Widget.extend(/** @lends openerp.web.Header# * this._super(parent); this.qs = "?" + jQuery.param.querystring(); this.$content = $(); - console.debug("initializing header with id", this.element_id); this.update_promise = $.Deferred().resolve(); }, start: function() { @@ -776,74 +775,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; @@ -905,7 +962,6 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie this.session.start(); this.login.start(); this.menu.start(); - console.debug("The openerp client has been initialized."); }, on_logged: function() { if(this.action_manager) diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index fc4e3b4c2c4..076e91b269c 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -1,7 +1,10 @@ /*--------------------------------------------------------- * OpenERP Web core *--------------------------------------------------------*/ - +var console; +if (!console) { + console = {log: function () {}}; +} if (!console.debug) { console.debug = console.log; } @@ -944,7 +947,6 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg * If that's not the case this method will simply return `false`. */ do_action: function(action, on_finished) { - console.log('Widget.do_action', action, on_finished); if (this.widget_parent) { return this.widget_parent.do_action(action, on_finished); } diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index a2151dbd40f..db91d6bfd27 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; } diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index f8a89cd34a1..eeda44c4c99 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -415,8 +415,8 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# */ do_search: function (domains, contexts, groupbys) { return this.rpc('/web/session/eval_domain_and_context', { - domains: [this.dataset.get_domain()].concat(domains), - contexts: [this.dataset.get_context()].concat(contexts), + domains: _([this.dataset.get_domain()].concat(domains)).compact(), + contexts: _([this.dataset.get_context()].concat(contexts)).compact(), group_by_seq: groupbys }, $.proxy(this, 'do_actual_search')); }, @@ -541,6 +541,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# if (_.isEmpty(records)) { records = this.groups.get_records(); } + records = _(records).compact(); var count = 0, sums = {}; _(columns).each(function (column) { @@ -1235,6 +1236,9 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L }, get_records: function () { if (_(this.children).isEmpty()) { + if (!this.datagroup.length) { + return; + } return { count: this.datagroup.length, values: this.datagroup.aggregates 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 346e6653018..3e75628b12b 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -38,11 +38,17 @@ - - - -
-
+ + + + + + +
+ +
+
+
@@ -364,45 +370,39 @@ - - - - - + + +
- - - -
+ + + +
-