summaryrefslogtreecommitdiff
path: root/indoteknik_custom/static/src/js
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-08-20 13:57:18 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-08-20 13:57:18 +0700
commit930af568605dd2b0695bc76282f3164b885f3126 (patch)
tree8f6e14f3e51378daa66f0fa9f23c32a758b15d46 /indoteknik_custom/static/src/js
parentcaaef86e4c60f026a2b2b7abcad355f2d18366c3 (diff)
parent6adef807baa548aa132418d80e21b04cd5e21a68 (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into reminder-tempo-v2
Diffstat (limited to 'indoteknik_custom/static/src/js')
-rw-r--r--indoteknik_custom/static/src/js/check_product_barcode.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/indoteknik_custom/static/src/js/check_product_barcode.js b/indoteknik_custom/static/src/js/check_product_barcode.js
new file mode 100644
index 00000000..f7a1bb75
--- /dev/null
+++ b/indoteknik_custom/static/src/js/check_product_barcode.js
@@ -0,0 +1,41 @@
+odoo.define('indoteknik_custom.prevent_manual_typing', function (require) {
+ "use strict";
+
+ console.log("✅ Custom JS from indoteknik_custom loaded!");
+
+
+ const THRESHOLD_MS = 40; // jeda antar karakter dianggap scanner kalau <40ms
+ let lastTime = 0;
+ let burstCount = 0;
+
+ function isScannerLike(now) {
+ const gap = now - lastTime;
+ lastTime = now;
+ if (gap < THRESHOLD_MS) {
+ burstCount += 1;
+ } else {
+ burstCount = 1;
+ }
+ return burstCount >= 3; // setelah 3 char cepat, dianggap scanner
+ }
+
+ document.addEventListener('keydown', function (e) {
+ const t = e.target;
+ if (!(t instanceof HTMLInputElement)) return;
+
+ // pastikan hanya field code_product
+ if (t.name !== 'code_product') return;
+
+ const now = performance.now();
+ const scanner = isScannerLike(now);
+
+ // enter tetap boleh (scanner biasanya akhiri Enter)
+ if (e.key === "Enter") return;
+
+ // kalau bukan scanner → blok manual ketikan
+ if (!scanner) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ }, true);
+});