Odoo 10:从客户表单视图中删除按钮

时间:2018-10-17 15:33:40

标签: css xml forms button odoo

我要从客户表单视图中删除“ 未在网站上发布”按钮。

enter image description here

此按钮不是表单视图的一部分,因此当我尝试以下代码时,出现错误,认为父视图中不存在该元素:

<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>

但是仍然出现按钮。我是在做错什么还是还有其他方法可以删除此按钮?

1 个答案:

答案 0 :(得分:2)

您可以像这样扩展视图:

<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中,以能够继承添加按钮的视图,如上面的代码段