From 6107e079719de2de4a1054b65661be765baefda5 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Tue, 7 Jun 2022 14:31:46 +0000 Subject: [PATCH] [IMP] point_of_sale: automatically validate the order if fully-paid Only when the total payment is exactly the order's total price. closes odoo/odoo#93694 Related: odoo/enterprise#28433 Signed-off-by: Masereel Pierre --- .../static/src/js/Screens/PaymentScreen/PaymentScreen.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js index 97544d76154..535f6072ee5 100644 --- a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js @@ -8,6 +8,7 @@ odoo.define('point_of_sale.PaymentScreen', function (require) { const { useListener } = require("@web/core/utils/hooks"); const Registries = require('point_of_sale.Registries'); const { isConnectionError } = require('point_of_sale.utils'); + const utils = require('web.utils'); class PaymentScreen extends PosComponent { setup() { @@ -383,6 +384,14 @@ odoo.define('point_of_sale.PaymentScreen', function (require) { if (isPaymentSuccessful) { line.set_payment_status('done'); line.can_be_reversed = payment_terminal.supports_reversals; + // Automatically validate the order when after an electronic payment, + // the current order is fully paid and due is zero. + if ( + this.currentOrder.is_paid() && + utils.float_is_zero(this.currentOrder.get_due(), this.env.pos.currency.decimal_places) + ) { + this.trigger('validate-order'); + } } else { line.set_payment_status('retry'); }