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>
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
Python
{
'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,
}
tirectory结构
pos_complaint/
├── __init__.py
├── __manifest__.py
├── static/
│ └── src/
│ ├── js/
│ │ └── complaint.js
│ └── xml/
│ └── complaint.xml
我尝试过的是:
使用--dev =all
.重建资产。
清理浏览器高速缓存 ver ver ver ver ver ver ver ver ver ver ververnem.检查了错误的浏览器控制台(找不到错误)。
自定义按钮应显示在POS接口中。odoo版本:18 Python版本:3.10
有人可以帮我弄清楚为什么该按钮不显示?预先感谢!
这为我工作
''Assets':{
'point_of_sale._assets_pos': [
'your_module_name/static/src/xml/*.xml',
'your_module_name/static/src/js/*.js',
],
},