From 94a4072d45513a65f34dcd6eacf38902938808c1 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Mon, 15 Jun 2026 11:26:42 +0700 Subject: [PATCH] refactor: move closing receipt printing to occur after successful server session closure --- static/src/app/closing_receipt_patch.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/static/src/app/closing_receipt_patch.js b/static/src/app/closing_receipt_patch.js index 7613b74..9292163 100644 --- a/static/src/app/closing_receipt_patch.js +++ b/static/src/app/closing_receipt_patch.js @@ -154,15 +154,6 @@ patch(ClosePosPopup.prototype, { .filter((pm) => pm.type === "bank") .map((pm) => [pm.id, this.getDifference(pm.id)]); - // ── Print BEFORE closing session on server ─────────────────────── - // IMPORTANT: Must print here while IndexedDB is still fully open. - // After close_session_from_ui responds, the Odoo bus/sync detects - // the session state change and begins IDB teardown. Any OWL render - // or Logger.log call after that point throws: - // InvalidStateError: Failed to execute 'transaction' on - // 'IDBDatabase': The database connection is closing. - await this._printClosingReceipt(receiptData); - const response = await this.pos.data.call( "pos.session", "close_session_from_ui", @@ -178,6 +169,9 @@ patch(ClosePosPopup.prototype, { return this.handleClosingError(response); } + // ── Print AFTER closing session on server ──────────────────────── + await this._printClosingReceipt(receiptData); + // Mark session closed locally this.pos.session.state = "closed";