有人可以幫忙嗎?我想在 POS Odoo 15 CE 中添加一個自定義按鈕。我關注了這篇文章:https : //www.cybrosys.com/blog/how-to-add-buttons-in-pos-using-owl ,但似乎從第 14 版到第 15 版有所改變。
這是我在my_project/static/src/js目錄中的 js 檔案:
odoo.define('numenapp_buyer_name.alias_button', function(require) {
'use strict';
const PosComponent = require('point_of_sale.PosComponent');
const ProductScreen = require('point_of_sale.ProductScreen');
const { useListener } = require('web.custom_hooks');
const Registries = require('point_of_sale.Registries');
class AliasButton extends PosComponent {
constructor() {
super(...arguments);
useListener('click', this.onClick);
}
is_available() {
const order = this.env.pos.get_order();
return order;
}
onClick() {
const cli = this.get_client();
alert(cli.name);
}
}
AliasButton.template = 'AliasButton';
ProductScreen.addControlButton({
component: AliasButton,
condition: function() {
return this.env.pos;
},
position: ['before', 'OrderlineCustomerNoteButton'],
});
Registries.Component.add(AliasButton);
return AliasButton;
});
這是我在my_project/static/src/xml目錄中的 xml 檔案:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="AliasButton" owl="1">
<div class='control-button'>
Alias
</div>
</t>
</templates>
這是我的清單.py檔案(一塊):
'data': [
# 'security/ir.model.access.csv',
'views/views.xml',
'views/templates.xml',
],
'demo': [
'demo/demo.xml',
],
'qweb': [
'static/src/xml/AliasButton.xml',
],
'assets': {
'point_of_sale.assets': [
'numenapp_buyer_name/static/src/js/**/*',
],
},
uj5u.com熱心網友回復:
不再是qweb條目。
來自捆綁檔案:
捆綁包在每個模塊中定義,具有包含字典
__manifest__.py的專用鍵:后端環境和銷售點中使用的所有靜態 XML 模板。assets
web.assets_qweb
鏈接捆綁包中的所有 qweb .xml,web.assets_qweb如下所示:
'assets': {
'web.assets_qweb': [
'my_project/static/src/xml/AliasButton.xml',
],
},
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/447671.html
下一篇:按鈕btn1_click未執行
