From ca9b8158aaa2fddcc643bd0d4f5fdd322ce22e32 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 23 Dec 2011 17:15:02 +0100 Subject: [PATCH] [fix] small problem with scrollbar in order lines in pos bzr revid: nicolas.vanhoren@openerp.com-20111223161502-qtva9qrk3ifn9q25 --- addons/point_of_sale/static/src/js/pos.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index ccb9b0442e0..232992e6740 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -688,25 +688,30 @@ openerp.point_of_sale = function(db) { this._super(parent); this.model = options.model; this.model.bind('change', _.bind( function() { - this.$element.hide(); - this.render_element(); + this.refresh(); }, this)); this.model.bind('remove', _.bind( function() { - return this.$element.remove(); + this.$element.remove(); }, this)); this.order = options.order; }, start: function() { this.$element.click(_.bind(this.clickHandler, this)); + this.refresh(); }, clickHandler: function() { this.select(); }, render_element: function() { + this.$element.html(this.template_fct(this.model.toJSON())); this.select(); - return this.$element.html(this.template_fct(this.model.toJSON())).fadeIn(400, function() { - return $('#current-order').scrollTop($(this).offset().top); - }); + }, + refresh: function() { + this.render_element(); + var heights = _.map(this.$element.prevAll(), function(el) {return $(el).outerHeight();}); + heights.push($('#current-order thead').outerHeight()); + var position = _.reduce(heights, function(memo, num){ return memo + num; }, 0); + $('#current-order').scrollTop(position); }, select: function() { $('tr.selected').removeClass('selected');