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

如何继承看板视图并修改default_group_by属性?

Replacing default_group_by in an Inherited Kanban View (Odoo)

Absolutely, you can replace the default_group_by attribute when inheriting a kanban view in Odoo—this is fully supported! Here's a straightforward, step-by-step guide to make it work:

Step 1: Build the Inherited View XML

Use Odoo's standard view inheritance structure to target the kanban root node and modify its attributes. Here's a complete, ready-to-use example:

<record id="inherit_target_kanban_view" model="ir.ui.view">
    <field name="name">target.model.kanban.inherit</field>
    <field name="model">your.target.model</field> <!-- Replace with your actual model name -->
    <field name="inherit_id" ref="original_module.original_kanban_view_id"/> <!-- Replace with the original view's external ID -->
    <field name="arch" type="xml">
        <!-- Target the root kanban node where default_group_by is defined -->
        <xpath expr="//kanban" position="attributes">
            <!-- Overwrite the existing default_group_by value -->
            <attribute name="default_group_by">state</attribute>
        </xpath>
    </field>
</record>

Key Details to Get Right:

  • inherit_id: Double-check that this references the correct external ID of the kanban view you want to extend. You can find this ID in the original module's XML files, or by navigating to Settings > Technical > Views in Odoo and searching for the view.
  • XPath Target: The //kanban expression directly hits the root node of the kanban view, which is where the default_group_by attribute lives.
  • Attribute Replacement: Using position="attributes" signals to Odoo that you want to modify the node's attributes, and the <attribute> tag will directly overwrite the existing default_group_by value with your new one (state).

Quick Extra Tips:

  • If the original view's default_group_by was set dynamically via Python code (instead of XML), you might need to override the relevant method (like get_view or a model-specific group-by handler) to ensure your change takes priority. But for XML-defined attributes, the method above works flawlessly.
  • Don't forget to upgrade your module after adding this code—Odoo won't apply the changes until you do so.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 08:49:54