/** @odoo-module
 *
 * TicketScreen patch — gate double-click-to-resume-order through the
 * settle-due exit confirmation so cashiers can't silently abandon a
 * live settle-due order from the ticket list.
 *
 * Single-click (onClickOrder) only updates the ticket-list selection
 * and does NOT change the active POS order, so it's safe to leave
 * untouched. Double-click calls pos.setOrder — our patched setOrder
 * also enforces the gate, but doing it here too avoids the flicker
 * of partially-switching before the async confirm resolves.
 */
import { patch } from "@web/core/utils/patch";
import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen";

patch(TicketScreen.prototype, {
    async onDblClickOrder(order) {
        if (!order?.finalized) {
            const allowed = await this.pos.confirmExitSettleIfNeeded(order);
            if (!allowed) {
                return;
            }
        }
        return super.onDblClickOrder(order);
    },
});
