Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odgovori
1369 Prikazi

Upon hitting that little "disguard" button next to save bytton on certain apps/modules(not all, but enough to cause concern. Even on naitive apps/modules) I get the following error:

UncaughtPromiseError > TypeError

Uncaught Promise > commands is not iterable

TypeError: commands is not iterable

 at Proxy._applyCommands (https://myodoo.com/web/assets/a925e14/web.assets_web.min.js:6326:65)

    at Proxy._discard (https://myodoo.com/web/assets/a925e14/web.assets_web.min.js:6363:283)

    at Proxy._discard (https://myodoo.com/web/assets/a925e14/web.assets_web.min.js:6108:142)

    at https:/myodoo.com/web/assets/a925e14/web.assets_web.min.js:6066:39

    at always (https://myodoo.com/web/assets/a925e14/web.assets_web.min.js:3916:42)


What causes this? How can I fix it?

I find myself having to forcefully close the tab and come back man ually because I cannot disguard or go away from it.

Avatar
Opusti
Best Answer

I resolved the issue in Odoo17 by uninstalling a module that was adding a patch to the StaticList class. This patch was causing unintended behavior in list management by overriding the setup method, and removing the module fixed the problem.


To help identify if you are experiencing the same issue, you can check if they have similar code to the one causing the problem. This code is typically found in JavaScript files located in the path module/static/src/js. If you find a patch modifying the StaticList class or overriding its setup method, it could be the source of the issue.


The code:



import {StaticList} from "@web/model/relational_model/static_list";

import {markRaw} from "@odoo/owl";

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


patch(StaticList.prototype, {

setup(config, data, options = {}) {

this._parent = options.parent;

this._onUpdate = options.onUpdate;


this._cache = markRaw({});

this._commands = [];

this._initialCommands = [];

this._savePoint = undefined;

this._unknownRecordCommands = {};

this._currentIds = [...this.resIds];

this._initialCurrentIds = [...this.currentIds];

this._needsReordering = false;

this._tmpIncreaseLimit = 0;

this._extendedRecords = new Set();


this.records = Array.isArray(data)

? data

.slice(this.offset, this.limit)

.map((r) => this._createRecordDatapoint(r))

: [];

this.count = this.resIds.length;

this.handleField = Object.keys(this.activeFields).find(

(fieldName) => this.activeFields[fieldName].isHandle

);

},

});




Avatar
Opusti

Thanks! It worked. It was the same module, the mass editing module from OCA right?

Yes! Was the mass editing from OCA.

thanks it solved

Best Answer

I encountered the "commands is not iterable" error when trying to discard changes in my Odoo 17 instance. After investigating, I found that the issue occurred because _commands was either not properly initialized or set to a non-iterable value (like undefined or null).

To fix this, I ensured that _commands is always initialized as an array by adding a check in the setup method of the StaticList. Additionally, I added logging to track the state of _commands and verified that it's always an iterable. Here's the adjustment I made:

patch(StaticList.prototype, {
    setup(config, data, options = {}) {
        this._parent = options.parent;
        this._onUpdate = options.onUpdate;

        this._cache = markRaw({});
        this._commands = this._commands || [];  // Ensuring _commands is always an array
        console.log("Initial Commands:", this._commands);

        this._savePoint = undefined;
        this._unknownRecordCommands = {};
        this._currentIds = [...this.resIds];
        this._needsReordering = false;
        this._tmpIncreaseLimit = 0;
        this._extendedRecords = new Set();

        const safeData = Array.isArray(data) ? data : [];
        this.records = safeData.slice(this.offset, this.limit).map((r) => this._createRecordDatapoint(r));

        this.count = this.resIds.length;
        this.handleField = Object.keys(this.activeFields).find(
            (fieldName) => this.activeFields[fieldName].isHandle
        );
    },

    _applyCommands() {
        console.log("Applying Commands:", this._commands);
        this._commands = this._commands || [];  // Recheck before applying
    }
});

With these changes, the error was resolved, and the discard functionality works without issues. Adding logging also helped ensure the state of _commands remains consistent throughout its lifecycle.

Avatar
Opusti
Best Answer

Hi! Did you reached any solution? I'm having the same problem.

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
1
mar. 24
1353
4
maj 25
1185
2
maj 25
4280
1
mar. 25
642
4
mar. 25
3354