[FIX] point_of_sale: do not allow validation of empty order with no payments

closes odoo/odoo#76517

X-original-commit: 1207d3737f8b36159acc8c92fd841b3b56d1f730
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
Joseph Caburnay
2021-09-15 09:02:06 +00:00
parent 85500f5a07
commit f4c46694f5
2 changed files with 16 additions and 2 deletions
@@ -145,6 +145,18 @@ odoo.define('point_of_sale.PaymentScreen', function (require) {
NumberBuffer.reset();
this.render();
}
/**
* Returns false if the current order is empty and has no payments.
* @returns {boolean}
*/
_isValidEmptyOrder() {
const order = this.currentOrder;
if (order.get_orderlines().length == 0) {
return order.get_paymentlines().length != 0;
} else {
return true;
}
}
async validateOrder(isForceValidate) {
if(this.env.pos.config.cash_rounding) {
if(!this.env.pos.get_order().check_paymentlines_rounding()) {
@@ -349,6 +361,8 @@ odoo.define('point_of_sale.PaymentScreen', function (require) {
return false;
}
if (!this._isValidEmptyOrder()) return false;
return true;
}
async _postPushOrderResolve(order, order_server_ids) {
@@ -12,7 +12,7 @@
<span class="back_text">Back</span>
</div>
<div class="top-content-center"><h1>Payment</h1></div>
<div class="button next" t-att-class="{ highlight: currentOrder.is_paid() }"
<div class="button next" t-att-class="{ highlight: currentOrder.is_paid() and _isValidEmptyOrder() }"
t-on-click="validateOrder(false)">
<span class="next_text">Validate</span>
<i class="fa fa-angle-double-right fa-fw"></i>
@@ -89,7 +89,7 @@
</div>
<t t-if="env.isMobile">
<div class="switchpane">
<button class="btn-switchpane" t-att-class="{ secondary: !currentOrder.is_paid() }" t-on-click="validateOrder(false)">
<button class="btn-switchpane" t-att-class="{ secondary: !(currentOrder.is_paid() and _isValidEmptyOrder()) }" t-on-click="validateOrder(false)">
<h1>Validate</h1>
</button>
<button class="btn-switchpane secondary" t-on-click="showScreen('ProductScreen', {mobile_pane: 'left'})">