Skip to Content
Menú
This question has been flagged
3 Respostes
11618 Vistes

I'm encountering a persistent issue when trying to access the Point of Sale (POS) menu in Odoo, and I'm hoping someone can provide guidance on resolving it.


Here's the error message I'm encountering:

TypeError: Cannot read properties of undefined (reading 'type')
    at ControlPanelModelExtension._extractAttributes (http://localhost:5050/web/assets/490-44ec158/web.assets_backend.min.js:3583:107)
    at http://localhost:5050/web/assets/490-44ec158/web.assets_backend.min.js:3565:6
    at Array.forEach ()
    at ControlPanelModelExtension._createGroupOfFiltersFromArch (http://localhost:5050/web/assets/490-44ec158/web.assets_backend.min.js:3560:364)
    at ControlPanelModelExtension._addFilters (http://localhost:5050/web/assets/490-44ec158/web.assets_backend.min.js:3549:51)
    at ControlPanelModelExtension.prepareState (http://localhost:5050/web/assets/490-44ec158/web.assets_backend.min.js:3523:149)
    at ControlPanelModelExtension.importState (http://localhost:5050/web/assets/490-44ec158/web.assets_backend.min.js:5799:68)
    at ActionModel.importState (http://localhost:5050/web/assets/490-44ec158/web.assets_backend.min.js:5815:180)
    at new Model (http://localhost:5050/web/assets/490-44ec158/web.assets_backend.min.js:5804:6)
    at new ActionModel (http://localhost:5050/web/assets/490-44ec158/web.assets_backend.min.js:4460:1)

 I've attempted creating new databases, but the the problem persists, and it consistently arises after installing a custom module. Importantly, this module is unrelated to the POS module, and it does not contain any JavaScript code.
Any insights into what might be causing this problem would be greatly appreciated.


Thank you in advance for your assistance!

Avatar
Descartar
Best Answer

Hi kahina, 

Recently i got this error too, and then after i digg in into the error i try to disable and make an if else condition to solve this error 

File that I was i editing was
odoo15\addons\web\static\src\legacy\js\control_panel\control_panel_model_extension.js

on the  _extractAttributes you can add if else condition, and console.log to check the output and heres the final code :

_extractAttributes(filter, attrs) {

            console.log("Extracting attributes:", attrs);  // Debugging attrs

            console.log("Filter object before processing:", filter);

            if (!attrs) {

                console.error("Missing or undefined attrs:", attrs);

                return;

            }

            if (!filter) {

                console.error("Missing or undefined filter:", filter);

                return;

            }

            if (attrs.isDefault) {

                filter.isDefault = attrs.isDefault;

            }

            filter.description = attrs.string || attrs.help || attrs.name || attrs.domain || 'Ω';

            switch (filter.type) {

                case 'filter':

                    if (attrs.context) {

                        filter.context = attrs.context;

                    }

                    if (attrs.date) {

                        filter.isDateFilter = true;

                        filter.hasOptions = true;

                        filter.fieldName = attrs.date;

                        // Cek apakah field ada sebelum mengakses 'type'

                        const field = this.fields[attrs.date];

                        if (field) {

                            filter.fieldType = field.type;

                        } else {

                            console.error(`Field ${attrs.date} not found in this.fields!`);

                            filter.fieldType = 'default'; // Set default fieldType jika tidak ditemukan

                        }

                        filter.defaultOptionId = attrs.default_period || DEFAULT_PERIOD;

                    } else {

                        filter.domain = attrs.domain || '[]';

                    }

                    if (filter.isDefault) {

                        filter.defaultRank = -5;

                    }

                    break;

                case 'groupBy':

                    filter.fieldName = attrs.fieldName;

                    // Cek apakah field ada sebelum mengakses 'type'

                    const groupField = this.fields[attrs.fieldName];

                    if (groupField) {

                        filter.fieldType = groupField.type;

                    } else {

                        console.error(`Field ${attrs.fieldName} not found in this.fields!`);

                        filter.fieldType = 'default';

                    }

                    if (['date', 'datetime'].includes(filter.fieldType)) {

                        filter.hasOptions = true;

                        filter.defaultOptionId = attrs.defaultInterval || DEFAULT_INTERVAL;

                    }

                    if (filter.isDefault) {

                        filter.defaultRank = attrs.defaultRank;

                    }

                    break;

                case 'field': {

                    const field = this.fields[attrs.name];

                    if (field) {

                        filter.fieldName = attrs.name;

                        filter.fieldType = field.type;

                    } else {

                        console.error(`Field ${attrs.name} not found in this.fields!`);

                        filter.fieldType = 'default';

                    }

                    if (attrs.domain) {

                        filter.domain = attrs.domain;

                    }

                    if (attrs.filter_domain) {

                        filter.filterDomain = attrs.filter_domain;

                    } else if (attrs.operator) {

                        filter.operator = attrs.operator;

                    }

                    if (attrs.context) {

                        filter.context = attrs.context;

                    }

                    if (filter.isDefault) {

                        let operator = filter.operator;

                        if (!operator) {

                            const type = attrs.widget || filter.fieldType;

                            if (["char", "html", "many2many", "one2many", "text"].includes(type)) {

                                operator = "ilike";

                            } else {

                                operator = "=";

                            }

                        }

                        filter.defaultRank = -10;

                        filter.defaultAutocompleteValue = {

                            operator,

                            value: attrs.defaultValue,

                        };

                    }

                    break;

                }

            }

            if (filter.fieldName && !attrs.string) {

                const field = this.fields[filter.fieldName];

                if (field) {

                    filter.description = field.string;

                } else {

                    console.error(`Field ${filter.fieldName} not found in this.fields for description!`);

                    filter.description = 'Ω';

                }

            }

        }

 

Avatar
Descartar
Best Answer

Hi,

Maybe you have found a solution. But it may help someone.

I suggest you look at the current user's access rights. For example, I somehow used Project Stages on the window, which I tried to view but showed this error. So I enabled 'Use Stages on Project' for the logged-in user. After that, the error is gone.

Avatar
Descartar
Best Answer

What you can do to find out what is causing the problem, is go to 'Settings' and 'Activate the developer mode (with assets)'. If you now reload you page you can see in the console where the error occurs and in which file, e.g.:

This might be helpful to find out to find out more about this error. I hope this helps!

Avatar
Descartar
Autor

The error message points to a problem in the file "/web/static/src/legacy/js/control_panel/control_panel_model_extension.js," specifically in the following line of code:
filter.fieldType = field.type;
The error message doesn't provide enough information for me to pinpoint the exact cause of the problem.

Related Posts Respostes Vistes Activitat
0
d’abr. 25
447
1
de març 25
3576
1
de jul. 24
2035
1
de set. 23
6682
0
de febr. 23
1721