تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
2287 أدوات العرض

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.


الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
الكاتب

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أبريل 25
1308
1
سبتمبر 24
1342
1
أغسطس 24
1267
0
يناير 25
972
1
نوفمبر 24
1596