Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Discuss
    • Kecerdasan Buatan
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Manajemen Properti
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Konsultasi
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Custom PLU Weight Barcode Parsing Not Working in Odoo 18 POS JS Patch

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
javascriptposbarcode
1 Balas
458 Tampilan
Avatar
Ashilkrishna

Hi everyone,

I am trying to implement custom PLU barcode parsing in Odoo 18 POS using JavaScript patching, but it is not working.

My goal:

  • Barcode format: 0PPPPWWWWW

  • First 5 digits → product barcode

  • Last 5 digits → weight in grams

my code:

{
'name': 'POS PLU Barcode Parser',
'version': '18.0.1.0.0',
'category': 'Point of Sale',
'summary': 'Adds support for parsing weight from PLU barcodes in the Point of Sale.',
'depends': ['point_of_sale'],
'assets': {
'point_of_sale._assets_pos': [
'zl_product_plu_barcode/static/src/js/plu_barcode_parser.js',
],
},
'installable': True,
'auto_install': False,
'license': 'LGPL-3',
}
/** @odoo-module **/

import { patch } from "@web/core/utils/patch";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import { _t } from "@web/core/l10n/translation";

patch(ProductScreen.prototype, {
/**
* This is the correct function to override for Odoo 18.
* The useBarcodeReader hook in ProductScreen directs product-related scans to this method.
*/

async _barcodeProductAction(code) {
const barcode = code.code;

// Our custom logic for weight-embedded barcodes
if (barcode && barcode.length === 10 && barcode.startsWith('0') && /^\d+$/.test(barcode)) {
const product_barcode = barcode.substring(0, 5).replace(/^0+/, '');
const weight = parseFloat(barcode.substring(5)) / 1000.0;

// Create a mock code object for the product search
const productCode = { code: product_barcode, type: 'product' };
const product = await this._getProductByBarcode(productCode);

if (product) {
// Product found. Call the same function as the original method,
// but inject our custom quantity into the options object.
await this.pos.addLineToCurrentOrder(
{ product_id: product },
{ code, quantity: weight }, // Pass original code and new quantity
product.needToConfigure()
);
this.numberBuffer.reset(); // Reset buffer like the original function
return; // Stop further processing
} else {
// Product not found, show a notification.
this.pos.env.services.notification.add(
_t("Product with barcode '%s' not found.", product_barcode),
{ type: 'danger' }
);
return;
}
}

// If it's not our custom weight barcode, fall back to the original Odoo method.
return await super._barcodeProductAction(code);
}
});

The module installs successfully, but barcode scanning does not trigger my custom logic.

Any help would be greatly appreciated.

Thank you.

0
Avatar
Buang
Avatar
Vivek Kundaliya
Jawaban Terbai

The issue is that in Odoo 18, the POS barcode scanning architecture was refactored. The _barcodeProductAction method may not be the correct hook to override.\n\nHere are the key fixes:\n\n1. Check the correct method to patch. In Odoo 18 POS, barcode scanning goes through the BarcodeReader service, not directly through ProductScreen. Check the Odoo 18 source at point_of_sale/static/src/app/barcode/barcode_reader.js to find the method that processes product barcodes. The method name may have changed from Odoo 17.\n\n2. Verify your patch is being applied by adding a console.log at the top of your patched method. If the log never appears, your patch target is wrong.\n\n3. Recommended alternative: use Odoo's built-in Barcode Nomenclature. This is the native Odoo way and requires zero JavaScript:\n- Go to Inventory > Configuration > Barcode Nomenclatures\n- Add a rule with Type = Weighted Product and configure the pattern to match your 0PPPPWWWWW format\n- Odoo will automatically parse the product code and weight from the barcode\n\nThe barcode nomenclature approach is strongly recommended as it requires no custom code, works with standard Odoo, and survives version upgrades without breaking.

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Odoo 19 POS Pay Later – Need Review of Custom Implementation
javascript pos
Avatar
0
Mei 26
776
I am customizing the POS receipt in Odoo 19.
javascript pos
Avatar
0
Mei 26
785
Can anyone correct my code-iam coustmizing odoo 19 defualt pos reciept Diselesaikan
javascript pos
Avatar
Avatar
1
Mei 26
1219
Odoo 19 POS Receipt Customization – Remove Default Unit Price and Show Custom MRP Line
javascript pos
Avatar
1
Mei 26
893
Barcode scanning on POS Diselesaikan
pos barcode
Avatar
Avatar
Avatar
2
Okt 25
12751
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Karir
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo adalah software terintegrasi dengan 70+ aplikasi seperti CRM, Akuntansi, Inventaris, Sales, eCommerce, Marketing, POS; plus fitur lokal Indonesia!

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now