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

Hi everyone,

I’m currently modifying the Odoo HR Attendance Kiosk app’s JavaScript codebase to extend its functionality. Specifically, I’m patching the kiosk app to log additional details during barcode scanning. I’d appreciate any guidance or another example solution.

This is my error:
The following modules failed to load because of an error, you may find more information in the devtools console:

  • @HR_Attendance_Geolocation/js/custom_kiosk_app



partial-manifest:
'depends': ['hr_attendance'],

   

    'assets': {

        'web.assets_backend': [

            'HR_Attendance_Geolocation/static/src/js/custom_kiosk_app.js',

        ],

    },

    'data': [

        #'views/assets.xml',

    ],

<?xml version="1.0" encoding="UTF-8"?>

<odoo>

    <template id="assets_backend" inherit_id="web.assets_backend" name="Custom Kiosk Attendance Assets">

        <xpath expr="." position="inside">

            <script type="module" src="/HR_Attendance_Geolocation/static/src/js/custom_kiosk_app.js"></script>

        </xpath>

    </template>

</odoo>

JS:

import { kioskAttendanceApp } from "@hr_attendance/public_kiosk/public_kiosk_app";

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

patch(kioskAttendanceApp.prototype, "custom_kiosk_app", {

    async onBarcodeScanned(barcode) {

        console.log("Custom log: Barcode scanned:", barcode);


        if (this.lockScanner || this.state.active_display !== 'main') {

            return;

        }

        this.lockScanner = true;


        const result = await this.rpc('attendance_barcode_scanned', {

            'barcode': barcode,

            'token': this.props.token

        });


        if (result && result.employee_name) {

            this.employeeData = result;

            this.switchDisplay('greet');

        } else {

            this.displayNotification(

                _t("No employee corresponding to Badge ID '%(barcode)s.'", { barcode })

            );

        }

        this.lockScanner = false;

        console.log("Custom log: Barcode processing completed.");

    },

});



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

Can you share with us what is written in the devtools console?

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

Of course
Uncaught Error: Error while loading
web.assets_web.min.js:11
"@HR_Attendance_Geolocation/js/custom_kiosk_app":
TypeError: Cannot read properties of undefined (reading 'prototype')
at ModuleLoader.startModule (web.assets web.min.js:11:213)
at ModuleLoader.startModules (web.assets web.min.js: 10:57)
at ModuleLoader.addJob (web.assets web.min.js:7:39)
at ModuleLoader.define (web.assets web.min.js:6:141)
web.assets web.min.js:15602:6

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يونيو 25
95
0
أبريل 25
440
Odoo icon change تم الحل
2
يناير 25
875
2
نوفمبر 24
2211
1
نوفمبر 23
2632