Browse Source

Cleaner inheritance implementation in pos_customer_display

Better debug logs in hw_* modules for LCD and Telium
pull/30/head
Alexis de Lattre 10 years ago
parent
commit
fcd8540c79
  1. 4
      hw_customer_display/controllers/main.py
  2. 5
      hw_telium_payment_terminal/controllers/main.py
  3. 55
      pos_customer_display/static/src/js/customer_display.js

4
hw_customer_display/controllers/main.py

@ -174,5 +174,7 @@ class CustomerDisplayProxy(hw_proxy.Proxy):
'/hw_proxy/send_text_customer_display', type='json', auth='none', '/hw_proxy/send_text_customer_display', type='json', auth='none',
cors='*') cors='*')
def send_text_customer_display(self, text_to_display): def send_text_customer_display(self, text_to_display):
logger.debug('LCD: Call send_text_customer_display')
logger.debug(
'LCD: Call send_text_customer_display with text=%s',
text_to_display)
driver.push_task('display', text_to_display) driver.push_task('display', text_to_display)

5
hw_telium_payment_terminal/controllers/main.py

@ -224,7 +224,6 @@ class TeliumPaymentTerminalDriver(Thread):
payment_info_dict = simplejson.loads(payment_info) payment_info_dict = simplejson.loads(payment_info)
assert isinstance(payment_info_dict, dict), \ assert isinstance(payment_info_dict, dict), \
'payment_info_dict should be a dict' 'payment_info_dict should be a dict'
logger.debug("payment_info_dict = %s" % payment_info_dict)
try: try:
logger.debug( logger.debug(
'Opening serial port %s for payment terminal with baudrate %d' 'Opening serial port %s for payment terminal with baudrate %d'
@ -280,5 +279,7 @@ class TeliumPaymentTerminalProxy(hw_proxy.Proxy):
'/hw_proxy/payment_terminal_transaction_start', '/hw_proxy/payment_terminal_transaction_start',
type='json', auth='none', cors='*') type='json', auth='none', cors='*')
def payment_terminal_transaction_start(self, payment_info): def payment_terminal_transaction_start(self, payment_info):
logger.debug('Telium: Call payment_terminal_transaction_start')
logger.debug(
'Telium: Call payment_terminal_transaction_start with '
'payment_info=%s', payment_info)
driver.push_task('transaction_start', payment_info) driver.push_task('transaction_start', payment_info)

55
pos_customer_display/static/src/js/customer_display.js

@ -199,9 +199,9 @@ openerp.pos_customer_display = function(instance){
return res; return res;
}; };
var _super_update_payment_summary_ = module.PaymentScreenWidget.prototype.update_payment_summary;
module.PaymentScreenWidget.prototype.update_payment_summary = function(){
res = _super_update_payment_summary_.call(this);
module.PaymentScreenWidget.include({
update_payment_summary: function(){
res = this._super();
var currentOrder = this.pos.get('selectedOrder'); var currentOrder = this.pos.get('selectedOrder');
var paidTotal = currentOrder.getPaidTotal(); var paidTotal = currentOrder.getPaidTotal();
var dueTotal = currentOrder.getTotalTaxIncluded(); var dueTotal = currentOrder.getTotalTaxIncluded();
@ -211,39 +211,40 @@ openerp.pos_customer_display = function(instance){
this.pos.prepare_text_customer_display('update_payment', {'change': change_rounded}); this.pos.prepare_text_customer_display('update_payment', {'change': change_rounded});
} }
return res; return res;
};
},
});
var _super_closePOS_ = module.PosWidget.prototype.close;
module.PosWidget.prototype.close = function(){
module.PosWidget.include({
close: function(){
this._super();
this.pos.prepare_text_customer_display('closePOS', {}); this.pos.prepare_text_customer_display('closePOS', {});
return _super_closePOS_.call(this);
};
},
});
var _super_proxy_start_ = module.ProxyStatusWidget.prototype.start;
module.ProxyStatusWidget.prototype.start = function(){
res = _super_proxy_start_.call(this);
module.ProxyStatusWidget.include({
start: function(){
this._super();
this.pos.prepare_text_customer_display('openPOS', {}); this.pos.prepare_text_customer_display('openPOS', {});
return res;
};
},
});
/* Handle Button "Display Total to Customer" */ /* Handle Button "Display Total to Customer" */
var _super_OrderWidget_init_ = module.OrderWidget.prototype.init;
module.OrderWidget.prototype.init = function(parent, options){
_super_OrderWidget_init_.call(this, parent, options);
/* TODO: understand why Odoo sends the prepare_text_customer_display
3 times to the Posbox/LCD when the user clicks on the button
'Show total to customer' */
module.OrderWidget.include({
update_summary: function(){
console.log('MY update_summary');
this._super();
var self = this; var self = this;
this.prepare_text_customer_display = function(event){
self.pos.prepare_text_customer_display('addPaymentline', {});
event.stopPropagation();
};
};
var _super_update_summary_ = module.OrderWidget.prototype.update_summary;
module.OrderWidget.prototype.update_summary = function(){
_super_update_summary_.call(this);
if (this.pos.config.iface_customer_display){ if (this.pos.config.iface_customer_display){
console.log('.addEventListener');
this.el.querySelector('.show-total-to-customer') this.el.querySelector('.show-total-to-customer')
.addEventListener('click', this.prepare_text_customer_display);
.removeEventListener('click', function(){self.pos.prepare_text_customer_display('addPaymentline', {})});
this.el.querySelector('.show-total-to-customer')
.addEventListener('click', function(){self.pos.prepare_text_customer_display('addPaymentline', {})});
} }
};
},
});
}; };
Loading…
Cancel
Save