Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
128 Tampilan

I keep getting this in odoo 18 POS screen ( in the console F12) , point_of_sale.assets_prod.min.js:24 The following modules are needed by other modules but have not been defined, they may not be present in the correct asset bundle: ['@point_of_sale/app/store/pos_global_state']

reportErrors @ point_of_sale.assets_prod.min.js:24

(anonymous) @ point_of_sale.assets_prod.min.js:10

Promise.then

define @ point_of_sale.assets_prod.min.js:10

(anonymous) @ point_of_sale.assets_prod.min.js:1656Understand this error

point_of_sale.assets_prod.min.js:26 The following modules could not be loaded because they have unmet dependencies, this is a secondary error which is likely caused by one of the above problems: ['@psms/js/pos_data_loader']  


 My  pos_data_loader.js  is as follows; 


/** @odoo-module **/


import { PosGlobalState } from "@point_of_sale/app/store/pos_global_state";

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



console.log("🚀 PSMS: Extending POS data models with nozzle_ids, pump_ids, tanks_ids");


// ✅ Patch the global state to add nozzle/pump/tank info from backend

patch(PosGlobalState.prototype, {

    async _loadData() {

        console.log("🟣 PSMS: pos_data_loader.js running...");


        // Load default data first

        await super._loadData();


        // ORM service reference

        const orm = this.env.services.orm;

        if (!orm) {

            console.error("❌ PSMS: ORM service unavailable");

            return;

        }


        // Fetch POS Config records, ensuring core fields like display_stock are included

        const configs = await orm.searchRead("pos.config", [], [

            "id",

            "name",

            "display_stock", // <-- ADDED: Fixes the 'display_stock' TypeError

            "nozzle_ids",

            "pump_ids",

            "tanks_ids",

        ]);


        // Identify current POS Config

        const currentSession = this.pos_session;

        const currentConfigId = currentSession?.config_id?.[0];


        console.log("🧭 POS SESSION:", currentSession);

        console.log("🧭 POS CONFIG ID:", currentConfigId);


        const currentConfig = configs.find(c => c.id === currentConfigId);

        if (!currentConfig) {

            console.warn("⚠️ PSMS : No matching pos.config found for session", currentConfigId);

            return;

        }


        // ✅ Extend pos_config by assigning custom and core fields fetched from DB

        // NOTE: Direct assignment prevents unintentional loss of other core properties

        this.pos_config.display_stock = currentConfig.display_stock; // <-- ASSIGNED: Ensure core logic has this value

        this.pos_config.nozzle_ids = currentConfig.nozzle_ids || [];

        this.pos_config.pump_ids = currentConfig.pump_ids || [];

        this.pos_config.tanks_ids = currentConfig.tanks_ids || [];

        console.log("🧭 POS CONFIG", this.pos_config);

        // debugger; // Removed debugger for cleaner run


        // ✅ Load Nozzle Data

        if (currentConfig.nozzle_ids.length) {

            const nozzles = await orm.searchRead("petrol.nozzle", [

                ["id", "in", currentConfig.nozzle_ids],

            ], [

                "id",

                "name",

                "pump_id",

                "tank_id",

                "product_id",

            ]);


            this.db.nozzle_by_id = {};

            for (const nozzle of nozzles) {

                this.db.nozzle_by_id[nozzle.id] = nozzle;

            }


            console.log(`✅ PSMS: Loaded ${nozzles.length} nozzles for this POS`);

        } else {

            console.warn("⚠️ PSMS: No nozzles linked to current pos.config");

        }

    },

});



Kindly help.

Avatar
Buang