ValueError: External ID not found in the system: website.assets_frontend

ValueError: External ID not found in the system: website.assets_frontend

我正在从 Odoo V13 升级到 V15,由于我编写了一个自定义模块来更改某些样式,因此在构建暂存分支时出现错误。

如何修复以下错误

File "/home/odoo/src/odoo/odoo/addons/base/models/ir_model.py", line 1928, in _xmlid_lookup
    raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: website.assets_frontend
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 693, in _tag_root
    raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing None:4, somewhere inside
<data inherit_id="website.assets_frontend" name="Profile Frontend Assets">
            <xpath expr="//link[last()]" position="after">
                 <link rel="stylesheet" type="text/scss" href="/website_profile_scss_customization/static/src/scss/website_profile.scss" t-ignore="true"/>
        </xpath>
    </data>

完整的错误输出

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/tools/cache.py", line 85, in lookup
    r = d[key]
  File "/home/odoo/src/odoo/odoo/tools/func.py", line 71, in wrapper
    return func(self, *args, **kwargs)
  File "/home/odoo/src/odoo/odoo/tools/lru.py", line 34, in __getitem__
    a = self.d[obj]
KeyError: ('ir.model.data', <function IrModelData._xmlid_lookup at 0x7f3e2ef8ee50>, 'website.assets_frontend')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/tools/convert.py", line 680, in _tag_root
    f(rec)
  File "/home/odoo/src/odoo/odoo/tools/convert.py", line 658, in _tag_template
    return self._tag_record(record)
  File "/home/odoo/src/odoo/odoo/tools/convert.py", line 567, in _tag_record
    f_val = self.id_get(f_ref)
  File "/home/odoo/src/odoo/odoo/tools/convert.py", line 663, in id_get
    res = self.model_id_get(id_str, raise_if_not_found)
  File "/home/odoo/src/odoo/odoo/tools/convert.py", line 669, in model_id_get
    return self.env['ir.model.data']._xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
  File "/home/odoo/src/odoo/odoo/addons/base/models/ir_model.py", line 1935, in _xmlid_to_res_model_res_id
    return self._xmlid_lookup(xmlid)[1:3]
  File "<decorator-gen-35>", line 2, in _xmlid_lookup
  File "/home/odoo/src/odoo/odoo/tools/cache.py", line 90, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/home/odoo/src/odoo/odoo/addons/base/models/ir_model.py", line 1928, in _xmlid_lookup
    raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: website.assets_frontend

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/service/server.py", line 1246, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/home/odoo/src/odoo/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/odoo/src/odoo/odoo/modules/loading.py", line 470, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/odoo/src/odoo/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/src/odoo/odoo/modules/loading.py", line 222, in load_module_graph
    load_data(cr, idref, mode, kind='data', package=package)
  File "/home/odoo/src/odoo/odoo/modules/loading.py", line 69, in load_data
    tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
  File "/home/odoo/src/odoo/odoo/tools/convert.py", line 745, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate)
  File "/home/odoo/src/odoo/odoo/tools/convert.py", line 811, in convert_xml_import
    obj.parse(doc.getroot())
  File "/home/odoo/src/odoo/odoo/tools/convert.py", line 731, in parse
    self._tag_root(de)
  File "/home/odoo/src/odoo/odoo/tools/convert.py", line 693, in _tag_root
    raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing None:4, somewhere inside
<data inherit_id="website.assets_frontend" name="Profile Frontend Assets">
            <xpath expr="//link[last()]" position="after">
                 <link rel="stylesheet" type="text/scss" href="/website_profile_scss_customization/static/src/scss/website_profile.scss" t-ignore="true"/>
        </xpath>
    </data>
the shutdown. 
odoo-bin process returned error code 255.

src/user/website_profile_scss_customization/清单.py

{
    'name': "Website Profile SCSS Customization",
    'version': '1.0',
    'depends': ['website_profile'],
    'author': "ES",
    'category': 'Category',
        'description': """Customize SCSS for Website Profile (for e-learning module) to match our branding""",
    # data files always loaded at installation
    'data': [
        'views/assets.xml',
    ],
}

src/user/website_profile_scss_customization/views/assets.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <template id="assets_frontend" inherit_id="website.assets_frontend" name="Profile Frontend Assets">
            <xpath expr="//link[last()]" position="after">
                 <link rel="stylesheet" type="text/scss" href="/website_profile_scss_customization/static/src/scss/website_profile.scss" t-ignore="true"/>
        </xpath>
    </template>
    
</odoo>

src/user/website_profile_scss_customization/static/src/scss/website_profile.scss

$esGreen: #0EAF56;

element.style {
    background-image: linear-gradient(99deg, #0EAF56 10%, #0EAF56 90%) !important;

}

.o_wforum_forum_card_bg {
    background-image: linear-gradient(99deg, #0EAF56 10%, #0EAF56 90%) !important;
}

.s_parallax_bg {
    background-image: linear-gradient(99deg, #0EAF56 10%, #0EAF56 90%) !important;
}

.o_wprofile_nav_tabs {
    @include media-breakpoint-up(md)  {
        margin-top: $owprofile-tabs-height * -1;
        border-bottom: 0;

        .nav-link {
            border-radius: 0;
            border-width: 0 1px;
            line-height: $line-height-base;
            @include o-hover-text-color(rgba(white, 0.8), white);

            &, &:hover {
                border-color: none !important;
                background: transparent;
            }

            &.active {
                color: color-yiq($owprofile-color-bg);
                background: $owprofile-color-bg;
                border-color: $owprofile-color-bg;
            }
        }
    }

    @include media-breakpoint-only(xs) {
        overflow-x: auto;
        overflow-y: hidden;

        li {
            white-space: nowrap;
        }
    }
}

@media (min-width: 768px) {
    .o_wforum_elearning_navtabs_container {
        background-color: #0EAF56 !important;
    }
    
    .o_wprofile_nav_tabs .nav-link, .o_wprofile_nav_tabs .nav-link:hover {
        border-color: 0EAF56 !important;
        background: transparent;
    }
}

.o_wforum_elearning_navtabs_container {
    background-color: #0EAF56 !important;
}

.btn-secondary {
    color: white !important;
    background-color: #0EAF56 !important;
    border-color: #0EAF56 !important;
}

.btn-secondary.disabled, .btn-secondary:disabled {
    color: white !important;
    background-color: #0EAF56 !important;
    border-color: #0EAF56 !important;
}

@media (min-width: 768px) {
  .o_wprofile_nav_tabs .nav-link, .o_wprofile_nav_tabs .nav-link:hover {
    border-color: transparent !important;
    background: transparent;
  }
}

.o_wprofile_nav_tabs .nav-link, .o_wprofile_nav_tabs .nav-link:hover {
    border-color: transparent !important;
    background: transparent;
}

.o_forum_ask_btn {
    background: $esGreen !important;
}

我明白了。 Odoo V15 不再具有模板覆盖,因此您无需创建 assets.xml 文件,您只需将 CSS、JS 等包含在 assets 包中 [=13] =].

我的新清单.py

{
    'name': "Website Profile SCSS Customization",
    'version': '1.0',
    'depends': ['website_profile'],
    'author': "ES",
    'category': 'Category',
        'description': """Customize SCSS for Website Profile (for e-learning module) to match our branding""",
    'assets': {
        'web.assets_frontend': [          
            'website_profile_scss_customization/static/src/scss/website_profile.scss'
        ]
    }
}