odoo Uncaught TypeError: locale() locale is not loaded from moment locales!

解决方法:

  • 修改addons/web/static/lib/moment/moment.js

    • 修改前
    function loadLocale(name) {
        var oldLocale = null;
        // TODO: Find a better way to register and load all the locales in Node
        if (!locales[name] && (typeof module !== 'undefined') &&
            module && module.exports) {
            try {
                oldLocale = globalLocale._abbr;
                require('./locale/' + name);
                // because defineLocale currently also sets the global locale, we
                // want to undo that for lazy loaded locales
                getSetGlobalLocale(oldLocale);
            } catch (e) {
            }
        }
        return locales[name];
    }
    
    • 修改后
    function loadLocale(name) {
        var oldLocale = null;
        // TODO: Find a better way to register and load all the locales in Node
        if (!locales[name] && (typeof module !== 'undefined') &&
            module && module.exports) {
            try {
                oldLocale = globalLocale._abbr;
                require('./locale/' + name);
                // because defineLocale currently also sets the global locale, we
                // want to undo that for lazy loaded locales
                getSetGlobalLocale(oldLocale);
            } catch (e) {
            }
        }
    //-------------------------------------------------
        if (locales[name] === undefined) {
            locales[name] = locales['en'];
        }
    //-------------------------------------------------
        return locales[name];
    }
    
  • 这里的locales['en'], 是在报错页面运行moment.locale()得到的

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务