[英]How to add a new span in POS customer view? Odoo 14
我想在 POS 客户视图中添加一个跨度。 我尝试使用此代码,但不起作用。
//customer.xml
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="point_of_sale.template" xml:space="preserve">
<t t-extend="ClientDetailsEdit">
<t t-jquery=".client-details-right" t-operation="append">
<div class="client-detail">
<span class="label">Test</span>
</div>
</t>
</t>
</templates>
//清单.py
"qweb": [
'static/src/xml/customer.xml',
],
我的代码有什么问题? 请问有什么帮助吗? 谢谢。
如果我在 Odoo 插件中查看扩展的示例,则模板声明如下
<templates id="template" xml:space="preserve">
在您的情况下,您像这样声明模板
<templates id="point_of_sale.template" xml:space="preserve">
在您的模块中,当您编写此id="point_of_sale.template"
时,Odoo 将覆盖基本模板。 但是在模板的逻辑中,t-name 在所有模块中必须是唯一的。
如果我遵循这个逻辑,你应该写:
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-extend="ClientDetailsEdit">
<t t-jquery=".client-details-right" t-operation="append">
<div class="client-detail">
<span class="label">Test</span>
</div>
</t>
</t>
</templates>
在此解决方案中,您不会覆盖模板 point_of_sale.template 但您将创建一个新模板将扩展 t-name ClientDetailsEdit
PS:有关更多信息,我查看 addons/iap/statis/src/xml/iap_template.xml
代码是
<?xml version="1.0" encoding="UTF-8"?>
<template id="template" xml:space="preserve"> <!-- Id is only template -->
<!-- LAYOUT TEMPLATES -->
<div t-name="iap.redirect_to_odoo_credit">
<t t-if="data.body">
<div t-raw="data.body"/>
</t>
<t t-if="!data.body">
<t t-if="data.message">
<span t-esc="data.message"/>
</t>
<t t-if="!data.message">
<span>Insufficient credit to perform this service.</span>
</t>
</t>
</div>
<t t-extend="DashboardMain"> <!-- And extend template here -->
<t t-jquery=".o_web_settings_apps" t-operation="after">
<div class="o_web_settings_iap"></div>
</t>
</t>
<div t-name="iap.buy_more_credits" class="mt-2 row">
<div class="col-sm">
<button class="btn btn-link buy_credits"><i class="fa fa-arrow-right"/> Buy credits</button>
</div>
</div>
</template>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.