[IMP] pos_online_payment_self_order, pos_self_order: change order_widget

In this commit, we change the way the order_widget acts. Now, if we are
in mobile with pay after meal, the order_widget will show 'To Order'
instead of 'To Pay' when clicking on 'Order Now' for a second time
and the order button will be disable until a new line is added. To see
what is already sent to the waiters, we can click on the 'My Order'
button in the landing page which will display the cart.

Part-of: odoo/odoo#139187
This commit is contained in:
Adrien Guilliams (adgu)
2023-10-19 18:02:17 +00:00
parent bc63c53f07
commit 5ffe019b43
3 changed files with 5 additions and 11 deletions
@@ -41,13 +41,14 @@ export class OrderWidget extends Component {
const payAfter = this.selfOrder.config.self_ordering_pay_after;
const kioskPayment = this.selfOrder.pos_payment_methods;
const isNoLine = this.selfOrder.currentOrder.lines.length === 0;
const hasNotAllLinesSent = this.selfOrder.currentOrder.hasNotAllLinesSent();
let label = "";
let disabled = false;
if (currentPage === "product_list") {
label = _t("Order");
disabled = isNoLine;
disabled = isNoLine || hasNotAllLinesSent.length == 0;
} else if (payAfter === "meal" && !this.selfOrder.currentOrder.isSavedOnServer) {
label = _t("Order");
disabled = isNoLine;
@@ -61,15 +62,8 @@ export class OrderWidget extends Component {
get lineNotSend() {
const order = this.selfOrder.currentOrder;
if (order.isSavedOnServer) {
return {
price: order.amount_total,
count: order.totalQuantity,
};
}
const lineNotSend = order.hasNotAllLinesSent();
return lineNotSend.reduce(
(acc, line) => {
const currentQty = line.qty;
@@ -12,8 +12,7 @@
<button t-attf-class="btn btn-secondary btn-lg d-none d-sm-inline text-nowrap" t-on-click="onClickleftButton" t-esc="leftButton.name" />
<div class="d-flex align-items-center flex-grow-1 w-100 w-md-auto">
<div class="to-order">
<span t-if="!this.selfOrder.currentOrder.isSavedOnServer">To Order</span>
<span t-else="">To Pay</span>
<span>To Order</span>
<div class="d-flex align-items-center">
<span class="o-so-tabular-nums badge text-bg-secondary rounded" t-esc="lineNotSend.count"/>
<span class="o-so-tabular-nums mx-2" t-if="selfOrder.currentOrder.lines.length" t-esc="selfOrder.formatMonetary(lineNotSend.price)" />
@@ -52,6 +52,7 @@ export class CartPage extends Component {
const type = this.selfOrder.config.self_ordering_mode;
const takeAway = this.selfOrder.currentOrder.take_away;
const mode = this.selfOrder.config.self_ordering_pay_after;
const isOnlinePayment = this.selfOrder.pos_payment_methods.find((p) => p.is_online_payment);
const order = this.selfOrder.currentOrder;
const isPaymentMethod = this.selfOrder.pos_payment_methods.length > 0;