[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 <pim@odoo.com>
This commit is contained in:
Joseph Caburnay
2022-07-21 09:15:46 +02:00
parent 96c2716674
commit 6107e07971
@@ -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');
}