Odoo 16 系统中未找到外部 ID:website.assets_frontend

问题描述 投票:0回答:1

我对 Odoo 有点陌生,我想制作自己的 odoo 模块片段。但是当我尝试激活我的代码片段时,我收到此错误:

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
  File "/Users/scripty/Downloads/odoo/odoo/tools/cache.py", line 85, in lookup
    r = d[key]
        ~^^^^^
  File "<decorator-gen-8>", line 2, in __getitem__
  File "/Users/scripty/Downloads/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/tools/lru.py", line 34, in __getitem__
    a = self.d[obj]
        ~~~~~~^^^^^
KeyError: ('ir.model.data', <function IrModelData._xmlid_lookup at 0x106f9cb80>, 'website.assets_frontend')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 698, in _tag_root
    f(rec)
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 676, in _tag_template
    return self._tag_record(record)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 568, in _tag_record
    f_val = self.id_get(f_ref, raise_if_not_found=nodeattr2bool(rec, 'forcecreate', True))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 681, in id_get
    res = self.model_id_get(id_str, raise_if_not_found)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 687, 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 "/Users/scripty/Downloads/odoo/odoo/addons/base/models/ir_model.py", line 2059, in _xmlid_to_res_model_res_id
    return self._xmlid_lookup(xmlid)[1:3]
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-43>", line 2, in _xmlid_lookup
  File "/Users/scripty/Downloads/odoo/odoo/tools/cache.py", line 90, in lookup
    value = d[key] = self.method(*args, **kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/addons/base/models/ir_model.py", line 2052, 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 "/Users/scripty/Downloads/odoo/odoo/http.py", line 1653, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/service/model.py", line 133, in retrying
    result = func()
             ^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/http.py", line 1680, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/http.py", line 1884, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/addons/website/models/ir_http.py", line 237, in _dispatch
    response = super()._dispatch(endpoint)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
    result = endpoint(**request.params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/http.py", line 734, in route_wrapper
    result = endpoint(self, *args, **params_ok)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/addons/web/controllers/dataset.py", line 46, in call_button
    action = self._call_kw(model, method, args, kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/addons/web/controllers/dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/api.py", line 468, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/api.py", line 453, in _call_kw_multi
    result = method(recs, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-77>", line 2, in button_immediate_install
  File "/Users/scripty/Downloads/odoo/odoo/addons/base/models/ir_module.py", line 74, in check_and_log
    return method(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/addons/base/models/ir_module.py", line 478, in button_immediate_install
    return self._button_immediate_function(self.env.registry[self._name].button_install)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/addons/base/models/ir_module.py", line 602, in _button_immediate_function
    registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-16>", line 2, in new
  File "/Users/scripty/Downloads/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/Users/scripty/Downloads/odoo/odoo/modules/loading.py", line 489, in load_modules
    processed_modules += load_marked_modules(cr, graph,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/modules/loading.py", line 373, in load_marked_modules
    loaded, processed = load_module_graph(
                        ^^^^^^^^^^^^^^^^^^
  File "/Users/scripty/Downloads/odoo/odoo/modules/loading.py", line 232, in load_module_graph
    load_data(cr, idref, mode, kind='data', package=package)
  File "/Users/scripty/Downloads/odoo/odoo/modules/loading.py", line 72, in load_data
    tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 763, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate)
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 829, in convert_xml_import
    obj.parse(doc.getroot())
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 749, in parse
    self._tag_root(de)
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 698, in _tag_root
    f(rec)
  File "/Users/scripty/Downloads/odoo/odoo/tools/convert.py", line 711, 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="Custom Snippet Assets">
            <xpath expr="." position="inside">
                <link rel="stylesheet" type="text/css" href="/snippet_scripty/static/src/css/custom_snippet.css"/>
            </xpath>
        </data>

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    RPCError@http://localhost:8069/web/assets/2625-5089ccf/web.assets_backend.min.js:997:274
    makeErrorFromResponse@http://localhost:8069/web/assets/2625-5089ccf/web.assets_backend.min.js:1001:163
    jsonrpc/promise</<@http://localhost:8069/web/assets/2625-5089ccf/web.assets_backend.min.js:1009:34
    

老实说我不知道发生了什么事。说找不到 website.assets_frontend 。

这是我的 asset.xml 文件中的内容:

<odoo>
    <data>
        <!-- Ensure the frontend assets are correctly referenced -->
        <template id="custom_snippet_assets" inherit_id="website.assets_frontend" name="Custom Snippet Assets">
            <xpath expr="." position="inside">
                <link rel="stylesheet" type="text/css" href="/snippet_scripty/static/src/css/custom_snippet.css"/>
            </xpath>
        </template>
        <!-- Ensure the editor assets are correctly referenced -->
        <template id="custom_snippet_assets_editor" inherit_id="website.assets_editor" name="Custom Snippet Assets Editor">
            <xpath expr="." position="inside">
                <link rel="stylesheet" type="text/css" href="/snippet_scripty/static/src/css/custom_snippet.css"/>
            </xpath>
        </template>
    </data>
</odoo>

在我的清单上,我只有这个:

{
    'name': 'Snippet Scripty',
    'version': '1',
    'summary': 'Custom snippet made by scripty',
    'description': 'Custom snippet made by scripty',
    'category': 'Website',
    'depends': ['website'],
    'data': [
        'views/assets.xml',
        'xml/custom_snippet_templates.xml',
    ],
    'assets': {
        'web.assets_frontend': [
            '/snippet_scripty/static/src/css/custom_snippet.css',
        ],
        'web.assets_editor': [
            '/snippet_scripty/static/src/css/custom_snippet.css',
        ],
    },
    'installable': True,
    'application': False,
}

我希望我的代码片段出现在网站编辑器上并正常激活。但是当我尝试激活模块时我收到了这个错误

python xml odoo odoo-16
1个回答
0
投票

您正在以两种方式加载资源:旧方式和新方式。通过按键

assets
在清单中添加资产的新方法应该足够了。不再需要
data
xml。

© www.soinside.com 2019 - 2024. All rights reserved.