Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
2212 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

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??

Post Terkait Replies Tampilan Aktivitas
0
Apr 25
1259
1
Sep 24
1289
1
Agu 24
1218
0
Jan 25
941
1
Nov 24
1523