odoo - 如何禁用附件表单视图odoo11中的清除按钮?
解决方案
如果您想在 Odoo 中删除整个二进制字段小部件的 Button,您可以“扩展”该小部件的 QWeb 模板,即:
<t t-name="FieldBinaryFile">
<a t-if="widget.mode === 'readonly'" href="javascript:void(0)" class="o_form_uri"/>
<div t-if="widget.mode !== 'readonly'" class="o_field_binary_file">
<input type="text" class="o_input"
readonly="readonly"
t-att-name="widget.name"
t-att-tabindex="widget.attrs.tabindex"
t-att-autofocus="widget.attrs.autofocus"/>
<button type="button" class="btn btn-sm btn-primary o_select_file_button" title="Select">Upload your file</button>
<button type="button" class="btn btn-sm btn-default fa fa-pencil o_select_file_button" title="Select"/>
<button type="button" class="btn btn-sm btn-default fa fa-trash-o o_clear_file_button" title="Clear"/>
<span class="o_form_binary_progress">Uploading...</span>
<t t-call="HiddenInputFile">
<t t-set="fileupload_id" t-value="widget.fileupload_id"/>
<t t-set="fileupload_style" t-translation="off">overflow-x: hidden</t>
</t>
</div>
</t>
您可以扩展 QWeb 模板,但必须将它们加载到 key 下的清单文件中qweb
。
xml 文件通常在 /static/src/xml 的模块中
<templates>
<t t-name="web.FieldBinaryFile" t-extend="base.FieldBinaryFile">
<t t-jquery="button[title='Clear']"
t-operation="replace" />
</t>
</templates>
和清单的一部分
{
'name': 'remove button in binary widget',
# and so on
'depends': [
'base',
],
'qweb': [
'static/src/xml/remove_button.xml'
],
# and so on
}
推荐阅读
- java - 无法将 setArray JDBC(整数)与 H2 数据库一起使用
- python - Django 模块 - 缺少视图模型
- amazon-web-services - MissingRegion:在 golang 和 aws sns 中找不到区域配置
- oracle12c - 使用 expdp 问题导出表
- javascript - 使用 Redux / React 移动数组中的项目
- azure - Azure 导出操作系统映像(不是超大 VHD)
- html - Gmail 在收件箱中显示表情符号,但在打开电子邮件时不显示
- git - 如何让我的本地更改显示到 github 存储库?
- r - 编写循环/函数以生成各种混合模型结果
- python - return 语句后循环继续,如何停止它