Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
17192 Lượt xem

Hi,
I have created a popup window in pos. When I click on the payment method a popup window will be shown with a textarea.
But the issue is, I am unable to input any value to the textarea using the keyboard
I can input value to the text area using 'ctrl+v' , but no other keys in the keyboard is working.
The code I used is below,

this.gui.show_popup('textarea',{
'title': _t('Swipe your card'),
'confirm': function(value) {
        //-------- my code--------------- } });

Any help appreciated. 

Thank you.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Hi Saravana,

I found a solution for this. The reason why it is not possible to input any value is, there is a keyboard key down handler function in 'PaymentScreenWidget'. This is a keydown handler that prevents backspace from doing a back navigation. It also makes sure that keys that do not generate a keypress in Chrom{e,ium} (eg. delete, backspace, ...) get passed to the keypress handler.

I have made some changes in that function and now I can input values using my keyboard.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi

POS functions keyboard_keydown_handler() and keyboard_handler() blocks typing of content using your keyboard with the pop-up window. To fix this ;

Create  your pos_custom.js file and override the functions from the PaymentScreenWidget. See below code

odoo.define('pos_custom', function (require) {
"use strict";
//
var core = require('web.core');
var utils = require('web.utils');
//
var module = require('point_of_sale.models'); //Includes all Base Classes of point of sale
var round_di = utils.round_decimals;
var round_pr = utils.round_precision;
//Screens
var screens = require('point_of_sale.screens') // Require Base screens class
//
var QWeb = core.qweb;
var _t = core._t;
//
  //Extend payment screen and add more functionality
 screens.PaymentScreenWidget.include({

click_paymentmethods: function(id) {
var self = this ;
var cashregister = null;
for ( var i = 0; i < this.pos.cashregisters.length; i++ ) {
if ( this.pos.cashregisters[i].journal_id[0] === id ){
cashregister = this.pos.cashregisters[i];
break;
}
}
//debug
console.log("Payment Register ID >> " +cashregister.journal.id) ;
console.log("Payment Register Type >>> "+cashregister.journal.payment_mode) ;
//
if(cashregister.journal.payment_mode === 'mpesa'){
var phone_no = '123456' ;
// alert("Enter Client Phone Number >> ") ;
self.gui.show_popup('textinput',{
title: _t("Enter Client Phone Number") ,
confirm: function(){
//get value
var value = this.$('#text-input').val();
//alert(value);
//console.log("Value Captured ",value);
if(value){
console.log("Perform Validation of MPESA Code") ;
//Add Payment Line after success validation of the code
self.pos.get_order().add_paymentline( cashregister );
self.reset_input();
self.render_paymentlines();
}else{
// console.log("Cannot validate Code..");
self.gui.show_popup('error',{
'title': _t('Error: Payment Validation Error'),
'body': _t('Sorry Cannot validate the payment. Try again later'),
});
}

},
}) ;
}else {
//Add Payment Line after success validation of the code
self.pos.get_order().add_paymentline( cashregister );
self.reset_input();
self.render_paymentlines();
}

},
init: function(parent, options) {
var self = this;
this._super(parent, options);
//Overide methods
this.keyboard_keydown_handler = function(event){

if (event.keyCode === 8 || event.keyCode === 46) { // Backspace and Delete
event.preventDefault();
self.keyboard_handler(event);
}
};

this.keyboard_handler = function(event){
var key = '';

if (event.type === "keypress") {
if (event.keyCode === 13) { // Enter
self.validate_order();
} else if ( event.keyCode === 190 || // Dot
event.keyCode === 110 || // Decimal point (numpad)
event.keyCode === 188 || // Comma
event.keyCode === 46 ) { // Numpad dot
key = self.decimal_point;
} else if (event.keyCode >= 48 && event.keyCode <= 57) { // Numbers
key = '' + (event.keyCode - 48);
} else if (event.keyCode === 45) { // Minus
key = '-';
} else if (event.keyCode === 43) { // Plus
key = '+';
}else{
return ;
}
} else { // keyup/keydown
if (event.keyCode === 46) { // Delete
key = 'CLEAR';
} else if (event.keyCode === 8) { // Backspace
key = 'BACKSPACE';
}
}

self.payment_input(key);
// event.preventDefault();
/* if (event.type === "keypress") {
return ;
}*/
};
//End method override
} ,

}) ;

});



Thanks..



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I too have the same problem in odoo v9.

I created a new payment method for card payment. when choosing this payment option, a popup will arise to get the card details from the user. here i can't key in the details in the input fields. ( ctrl+v is working ).

i tested the odoo base popup widgets like TextInputPopupWidget and TextIAreaPopupWidget both are not working and can't key in the values.

Any solutions.?

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 19
9852
0
thg 12 18
2977
1
thg 10 18
6317
1
thg 11 24
1562
4
thg 10 24
3943