Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2191 Zobrazení

hi every one in odoo 16 I working on module to update the BarcodeModel in stock_barcode addon so I found this JavaScript file in odoo stock_barcode addon and I want to make extension from this class

/** @odoo-module **/

import BarcodeParser from 'barcodes.BarcodeParser';
import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { Mutex } from "@web/core/utils/concurrency";
import LazyBarcodeCache from '@stock_barcode/lazy_barcode_cache';
import { _t } from 'web.core';
import { sprintf } from '@web/core/utils/strings';
import { useService } from "@web/core/utils/hooks";

const { EventBus } = owl;

export default class BarcodeModel extends EventBus {
    constructor(params, services) {
        super();
    }
       
    //code here 

    async _processBarcode(barcode) {
        //code here 
    }
}

I want to make extent ion from this class in my module and make overwide the method _processBarcode to make changes on it

can any one help me.


Avatar
Zrušit
Nejlepší odpověď

Hi,


To extend the BarcodeModel and override the _processBarcode function, use the code below.


/** @odoo-module **/

import BarcodeModel from '@stock_barcode/models/barcode_model';


export default class CustomBarcodePickingModel extends BarcodeModel {

    constructor(params) {

        super(...arguments);

    }


    // Override the _processBarcode method

    async _processBarcode(barcode) {

        // Your custom logic here


        // Call the original method from the superclass if needed

        const result = await super._processBarcode(barcode);


        // Your additional custom logic here


        // Return the result (if needed)

        return result;

    }

}


Hope it helps

Avatar
Zrušit
Autor

Unfortunately, it did not work, although it is logical that it should work, but it seems that there is a missing step because I added to your code this line

console.log('_processBarcode test =====>')

In order to make sure that it works, but when I use the barcode reader, it does not seem to me that the code is working
Are there any steps missing??

Related Posts Odpovědi Zobrazení Aktivita
0
dub 25
1253
1
zář 24
1280
1
srp 24
1210
0
led 25
930
1
lis 24
1511