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

Odoo 16自定义模块继承模板移除仪表盘日历失败求助

解决Odoo 16 hr_holidays CalendarRenderer模板继承无效问题

你的继承代码无效主要有几个原因,下面给出针对性的修复方案和检查项:

一、精准修改模板(按需选择)

方案1:直接移除仪表盘组件(保留日历)

如果你的需求是只去掉TimeOffDashboard仪表盘部分,保留原有的日历视图,修改继承模板为:

<templates xml:space="preserve">
    <t t-name="hr_holidays.CalendarRenderer" t-extend="hr_holidays.CalendarRenderer">
        <xpath expr="//TimeOffDashboard" position="replace"/>
    </t>
</templates>

方案2:通过控制显示变量隐藏仪表盘

因为原模板中TimeOffDashboard依赖showDashboard变量控制显示,你可以直接强制将该变量设为false:

<templates xml:space="preserve">
    <t t-name="hr_holidays.CalendarRenderer" t-extend="hr_holidays.CalendarRenderer">
        <t t-set="showDashboard" t-value="false"/>
    </t>
</templates>

方案3:替换整个容器(保留核心日历)

如果需要完全替换原容器但保留日历视图,使用以下代码:

<templates xml:space="preserve">
    <t t-name="hr_holidays.CalendarRenderer" t-extend="hr_holidays.CalendarRenderer">
        <xpath expr="//div[@class='o_timeoff_calendar']" position="replace">
            <div class="o_timeoff_calendar">
                <t t-call="web.CalendarRenderer"/>
            </div>
        </xpath>
    </t>
</templates>

二、必做的检查项

  1. 模块依赖配置:确保自定义模块的__manifest__.py中添加了hr_holidays依赖,否则继承逻辑不会生效:
'depends': ['hr_holidays'],
  1. 静态资源路径验证:确认web.assets_backend中配置的模板路径与实际文件路径完全一致,文件必须存在于指定位置。

  2. 清除缓存:

    • 在Odoo后台更新自定义模块(应用列表中找到模块,点击「升级」)
    • 强制刷新浏览器缓存(Ctrl+F5),避免浏览器加载旧的静态资源

内容的提问来源于stack exchange,提问作者Nahid Jawad Angon

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 19:45:04