From a0d14e21472f3bf9a5f20a24e6a7a1c98b17853e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 22 Jun 2015 12:18:16 +0200 Subject: [PATCH] FIX when clicking on "Display Total to Customer", the query is now sent only once to the POSbox Patch written with the kind help of Sylvain Calador --- .../static/src/js/customer_display.js | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/pos_customer_display/static/src/js/customer_display.js b/pos_customer_display/static/src/js/customer_display.js index 2f245d4f..6ff84574 100755 --- a/pos_customer_display/static/src/js/customer_display.js +++ b/pos_customer_display/static/src/js/customer_display.js @@ -241,20 +241,16 @@ openerp.pos_customer_display = function(instance){ }); /* Handle Button "Display Total to Customer" */ - /* 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(){ - this._super(); - var self = this; - if (this.pos.config.iface_customer_display){ - this.el.querySelector('.show-total-to-customer') - .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', {})}); - } - }, - }); + var _saved_renderElement = module.OrderWidget.prototype.renderElement; + module.OrderWidget.prototype.renderElement = function() { + _saved_renderElement.apply(this, arguments); + var self = this; + if (self.pos.config.iface_customer_display) { + self.el.querySelector('.show-total-to-customer') + .addEventListener('click', function(){ + self.pos.prepare_text_customer_display('addPaymentline', {}) + }); + } + }; };