From d44defdba11e7c6df1e9abdd21b4ffcbd59e9f0c Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Mon, 15 Jun 2026 10:49:57 +0700 Subject: [PATCH] first commit --- .gitignore | 2 ++ README.md | 7 +++++++ __init__.py | 1 + __manifest__.py | 22 +++++++++++++++++++++ static/src/app/services/pos_store_patch.js | 23 ++++++++++++++++++++++ 5 files changed, 55 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 __init__.py create mode 100644 __manifest__.py create mode 100644 static/src/app/services/pos_store_patch.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d646835 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +__pycache__/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..152fd56 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# POS Sync Before Print + +Ensure POS receipts are only printed after the order is successfully synced with the server. + +## Description + +This module patches the Point of Sale printReceipt method to check the synchronization state of the order. If the order has not been synchronized with the server yet, printing is blocked. During offline validation, the order validation proceeds normally but the receipt is not printed automatically, and a warning is shown if printing manually. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..40a96af --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..09f2db9 --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +{ + 'name': 'POS Sync Before Print', + 'version': '19.0.1.0.0', + 'summary': 'Ensure POS receipts are only printed after the order is successfully synced with the server.', + 'description': """ +Ensure POS receipts are only printed after the order is successfully synced with the server. +If an order is not synced, the receipt will not be printed automatically, and manual printing will show a warning popup. + """, + 'author': 'Suherdy Yacob', + 'category': 'Point of Sale', + 'depends': ['point_of_sale'], + 'data': [], + 'assets': { + 'point_of_sale._assets_pos': [ + 'pos_sync_before_print/static/src/app/services/pos_store_patch.js', + ], + }, + 'installable': True, + 'auto_install': False, + 'license': 'LGPL-3', +} diff --git a/static/src/app/services/pos_store_patch.js b/static/src/app/services/pos_store_patch.js new file mode 100644 index 0000000..efca80f --- /dev/null +++ b/static/src/app/services/pos_store_patch.js @@ -0,0 +1,23 @@ +/** @odoo-module **/ + +import { patch } from "@web/core/utils/patch"; +import { PosStore } from "@point_of_sale/app/services/pos_store"; +import { _t } from "@web/core/l10n/translation"; +import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; + +patch(PosStore.prototype, { + async printReceipt(options = {}) { + const order = options.order || this.getOrder(); + if (order && !order.isSynced && !options.printBillActionTriggered) { + this.dialog.add(AlertDialog, { + title: _t("Unsynced Order"), + body: _t( + "This order has not been synchronized with the server yet. " + + "Please wait for the server synchronization to complete before printing the receipt." + ), + }); + return false; + } + return super.printReceipt(...arguments); + } +});