gpt4 book ai didi

javascript - Odoo 10 添加按钮到 POS

转载 作者:太空宇宙 更新时间:2023-11-03 15:58:14 25 4
gpt4 key购买 nike

我正在尝试向 POS 屏幕添加一个按钮。我掌握的很多信息都与 Odoo 8 有关,这可能就是它不起作用的原因。我安装了自定义插件,没有任何错误,但我没有看到按钮。运行 POS 时我也没有收到任何错误。在版本 8 中有一个 widgets.js 文件,其中包含

module.PosWidget.include({
build_widgets: function(){
var self = this;
this._super()

版本 10 中没有 widgets.js,我猜这就是我的问题所在。这只是一个猜测,我真的不知道如何向 POS 添加按钮。

这是我的 pos_custom.js

odoo.pos_custom = function(instance){
var module = instance.point_of_sale;
var round_pr = instance.web.round_precision
var QWeb = instance.web.qweb;

console.log("POS JS Loaded")
module.PosWidget.include({
build_widgets: function(){
var self = this;
this._super()

custom_btn = $(QWeb.render(`custom_btn`))
custom_btn.click(function(){
alert("hello")
})
console.log("button <<<>>> ",custom_btn,this.$(`.control-button`))
custom_btn.appendTo(this.$(`.control-button`))


this.$control_buttons`).removeClass(`oe_hidden`)


}
})

};

我的/src/xml/pos_custom.xml

<?xml version="1.0" encoding="UTF-8"?>
<templates xml="template" xml:space="preserve">

<t t-name="custom_btn">
<button>Cust Button</button>
</t>

</templates>

我的/views/templates.xml

<?xml version="1.0"?>
<openerp>
<data>
<template id="assets_backend" name="pos_custom assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">

<script type="text/javascript" src="/pos_custom/static/src/js/pos_custom.js"></script>
</xpath>
</template>

</data>
</openerp>

list .py

{
'name': 'Point Custom Module',
'version': '1.2',
'category': 'Point of Sale',
'summary': 'Custom Point of Sale ',
'description': "",
'data': [
"views/templates.xml"

],
'depends': ['point_of_sale'],


'qweb': ['static/src/xml/*.xml'],
'application': True,


}

最佳答案

有关如何做到这一点的具体示例,请查看 addons/pos_discount/static/src/js/discount.js。您可以在此处看到在 Odoo POS 的其中一个屏幕中添加了一个标签为 Discount 的按钮。检查整个模块,因为基本上所做的是在 POS 的操作按钮上添加一个按钮(附上屏幕截图)

enter image description here

还要检查 addons/pos_discount/static/src/xml/discount_templates.xml 上的模板以了解按钮的布局。

关于javascript - Odoo 10 添加按钮到 POS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41997252/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com