Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Odoo7: overwrite OrderWidget to let order-control automagically resize

By
chen rong
on 9/26/14, 2:03 AM 495 views

openerp.openerp_pos_widgets = function (instance, module) {
    module.OrderWidget = module.PosBaseWidget.extend({
        renderElement: function() {
            var self = this;
            this._super();
            // freeing subwidgets
            if(this.scrollbar){
                this.scrollbar.destroy();
            }
            var height = document.getElementById("paypad").offsetHeight;
            $('.point-of-sale .order-container').css({'bottom': height});
            for(var i = 0, len = this.orderlinewidgets.length; i < len; i++){
                this.orderlinewidgets[i].destroy();
            }
            this.orderlinewidgets = [];
            if(this.display_mode === 'maximized'){
                $('.point-of-sale .order-container').css({'bottom':'0px'});
            }else if(this.display_mode === 'actionbar'){
                $('.point-of-sale .order-container').css({'bottom':'105px'});
            }else if(this.display_mode !== 'numpad'){
                console.error('ERROR: OrderWidget renderElement(): wrong display_mode:',this.display_mode);
            }

            var $content = this.$('.orderlines');
            this.currentOrderLines.each(_.bind( function(orderLine) {
                var line = new module.OrderlineWidget(this, {
                        model: orderLine,
                        order: this.pos.get('selectedOrder'),
                });
                line.on('order_line_selected', self, self.update_numpad);
                line.on('order_line_refreshed', self, self.update_summary);
                line.appendTo($content);
                self.orderlinewidgets.push(line);
            }, this));
            this.update_numpad();
            this.update_summary();
            var position = this.scrollbar ? this.scrollbar.get_position() : 0;
            var at_bottom = this.scrollbar ? this.scrollbar.is_at_bottom() : false;
            
            this.scrollbar = new module.ScrollbarWidget(this,{
                target_widget:   this,
                target_selector: '.order-scroller',
                name: 'order',
                track_bottom: true,
                on_show: function(){
                    self.$('.order-scroller').css({'width':'89%'},100);
                },
                on_hide: function(){
                    self.$('.order-scroller').css({'width':'100%'},100);
                },
            });

            this.scrollbar.replace(this.$('.placeholder-ScrollbarWidget'));
            this.scrollbar.set_position(position);

            if( at_bottom ){
                this.scrollbar.set_position(Number.MAX_VALUE, false);
            }

        }
    })
}

I make a new module

  add    var height = document.getElementById("paypad").offsetHeight;
            $('.point-of-sale .order-container').css({'bottom': height});

to OrderWidget

and add js['static/src/js/auto_height.js']

But it not works

sloved

chen rong
on 9/26/14, 6:26 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/26/14, 2:03 AM
Seen: 495 times
Last updated: 3/16/15, 8:10 AM