You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

解决Odoo Website Sliders背景图片更换后无法显示的问题

解决Odoo幻灯片背景图片404无法显示的问题

核心问题:静态资源路径错误

日志里的404说明Odoo找不到你指定的SVG文件,因为你用了文件系统路径/custom_addons/custom_module/...,但Odoo的静态资源路由不需要包含插件目录名custom_addons,正确路径应以模块名为开头。

具体解决步骤:

  • 修正资源URL
    把背景图的URL从/custom_addons/custom_module/static/src/img/banner_dupli.svg改成/custom_module/static/src/img/banner_dupli.svg。修正后的模板代码片段:

    <section class="s_banner overflow-hidden bg-900" style="background-image: url(&quot;/custom_module/static/src/img/banner_dupli.svg&quot;); background-size: cover; background-position: 55% 65%" data-snippet="s_banner">
    
  • 验证文件目录结构
    确认自定义模块内文件位置完全匹配:

    custom_module/
    └── static/
        └── src/
            └── img/
                └── banner_dupli.svg
    

    注意:Linux系统下文件名和目录名区分大小写,需与代码里的写法完全一致。

  • 更新模块并加载资源

    1. 登录Odoo后台,进入「应用」列表,找到custom_module,确保它处于已安装状态
    2. 点击模块卡片上的「更新」按钮,或用命令行执行模块更新:
      ./odoo-bin -d o14-custom_db -u custom_module
      
  • 清除缓存

    1. 浏览器按Ctrl+Shift+R强制刷新页面,避免缓存旧的资源路径
    2. 若仍不生效,进入Odoo后台「设置 > 技术 > 资产」,删除相关web资产记录后重启Odoo服务
  • 更规范的QWeb引用方式(可选)
    用Odoo的asset模板过滤器引用静态资源,它会自动处理路由和缓存,避免路径错误:

    <section class="s_banner overflow-hidden bg-900" t-attf-style="background-image: url('{{ asset('custom_module/static/src/img/banner_dupli.svg') }}'); background-size: cover; background-position: 55% 65%" data-snippet="s_banner">
    

内容的提问来源于stack exchange,提问作者Kai Ning

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 18:05:28