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

Odoo日历视图已声明字段无法全部显示问题求助

Odoo日历视图无法同时显示states和client字段的解决方法

你的问题核心在于两处配置错误:

  1. 给client和states字段都设置了invisible="1",强制隐藏了字段内容
  2. 未明确指定日历事件的显示逻辑,导致默认仅加载了关联颜色的states字段

修改后的完整代码如下:

<record id="view_planfication_rotation_calendar" model="ir.ui.view">
    <field name="name">planification.rotation.calendar</field>
    <field name="model">plannification.rotation</field>
    <field name="arch" type="xml">
        <calendar string="Planification" date_start="date_sortie" color="states">
            <!-- 保留筛选功能,移除隐藏属性让states字段可显示 -->
            <field name="states" filters="1"/>
            <!-- 移除隐藏属性,确保client字段被加载展示 -->
            <field name="client"/>
            <!-- 自定义日历事件显示模板,同时展示两个字段 -->
            <t t-name="calendar.event">
                <div>
                    <span t-field="record.states"/>
                    <span> - </span>
                    <span t-field="record.client"/>
                </div>
            </t>
        </calendar>
    </field>
</record>

关键修改说明:

  • 移除invisible="1":该属性会阻止字段内容在日历事件中渲染,必须移除才能显示
  • 自定义显示模板:通过<t t-name="calendar.event">可以精准控制事件的显示格式,确保两个字段同时展示
  • 保留原有功能:color="states"继续按状态区分事件颜色,filters="1"保留states字段的筛选能力

如果不需要自定义格式,仅移除invisible="1"属性,Odoo也会自动将可见字段展示在日历事件中,但自定义模板能让显示布局更贴合需求。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 11:55:03