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

Odoo 18 POS界面自定义按钮无法显示问题求助

Odoo 18 POS界面自定义按钮无法显示问题求助

我正在尝试通过自定义模块给Odoo 18的POS界面添加一个自定义按钮。我已经参考了官方文档,试了各种方法,但按钮就是不显示。模块加载正常,控制台也没有报错。以下是我的代码:


complaint.xml(XML模板文件)

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="pos_custom.ControlButtons" t-inherit="point_of_sale.ControlButtons" t-inherit-mode="extension">
        <xpath expr="//div[@class='control-buttons']" position="inside">
            <button class="btn btn-light btn-lg flex-shrink-0 ms-auto" t-on-click="onClickPopupSingleField">
                Custom Button
            </button>
        </xpath>
    </t>
</templates>

complaint.js(JavaScript逻辑文件)

import { ControlButtons } from "@point_of_sale/app/screens/product_screen/control_buttons/control_buttons";
import { patch } from "@web/core/utils/patch";

patch(ControlButtons.prototype, {
    onClickPopupSingleField() {
        alert("Custom Button Clicked!");
    }
});

manifest.py(模块配置文件)

{
    'name': 'POS Complaint',
    'version': '1.0',
    'category': 'Point of Sale',
    'summary': 'Add a Create Complaint button in POS Partner List',
    'depends': ['point_of_sale'],
    'assets': {
        'point_of_sale.assets': [
            'pos_complaint/static/src/js/complaint.js',
            'pos_complaint/static/src/xml/complaint.xml',
        ],
    },
    'installable': True,
    'application': True,
}

目录结构

pos_complaint/
├── __init__.py
├── __manifest__.py
├── static/
│   └── src/
│       ├── js/
│       │   └── complaint.js
│       └── xml/
│           └── complaint.xml

我已经尝试过的操作:

  • 使用--dev=all命令重新构建了资源文件
  • 清除了浏览器缓存
  • 确认模块已经在系统中正确安装
  • 检查了浏览器控制台,没有发现任何报错信息

我预期这个自定义按钮会显示在POS界面中,但目前没有任何效果。

环境信息:

  • Odoo版本:18
  • Python版本:3.10

有没有人能帮我找出按钮不显示的原因?提前感谢!


备注:内容来源于stack exchange,提问作者Christen Alvarez

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.14 08:24:34