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

Odoo 15中CRM看板自定义按钮重复显示问题求助

Odoo 15 CRM看板自定义按钮重复显示问题解决

问题原因

你的XML模板中使用了t-jquery="button"选择器配合replace操作,这会匹配看板按钮区域内所有按钮元素(CRM线索看板头部除Create按钮外,默认还有Import按钮),将每个匹配到的按钮都替换成自定义按钮,最终导致重复显示。而联系人看板头部只有Create一个按钮,替换后仅显示一个自定义按钮,看似正常但实际是替换了原Create按钮,并非新增按钮。

解决方案

修改XML模板,将替换操作改为添加操作,精确匹配Create按钮并在其附近插入自定义按钮,同时保留原Create按钮:

修改后的crm_custom_create.xml

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
   <t t-extend="KanbanView.buttons" t-name="button_near_create.button.crm">
       <!-- 精确匹配Odoo默认Create按钮,在其后方插入自定义按钮 -->
       <t t-jquery="button.o-kanban-button-new" t-operation="after">
           <button t-if="widget.modelName == 'crm.lead'"
                   class="btn btn-primary open_wizard_action_kanban_crm oe_highlight ml-2"
                   type="button">Search and Create</button>
       </t>
   </t>
</templates>

关键说明

  • o-kanban-button-new是Odoo默认Create按钮的专属类,用它作为选择器可避免误匹配其他按钮(如Import)
  • t-operation="after"表示在目标按钮后方插入自定义按钮,若想放在Create按钮前方可改为before
  • ml-2类用于添加按钮间距,优化视觉效果

验证步骤

  1. 升级模块并刷新页面
  2. 查看CRM线索看板头部,此时会同时显示原Create按钮和自定义按钮,且无重复问题

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 03:40:54