Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

Error in OWL constructor inherit from stock_barcode module

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
inheritanceowlOWLodoo17
1 Antworten
2422 Ansichten
Avatar
Alma Mena

Hello everyone!
i need help! i am trying to inherit a constructor from the file lazy_barcode_cache.js and Is not working, I tried with patch but nothing happends. 

export default class LazyBarcodeCache {

    constructor(cacheData, params) {

        this.rpc = params.rpc;

        this.dbIdCache = {}; // Cache by model + id

        this.dbBarcodeCache = {}; // Cache by model + barcode

        this.missingBarcode = new Set(); // Used as a cache by `_getMissingRecord`

        this.barcodeFieldByModel = {

            'stock.location': 'barcode',

            'product.product': 'barcode',

            'product.packaging': 'barcode',

            'stock.package.type': 'barcode',

            'stock.picking': 'name',

            'stock.quant.package': 'name',

            'stock.lot': 'name', // Also ref, should take in account multiple fields ?

        };

        this.gs1LengthsByModel = {

            'product.product': 14,

            'product.packaging': 14,

            'stock.location': 13,

            'stock.quant.package': 18,

        };

        // If there is only one active barcode nomenclature, set the cache to be compliant with it.

        if (cacheData['barcode.nomenclature'].length === 1) {

            this.nomenclature = cacheData['barcode.nomenclature'][0];

        }

        this.setCache(cacheData);

    }


thats the one i need to inherit, and the only change i need to do is change this:
"

            'stock.lot': 'name', 


to :

            'stock.lot': 'barcode_lot',

if somebody could help i will be super grateful. 

Greetings! 

0
Avatar
Verwerfen
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Beste Antwort

Hi,

Try this

 /** @odoo-module **/


import LazyBarcodeCache from '@stock_barcode/lazy_barcode_cache';


import { patch } from "@web/core/utils/patch";


patch(LazyBarcodeCache.prototype, {

    /**

     * @override

     */

     _constructor() {

        super._constructor(...arguments);

    },

});


Add the file in the correct asset bundle.

'assets': {

        'web.assets_backend': [

             "Add your file"

        ],

    },


Hope it helps

0
Avatar
Verwerfen
Alma Mena
Autor

Hello!
I tried that before and didnt work... Later on I read this in the odoo's documentation

"Also, Javascript handles the constructor in a special native way which makes it impossible to be patched. The only workaround is to call a method in the original constructor and patch that method instead:"

So after trying and trying haha later I found this that worked:
/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import LazyBarcodeCache from "@stock_barcode/lazy_barcode_cache";

const originalSetCache = LazyBarcodeCache.prototype.setCache;

// Aplica el parche al prototipo de la clase LazyBarcodeCache
patch(LazyBarcodeCache.prototype, {
setCache(cacheData) {
// Llama al método original usando la referencia guardada
originalSetCache.call(this, cacheData);

// Modifica barcodeFieldByModel después de la inicialización
if (this.barcodeFieldByModel) {
this.barcodeFieldByModel['stock.lot'] = 'barcode_lot';
} else {
console.error("barcodeFieldByModel is undefined.");
}
},
});

I actually call the setCache first with the original argument (cacheData) that contains "barcodeFieldByModel" to changed it after de initialization and it worked pretty well.

Thank you so much for the answer,
greetings!

Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
Custom code: Can clicking on a Task with Subtasks (in Kanban View) open another Kanban with the Subtasks? Gelöst
owl OWL
Avatar
Avatar
Avatar
2
Juli 25
1923
How can I listen to the onFieldChange event in Odoo 17 using JavaScript?
javascript selected owl OWL odoo17
Avatar
0
März 25
1666
Default button inheritance
inheritance odoo17
Avatar
Avatar
1
Sept. 24
1824
OWL Cannot resolve symbol 'Component' 
owl odoo17
Avatar
Avatar
1
Juli 24
2914
Alter existing owl app
owl OWL
Avatar
Avatar
1
März 24
2261
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Ausbildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ภาษาไทย Türkçe українська Tiếng Việt

Odoo ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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