[英]How to extend a template attribute using t-jquery and t-operation (Odoo 14)
我想更改 POS 模块中“折扣”按钮的名称。 所以我用这段代码扩展了模板,但不起作用。
<t t-extend="DiscountButton">
<t t-jquery="span[class='control-button js_discount']" t-operation="replace">
<span class="control-button js_discount">
<i class="fa fa-tag"></i>
<span> </span>
<span>Discount(%)</span>
</span>
</t>
</t>
请问有什么帮助吗?
您可以使用扩展 inheritance (就地转换):
<t t-inherit="pos_discount.DiscountButton" t-inherit-mode="extension">
<xpath expr="//span[hasclass('js_discount')]/span[2]" position="replace">
<span>Discount(%)</span>
</xpath>
</t>
extension
指令用于更改就地的父模板。
编辑:
您可以更改DiscountButton
的模板
odoo.define('my_module_name.NewDiscount', function(require) {
'use strict';
var DiscountButton = require('pos_discount.DiscountButton');
DiscountButton.template = "NewDiscount"
});
并将 js 文件添加到销售点资产:
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/my_module_name/static/js/new_discount.js"></script>
</xpath>
</template>
我想您已经定义了NewDiscount
模板并将其添加到清单文件的qweb
条目下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.