From 5f27d2662cf91cbc671d592b67e74b528fc2095c Mon Sep 17 00:00:00 2001 From: andreparames Date: Thu, 3 May 2018 15:21:59 +0200 Subject: [PATCH] pos_payment_terminal: auto-validate orders with mixed payments --- .../static/src/js/pos_payment_terminal.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pos_payment_terminal/static/src/js/pos_payment_terminal.js b/pos_payment_terminal/static/src/js/pos_payment_terminal.js index ef30340f..00f84b01 100755 --- a/pos_payment_terminal/static/src/js/pos_payment_terminal.js +++ b/pos_payment_terminal/static/src/js/pos_payment_terminal.js @@ -38,16 +38,13 @@ odoo.define('pos_payment_terminal.pos_payment_terminal', function (require) { var transactions = drivers[driver_name].latest_transactions; if(!!transactions && transactions.hasOwnProperty(order.uid)) { + var previous_transactions = order.transactions; order.transactions = transactions[order.uid]; - - var order_total = Math.round(order.get_total_with_tax() * 100.0); - var paid_total = order.transactions.map(function(t) { - return t.amount_cents; - }).reduce(function add(a, b) { - return a + b; - }, 0); - - if(order_total === paid_total) { + var has_new_transactions = ( + !previous_transactions || + previous_transactions.length < order.transactions.length + ); + if(has_new_transactions && order.is_paid()) { paymentwidget.validate_order(); } }