[MERGE] point_of_sale: memory leak fixes
bzr revid: fva@openerp.com-20130114152724-pjj45my55syk0fwz
This commit is contained in:
commit
cf48b54665
|
@ -864,6 +864,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
this.pos.bind('change:selectedOrder', this.change_selected_order, this);
|
||||
this.bindPaymentLineEvents();
|
||||
this.bind_orderline_events();
|
||||
this.paymentlinewidgets = [];
|
||||
},
|
||||
show: function(){
|
||||
this._super();
|
||||
|
@ -932,18 +933,24 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
},
|
||||
addPaymentLine: function(newPaymentLine) {
|
||||
var self = this;
|
||||
var x = new module.PaymentlineWidget(null, {
|
||||
var l = new module.PaymentlineWidget(null, {
|
||||
payment_line: newPaymentLine
|
||||
});
|
||||
x.on('delete_payment_line', self, function(r) {
|
||||
l.on('delete_payment_line', self, function(r) {
|
||||
self.deleteLine(r);
|
||||
});
|
||||
x.appendTo(this.$('#paymentlines'));
|
||||
l.appendTo(this.$('#paymentlines'));
|
||||
this.paymentlinewidgets.push(l);
|
||||
this.$('.paymentline-amount input:last').focus();
|
||||
},
|
||||
renderElement: function() {
|
||||
this._super();
|
||||
this.$('#paymentlines').empty();
|
||||
for(var i = 0, len = this.paymentlinewidgets.length; i < len; i++){
|
||||
this.paymentlinewidgets[i].destroy();
|
||||
}
|
||||
this.paymentlinewidgets = [];
|
||||
|
||||
this.currentPaymentLines.each(_.bind( function(paymentLine) {
|
||||
this.addPaymentLine(paymentLine);
|
||||
}, this));
|
||||
|
|
|
@ -165,6 +165,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
this.set_numpad_state(options.numpadState);
|
||||
this.pos.bind('change:selectedOrder', this.change_selected_order, this);
|
||||
this.bind_orderline_events();
|
||||
this.orderlinewidgets = [];
|
||||
},
|
||||
set_numpad_state: function(numpadState) {
|
||||
if (this.numpadState) {
|
||||
|
@ -210,6 +211,16 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
var self = this;
|
||||
this._super();
|
||||
|
||||
// freeing subwidgets
|
||||
|
||||
if(this.scrollbar){
|
||||
this.scrollbar.destroy();
|
||||
}
|
||||
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'){
|
||||
|
@ -227,6 +238,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
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();
|
||||
|
@ -571,7 +583,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
var self = this;
|
||||
this._super(parent,options);
|
||||
this.model = options.model;
|
||||
this.product_list = [];
|
||||
this.productwidgets = [];
|
||||
this.weight = options.weight || 0;
|
||||
this.show_scale = options.show_scale || false;
|
||||
this.next_screen = options.next_screen || false;
|
||||
|
@ -584,7 +596,17 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
renderElement: function() {
|
||||
var self = this;
|
||||
this._super();
|
||||
this.product_list = [];
|
||||
|
||||
// free subwidgets memory from previous renders
|
||||
|
||||
for(var i = 0, len = this.productwidgets.length; i < len; i++){
|
||||
this.productwidgets[i].destroy();
|
||||
}
|
||||
this.productwidgets = [];
|
||||
if(this.scrollbar){
|
||||
this.scrollbar.destroy();
|
||||
}
|
||||
|
||||
this.pos.get('products')
|
||||
.chain()
|
||||
.map(function(product) {
|
||||
|
@ -593,7 +615,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
weight: self.weight,
|
||||
click_product_action: self.click_product_action,
|
||||
})
|
||||
self.product_list.push(product);
|
||||
self.productwidgets.push(product);
|
||||
return product;
|
||||
})
|
||||
.invoke('appendTo', this.$('.product-list'));
|
||||
|
|
Loading…
Reference in New Issue