css - Odoo 10:从客户表单视图中删除按钮
问题描述
我想从客户表单视图中删除“未在网站上发布”按钮。
这个按钮不是表单视图的一部分,所以当我尝试下面的代码时,我得到一个错误,即父视图中不存在元素:
<xpath expr='//div[@class="oe_button_box"]//button[@name="website_publish_button"]' position='replace'>
<button type="object" name="callSurvey" icon="contacts_custom/static/description/survey.png" class="oe_stat_button">
<field string="Surveys" name="survey_count" widget="statinfo" modifiers="{'readonly': true}"/>
</button>
</xpath>
然后我尝试使用 css 将其删除。我的 css.css 文件:
button[name=website_publish_button]
{
display:none !important;
}
和模板:
<openerp>
<data>
<!-- Adds all assets in Odoo -->
<template id="assets_backend" name="contacts_custom assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<!--These links will be called when loading your Odoo -->
<link rel="stylesheet" href="/contacts_custom/static/css/css.css"/>
</xpath>
</template>
</data>
</openerp>
但仍然出现按钮。我做错了什么还是有没有其他方法可以删除这个按钮?
解决方案
您可以像这样扩展视图:
<record id="view_partners_form_website" model="ir.ui.view">
<field name="name">view.res.partner.form.website</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="website_partner.view_partners_form_website"/>
<field eval="18" name="priority"/>
<field name="arch" type="xml">
<data>
<button name="website_publish_button" position="replace">
<button type="object" name="callSurvey" icon="contacts_custom/static/description/survey.png" class="oe_stat_button">
<field string="Surveys" name="survey_count" widget="statinfo" modifiers="{'readonly': true}"/>
</button>
</button>
</data>
</field>
</record>
向模块添加一个依赖条目,website_partner
以便能够继承添加按钮的视图,如上面的代码片段
推荐阅读
- c - 已分配但无法释放的内存 C
- c# - Visual Studio Code:添加新的 Windows 窗体
- kotlin - 简化嵌套的 Mono
> 表达式科特林 - python-3.x - Flask WTForm 验证提交但不更新数据库
- python - 如何在 Python 中将创建的文件复制到网络驱动器?
- python - 带拆分的多个背包
- cordova - Cordova window.resolveLocalFileSystemURL 仅在第三次调用后触发回调
- r - Rgl 包 3D 散点图从轴中删除科学记数法
- angular - 使用 Angular 异步管道订阅 Observable
- xpages - XPages:回调在 dynamicContent 控件中不起作用