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

Odoo 17继承POS模板报错External ID未找到,求解决方案

问题分析与解决

错误ValueError: External ID not found in the system: point_of_sale.template的核心原因是继承模板的外部ID写错了。你要继承的目标模板是point_of_sale.PaymentScreenButtons,而不是point_of_sale.template(这个ID并不存在)。

修正后的XML代码

<odoo>
    <template id="extend_payment_screen_buttons" inherit_id="point_of_sale.PaymentScreenButtons">
        <xpath expr="//button[contains(@class, 'js_invoice')]" position="replace">
            <button class="button js_invoice btn btn-light py-3 text-start rounded-0 border-bottom"
                    t-att-class="{ 'highlight text-bg-primary': currentOrder.is_to_invoice() }"
                    t-on-click="createAndPrintInvoice">
                <i class="fa fa-file-text-o me-2"/>Invoice
            </button>
        </xpath>
    </template>
 </odoo>

额外注意事项

  • 确保你已经在对应的POS组件(比如PaymentScreen)中定义了createAndPrintInvoice方法,否则点击按钮会触发报错。
  • 若要提升定位的稳定性,可以把XPath表达式改成//button[@t-on-click='toggleIsToInvoice'],直接匹配原按钮的点击事件属性,避免因class名称变更导致定位失效。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 16:31:00