[FIX] point_of_sale: keyboard focus for payment widget

bzr revid: fva@openerp.com-20130129140146-uz1jpmv4u3dmulus
This commit is contained in:
Frédéric van der Essen 2013-01-29 15:01:46 +01:00
parent e9c6fd0dea
commit a06e93e218
2 changed files with 25 additions and 3 deletions

View File

@ -857,6 +857,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.bindPaymentLineEvents();
this.bind_orderline_events();
this.paymentlinewidgets = [];
this.focusedLine = null;
},
show: function(){
this._super();
@ -886,6 +887,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
});
this.updatePaymentSummary();
this.line_refocus();
},
close: function(){
this._super();
@ -923,10 +925,20 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.bind_orderline_events();
this.renderElement();
},
line_refocus: function(lineWidget){
if(lineWidget){
if(this.focusedLine !== lineWidget){
this.focusedLine = lineWidget;
}
}
if(this.focusedLine){
this.focusedLine.focus();
}
},
addPaymentLine: function(newPaymentLine) {
var self = this;
var l = new module.PaymentlineWidget(null, {
payment_line: newPaymentLine
var l = new module.PaymentlineWidget(this, {
payment_line: newPaymentLine,
});
l.on('delete_payment_line', self, function(r) {
self.deleteLine(r);
@ -936,6 +948,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
if(this.numpadState){
this.numpadState.resetValue();
}
this.line_refocus(l);
},
renderElement: function() {
this._super();
@ -952,6 +965,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
},
deleteLine: function(lineWidget) {
this.currentPaymentLines.remove([lineWidget.payment_line]);
lineWidget.destroy();
},
updatePaymentSummary: function() {
var currentOrder = this.pos.get('selectedOrder');

View File

@ -328,11 +328,19 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
var self = this;
this.name = this.payment_line.get_cashregister().get('journal_id')[1];
this._super();
this.$('input').keyup(_.bind(this.changeAmount, this));
this.$('input').keyup(function(event){
self.changeAmount(event);
});
this.$('.delete-payment-line').click(function() {
self.trigger('delete_payment_line', self);
});
},
focus: function(){
var val = this.$('input')[0].value;
this.$('input')[0].focus();
this.$('input')[0].value = val;
this.$('input')[0].select();
},
});
module.OrderButtonWidget = module.PosBaseWidget.extend({