我正在使用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
答案 0 :(得分:1)
<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应该在menifest.xml中
试试这段代码。 我相信现在绝对有效。