odoo17 精减设置模块
设置模块中好多平时用不到的功能,如何隐藏,采取了继承修改方式,代码如下:
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="resconfig_ex_form" model="ir.ui.view">
<field name="name">设置去集成及关于</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='contacts_settings']" position="replace">
<div id="contacts_settings" invisible="1">
<block title="Contacts" name="contacts_setting_container" invisible="1">
<setting id="sms" string="Send SMS" documentation="/applications/marketing/sms_marketing/pricing/pricing_and_faq.html" help="Send texts to your contacts" />
<setting help="Automatically enrich your contact base with company data" title="When populating your address book, Odoo provides a list of matching companies. When selecting one item, the company data and logo are auto-filled." id="partner_autocomplete">
<field name="module_partner_autocomplete"/>
</setting>
</block>
</div>
</xpath>
<xpath expr="//div[@id='about']" position="replace">
<div id='about'>
</div>
</xpath>
<xpath expr="//div[@id='languages']" position="replace">
<div id='languages'>
</div>
</xpath>
<xpath expr="//div[@id='emails']" position="replace">
<div id='emails'>
</div>
</xpath>
<xpath expr="//block[@name='integration']" position="replace">
<block name="integration">
<div/>
</block>
</xpath>
<xpath expr="//block[@id='user_default_rights']" position="replace">
<block id="user_default_rights" >
<setting string="Default Access Rights" help="Set custom access rights for new users" title="By default, new users get highest access rights for all installed apps." id="access_rights">
<field name="user_default_rights"/>
<div class="content-group" invisible="not user_default_rights">
<div class="mt8">
<button type="object" name="open_default_user" string="Default Access Rights" icon="oi-arrow-right" class="btn-link"/>
</div>
</div>
</setting>
</block>
</xpath>
<xpath expr="//block[@id='pwa_settings']" position="replace">
<block id="pwa_settings" >
<div/>
</block>
</xpath>
<xpath expr="//block[@name='performance']" position="replace">
<block name="pwa_settings" >
<div/>
</block>
</xpath>
效果可以,但会出现问题,后期安装相关模块时,有继承找到ID情况时有发生
改变方式,利用属性不显示,可以即达到我们的目的,又可以不影响后期安装
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="resconfig_ex_form" model="ir.ui.view">
<field name="name">设置去集成及关于</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='contacts_settings']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//div[@id='about']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//div[@id='languages']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//div[@id='emails']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//block[@name='integration']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//block[@id='user_default_rights']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//block[@id='pwa_settings']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//block[@name='performance']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
</field>
</record>
</odoo>