我正在使用 Odoo 9,并且正在尝试复制付款按钮。我想将 50+ 按钮复制到左侧。
我尝试添加
<t t-extend="PaymentScreen-Paymentmethods">
<div class="paymentmethods">
<button class="mode-button" data-action='+50'>+50</button>
</div>
</t>
但我得到的只是 POS 中的黑屏。当我检查页面上的元素时,出现以下错误
Error: QWeb2: Error while extending template 'PaymentScreen-PaymentmethodsNo expression given
最佳答案
<t t-extend="PaymentScreen-Paymentmethods">
<t t-jquery='.paymentmethods' t-operation='append'>
<div class="button mode-button" data-action='+50'>
+50
</div>
</t>
</t>
好吧,那么您还需要扩展小部件并重写该方法。
odoo.define('module_name.jsfilename', function (require) {
"use strict";
var PosBaseWidget = require('point_of_sale.screens');
var gui = require('point_of_sale.gui');
var QWeb = core.qweb;
var _t = core._t;
var PaymentScreenWidget = PaymentScreenWidget.extend({
init: function(parent, options) {
var self = this;
this._super(parent, options);
},
render_paymentmethods: function() {
var self = this;
var methods = $(QWeb.render('PaymentScreen-Paymentmethods', { widget:this }));
methods.on('click','.paymentmethod',function(){
self.click_paymentmethods($(this).data('id'));
});
methods.on('click','.mode-button',function(){
self.click_numpad($(this));
});
return methods;
},
});
});
然后您需要将该 js 文件添加到销售点后端,如下所示。
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="custom_key_pad" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/your_module/static/src/js/your_js_file.js"></script>
</xpath>
</template>
</odoo>
那么该 xml 应该位于您的 manifest.xml 中。
试试这个代码。我确信现在肯定有效。
关于jquery - Odoo Pos-QWeb2 : Error while extending template No expression given,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44505541/