Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Intelligence artificielle
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Supermarché
    • Quincaillerie
    • Magasin de jouets
    Restauration & Hôtellerie
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Homme à tout faire
    • Matériel informatique & support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Parcourir toutes les industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenir partenaire
    • Services pour partenaires
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

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

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
javascriptposbarcode
1 Répondre
561 Vues
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
Ignorer
Avatar
Vivek Kundaliya
Meilleure réponse

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
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Odoo 19 POS Pay Later – Need Review of Custom Implementation
javascript pos
Avatar
0
mai 26
919
I am customizing the POS receipt in Odoo 19.
javascript pos
Avatar
0
mai 26
947
Can anyone correct my code-iam coustmizing odoo 19 defualt pos reciept Résolu
javascript pos
Avatar
Avatar
1
mai 26
1317
Odoo 19 POS Receipt Customization – Remove Default Unit Price and Show Custom MRP Line
javascript pos
Avatar
1
mai 26
1022
Barcode scanning on POS Résolu
pos barcode
Avatar
Avatar
Avatar
2
oct. 25
12824
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenir partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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