Browse Source

pos_payment_terminal: add missing css file

pos_customer_display: FIX JS code and make it more robust
pull/437/head
Alexis de Lattre 10 years ago
committed by Sylvain LE GAL
parent
commit
9ab59c37e8
  1. 125
      pos_customer_display/static/src/js/customer_display.js

125
pos_customer_display/static/src/js/customer_display.js

@ -3,7 +3,7 @@ openerp.pos_customer_display = function(instance){
var _t = instance.web._t; var _t = instance.web._t;
var round_di = instance.web.round_decimals; var round_di = instance.web.round_decimals;
var round_pr = instance.web.round_precision
var round_pr = instance.web.round_precision;
module.PosModel = module.PosModel.extend({ module.PosModel = module.PosModel.extend({
@ -25,6 +25,7 @@ openerp.pos_customer_display = function(instance){
this.proxy.complete_string_right(line.get_product().display_name, line_length), this.proxy.complete_string_right(line.get_product().display_name, line_length),
this.proxy.complete_string_right(l21, line_length - l22.length) + l22 this.proxy.complete_string_right(l21, line_length - l22.length) + l22
); );
} else if (type == 'removeOrderline') { } else if (type == 'removeOrderline') {
// first click on the backspace button set the amount to 0 => we can't precise the deleted qunatity and price // first click on the backspace button set the amount to 0 => we can't precise the deleted qunatity and price
var line = data['line']; var line = data['line'];
@ -32,6 +33,7 @@ openerp.pos_customer_display = function(instance){
this.proxy.complete_string_center(_t("Delete item"), line_length), this.proxy.complete_string_center(_t("Delete item"), line_length),
this.proxy.complete_string_center(line.get_product().name, line_length) this.proxy.complete_string_center(line.get_product().name, line_length)
); );
} else if (type == 'addPaymentline') { } else if (type == 'addPaymentline') {
var cashregister = data['cashregister']; var cashregister = data['cashregister'];
var total = this.get('selectedOrder').getTotalTaxIncluded().toFixed(currency_rounding); var total = this.get('selectedOrder').getTotalTaxIncluded().toFixed(currency_rounding);
@ -47,10 +49,11 @@ openerp.pos_customer_display = function(instance){
this.proxy.complete_string_center(_t("Delete payment"), line_length), this.proxy.complete_string_center(_t("Delete payment"), line_length),
this.proxy.complete_string_right(line.cashregister.journal_id[1] , line_length - 1 - amount.length) + ' ' + amount this.proxy.complete_string_right(line.cashregister.journal_id[1] , line_length - 1 - amount.length) + ' ' + amount
); );
} else if (type == 'pushOrder') { } else if (type == 'pushOrder') {
var currentOrder = data['currentOrder'];
var paidTotal = currentOrder.getPaidTotal();
var dueTotal = currentOrder.getTotalTaxIncluded();
var order = data['order'];
var paidTotal = order.getPaidTotal();
var dueTotal = order.getTotalTaxIncluded();
var remaining = dueTotal > paidTotal ? dueTotal - paidTotal : 0; var remaining = dueTotal > paidTotal ? dueTotal - paidTotal : 0;
var change = paidTotal > dueTotal ? paidTotal - dueTotal : 0; var change = paidTotal > dueTotal ? paidTotal - dueTotal : 0;
@ -66,6 +69,7 @@ openerp.pos_customer_display = function(instance){
l1, l1,
this.proxy.complete_string_center(_t("Next customer..."), line_length) this.proxy.complete_string_center(_t("Next customer..."), line_length)
); );
} else if (type = 'closePOS') { } else if (type = 'closePOS') {
var lines_to_send = new Array( var lines_to_send = new Array(
this.proxy.complete_string_center(_t("Point of sale closed"), line_length), this.proxy.complete_string_center(_t("Point of sale closed"), line_length),
@ -86,21 +90,16 @@ openerp.pos_customer_display = function(instance){
module.ProxyDevice = module.ProxyDevice.extend({ module.ProxyDevice = module.ProxyDevice.extend({
send_text_customer_display: function(data, line_length){ send_text_customer_display: function(data, line_length){
//FIXME : this function is call twice. The first time, it is not called by prepare_text_customer_display : WHY ? //FIXME : this function is call twice. The first time, it is not called by prepare_text_customer_display : WHY ?
// alert("In sent_text_customer_display " + line_length);
if (data[0].length != line_length)
console.warn(data[0].length + " -> " + data[0]);
if (data[1].length != line_length)
console.warn(data[1].length + " ->" + data[1]);
if (data[0].length != line_length || data[1].length != line_length){
console.warn("Data components have to have " + line_length + " chars.");
console.log(data[0].length + " -> "+ data[0] + "\n" + data[1].length + " -> " + data[1]);
if (_.isEmpty(data) || data.lenght != 2 || data[0].length != line_length || data[1].length != line_length){
console.warn("Bad Data argument. Data = " + data);
console.warn('Line_length = ' + line_length);
} else { } else {
// alert(JSON.stringify(data)); // alert(JSON.stringify(data));
return this.message('send_text_customer_display', {'text_to_display' : JSON.stringify(data)}); return this.message('send_text_customer_display', {'text_to_display' : JSON.stringify(data)});
} }
return;
}, },
complete_string_right: function(string, length){ complete_string_right: function(string, length){
if (string) {
if (string.length > length) if (string.length > length)
{ {
return string.substring(0,length); return string.substring(0,length);
@ -111,9 +110,11 @@ openerp.pos_customer_display = function(instance){
string = string + ' '; string = string + ' ';
return string; return string;
} }
}
return string; return string;
}, },
complete_string_left: function(string, length){ complete_string_left: function(string, length){
if (string) {
if (string.length > length) if (string.length > length)
{ {
return string.substring(0,length); return string.substring(0,length);
@ -124,10 +125,11 @@ openerp.pos_customer_display = function(instance){
string = ' ' + string; string = ' ' + string;
return string; return string;
} }
}
return string; return string;
}, },
complete_string_center: function(string, length){ complete_string_center: function(string, length){
var self = this;
if (string) {
if (string.length > length) if (string.length > length)
{ {
return string.substring(0, length); return string.substring(0, length);
@ -141,18 +143,19 @@ openerp.pos_customer_display = function(instance){
string = string + ' '; string = string + ' ';
return string; return string;
} }
}
return string; return string;
}, },
}); });
//FIXME : nothing append on customer display deconnection
//FIXME : nothing happen on customer display deconnection
var _super_setSmartStatus_ = module.ProxyStatusWidget.prototype.set_smart_status; var _super_setSmartStatus_ = module.ProxyStatusWidget.prototype.set_smart_status;
module.ProxyStatusWidget.prototype.set_smart_status = function(status){ module.ProxyStatusWidget.prototype.set_smart_status = function(status){
_super_setSmartStatus_.call(this, status); _super_setSmartStatus_.call(this, status);
if (status.status === 'connected') { if (status.status === 'connected') {
var warning = false; var warning = false;
var msg = ''
var msg = '';
if (this.pos.config.iface_customer_display) { if (this.pos.config.iface_customer_display) {
var customer_display = status.drivers.customer_display ? status.drivers.customer_display.status : false; var customer_display = status.drivers.customer_display ? status.drivers.customer_display.status : false;
if (customer_display != 'connected' && customer_display != 'connecting') { if (customer_display != 'connected' && customer_display != 'connecting') {
@ -168,101 +171,53 @@ openerp.pos_customer_display = function(instance){
} }
}; };
var _super_addProduct_ = module.Order.prototype.addProduct; var _super_addProduct_ = module.Order.prototype.addProduct;
module.Order.prototype.addProduct = function(product, options){ module.Order.prototype.addProduct = function(product, options){
_super_addProduct_.call(this, product, options);
res = _super_addProduct_.call(this, product, options);
if (product) {
this.pos.prepare_text_customer_display('addProduct', {'product' : product, 'options' : options}); this.pos.prepare_text_customer_display('addProduct', {'product' : product, 'options' : options});
}
return res;
}; };
var _super_removeOrderline_ = module.Order.prototype.removeOrderline; var _super_removeOrderline_ = module.Order.prototype.removeOrderline;
module.Order.prototype.removeOrderline = function(line){ module.Order.prototype.removeOrderline = function(line){
if (line) {
this.pos.prepare_text_customer_display('removeOrderline', {'line' : line}); this.pos.prepare_text_customer_display('removeOrderline', {'line' : line});
_super_removeOrderline_.call(this, line);
}
return _super_removeOrderline_.call(this, line);
}; };
var _super_removePaymentline_ = module.Order.prototype.removePaymentline; var _super_removePaymentline_ = module.Order.prototype.removePaymentline;
module.Order.prototype.removePaymentline = function(line){ module.Order.prototype.removePaymentline = function(line){
if (line) {
this.pos.prepare_text_customer_display('removePaymentline', {'line' : line}); this.pos.prepare_text_customer_display('removePaymentline', {'line' : line});
_super_removePaymentline_.call(this, line);
}
return _super_removePaymentline_.call(this, line);
}; };
var _super_addPaymentline_ = module.Order.prototype.addPaymentline; var _super_addPaymentline_ = module.Order.prototype.addPaymentline;
module.Order.prototype.addPaymentline = function(cashregister){ module.Order.prototype.addPaymentline = function(cashregister){
_super_addPaymentline_.call(this, cashregister);
res = _super_addPaymentline_.call(this, cashregister);
if (cashregister) {
this.pos.prepare_text_customer_display('addPaymentline', {'cashregister' : cashregister}); this.pos.prepare_text_customer_display('addPaymentline', {'cashregister' : cashregister});
}
return res;
}; };
var _super_pushOrder_ = module.PosModel.prototype.push_order; var _super_pushOrder_ = module.PosModel.prototype.push_order;
module.PosModel.prototype.push_order = function(currentOrder){
_super_pushOrder_.call(this, currentOrder);
this.prepare_text_customer_display('pushOrder', {'currentOrder' : currentOrder});
module.PosModel.prototype.push_order = function(order){
res = _super_pushOrder_.call(this, order);
if (order) {
this.prepare_text_customer_display('pushOrder', {'order' : order});
}
return res;
}; };
var _super_closePOS_ = module.PosWidget.prototype.close; var _super_closePOS_ = module.PosWidget.prototype.close;
module.PosWidget.prototype.close = function(){ module.PosWidget.prototype.close = function(){
this.pos.prepare_text_customer_display('closePOS', {}); this.pos.prepare_text_customer_display('closePOS', {});
_super_closePOS_.call(this);
return _super_closePOS_.call(this);
}; };
/*
var _super_updatePayment_ = module.PaymentScreenWidget.prototype.update_payment_summary;
module.PaymentScreenWidget.prototype.update_payment_summary = function(){
_super_updatePayement_.call(this);
if( this.pos.config.iface_customer_display != true )
return;
var currentOrder = this.pos.get('selectedOrder');
var paidTotal = currentOrder.getPaidTotal();
var dueTotal = currentOrder.getTotalTaxIncluded();
var remaining = dueTotal > paidTotal ? dueTotal - paidTotal : 0;
var change = paidTotal > dueTotal ? paidTotal - dueTotal : 0;
var currency_rounding = Math.ceil(Math.log(1.0 / this.pos.currency.rounding) / Math.log(10));
var amount = line.get_amount().toFixed(currency_rounding);
var line_length = this.pos.config.customer_display_line_length || 20;
var data = new Array(
this.pos.proxy.complete_string_right(_t("Suppression paiement"), line_length),
this.pos.proxy.complete_string_right(line.cashregister.journal_id[1] , line_length - amount.length) + ' ' + amount
);
this.pos.proxy.send_text_customer_display(data);
};
*/
/*
module.Paymentline = module.Paymentline.extend({
set_pos: function(pos){
this.pos = pos;
},
});
module.PaypadButtonWidget = module.PaypadButtonWidget.extend({
renderElement: function() {
var self = this;
this._super();
this.$el.click(function(){
if (self.pos.get('selectedOrder').get('screen') === 'receipt'){ //TODO Why ?
console.warn('TODO should not get there...?');
return;
}
self.pos.get('selectedOrder').addPaymentline(self.cashregister);
console.log('aurel');
self.pos.get('selectedOrder').get('paymentLines').at(self.pos.get('selectedOrder').get('paymentLines').length -1).set_pos(self.pos);
console.log('aurel');
self.pos_widget.screen_selector.set_current_screen('payment');
});
},
});
var _super_setamountPaymentline_ = module.Paymentline.prototype.set_amount;
module.Paymentline.prototype.set_amount = function(amount){
_super_setamountPaymentline_.call(this, amount);
var data = _t("Add paymentline : ") + this.cashregister.journal_id[1] + " " + this.get_amount() + " " + this.pos.get('selectedOrder').getDueLeft();
alert(data);
this.pos.proxy.send_text_customer_display(data);
};
*/
}; };
Loading…
Cancel
Save