I added a button on the pos payment interface which shows me a popup. how to make that when the user clicks on the confirm button of this popup that it redirects to the receipt of the pos
This is my action_button.js code:
"use strict";
var core = require('web.core');
var models = require('point_of_sale.models');
var screens = require('point_of_sale.screens');
var gui = require('point_of_sale.gui');
var PopupWidget = require('point_of_sale.popups');
var PaymentScreenWidget = screens.PaymentScreenWidget;
var PosBaseWidget = require('point_of_sale.BaseWidget');
var BarcodeEvents = require('barcodes.BarcodeEvents').BarcodeEvents;
var time = require('web.time');
var QWeb = core.qweb;
var ajax = require('web.ajax');
var _t = core._t;
var PopupNote = PopupWidget.extend({
template: 'PopupNote',
show: function(options) {
options = options || {};
this._super(options);
this.renderElement();
},
click_confirm: function() {
var value = this.$('input,textarea').val();
this.gui.close_popup();
if (this.options.confirm) {
this.options.confirm.call(this, value);
}
},
});
gui.define_popup({ name: 'popup_note', widget: PopupNote });
PaymentScreenWidget.include({
init: function(parent, options) {
var self = this;
this._super(parent, options);
this.pos.bind('change:selectedOrder', function() {
this.renderElement();
this.watch_order_changes();
}, this);
this.watch_order_changes();
this.inputbuffer = "";
this.firstinput = true;
this.decimal_point = _t.database.parameters.decimal_point;
// 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.
this.keyboard_keydown_handler = function(event) {
if (event.keyCode === 8 || event.keyCode === 46) { // Backspace and Delete
// event.preventDefault();
// These do not generate keypress events in
// Chrom{e,ium}. Even if they did, we just called
// preventDefault which will cancel any keypress that
// would normally follow. So we call keyboard_handler
// explicitly with this keydown event.
self.keyboard_handler(event);
}
};
// This keyboard handler listens for keypress events. It is
// also called explicitly to handle some keydown events that
// do not generate keypress events.
this.keyboard_handler = function(event) {
// On mobile Chrome BarcodeEvents relies on an invisible
// input being filled by a barcode device. Let events go
// through when this input is focused.
if (BarcodeEvents.$barcodeInput && BarcodeEvents.$barcodeInput.is(":focus")) {
return;
}
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 { // keyup/keydown
if (event.keyCode === 46) { // Delete
key = 'CLEAR';
} else if (event.keyCode === 8) { // Backspace
key = 'BACKSPACE';
}
}
// self.payment_input(key);
// event.preventDefault();
};
this.pos.bind('change:selectedClient', function() {
self.customer_changed();
}, this);
},
renderElement: function() {
var self = this;
this._super();
//var methods = this.render_paymentmethods();
//methods.appendTo(this.$('.paymentmethods-container'));
this.$('.confirm').click(function(){
self.click_custom_print();
});
this.$('.back').click(function(){
self.click_back();
});
/* this.$('.next').click(function(){
self.validate_order();
});*/
// console.log(this.$('js_customer_name'))
this.$('.popup_notes').click(function() {
self.get_select_data();
});
},
click_custom_print: function(){
var order = this.pos.get_order();
console.log(order)
// Render receipt screen and can print function
},
validate_order: function(force_validation) {
console.log("validation here")
if (this.order_is_valid(force_validation)) {
this.finalize_validation();
}
},
get_select_data: function() {
var self = this;
self.gui.show_popup('popup_note', {
title: _t('Interface Mobile money'),
confirm: function() {
var order = self.pos.get_order();
console.log("order=")
console.log(order)
var client_name=$("#client_name").text()
var numero_agent=$("#numero_agent").text()
var ref=document.getElementsByName("ref")[0].value
var montant=document.getElementsByName("montant")[0].value
if( numero_agent != '' && ref != '' && montant != ''){
ajax.jsonRpc("http://localhost:8070/postmobilemoney/",'call',{
name:"test",
reference:ref,
montant:montant,
nom_client:client_name,
numero_agent:numero_agent,
}).then(function (result){
var reference = result["reference"]
console.log(result)
//window.location.replace("http://localhost:8070/command/getall/"+reference);
})
}else {
alert("veuillez remplir tous les champs")
}
},
cance: function() {},
});
},
My views\pos.xml code in it we also find the popup interface:
Customer