跳至内容
菜单
此问题已终结
3 回复
1279 查看

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.

形象
丢弃
最佳答案

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

);

},

});




形象
丢弃

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

最佳答案

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.

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
1
3月 24
1235
4
5月 25
967
2
5月 25
3942
1
3月 25
470
4
3月 25
3127