<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="sh_enable_menu_search_res_config_settings" model="ir.ui.view">
            <field name="name">enable.menu.search</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[@data-key='general_settings']" position="inside">
                    <h2>Enable Global Menu Search</h2>
                    <div class="row mt16 o_settings_container">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane">
                                <field name="enable_menu_search" />
                            </div>
                            <div class="o_setting_right_pane">
                                <label for="enable_menu_search" />
                                <div class="text-muted"></div>
                            </div>
                        </div>
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane"></div>
                            <div class="o_setting_right_pane">
                                <label for="start_search_after_letter" />
                                <field name="start_search_after_letter" />
                                <div class="text-muted">
                                    If you enter 3 then search start after 3 letter type in search box. If it is 0 or 1 then search start on single letter typing.
                                </div>
                            </div>
                        </div>
                    </div>
                </xpath>
            </field>
        </record>

        <record id="sh_o2m_global_search_form" model="ir.ui.view">
            <field name="name">sh.dynamic.action.fields.form</field>
            <field name="model">global.search.fields</field>
            <field name="arch" type="xml">
                <form string="Global Search O2M Action">
                    <sheet>
                        <group>
                            <group>
                                <field name="related_model_id" readonly="1" />
                                <field name="model_id" invisible="1" />
                            </group>
                        </group>
                        <notebook>
                            <page string="Fields">
                                <field name="field_ids">
                                    <tree editable="bottom">
                                        <field name="sequence" widget="handle" />
                                        <field name="field_id" options="{'no_create':True,'no_create_edit':True}" required="1" domain="[('model_id','=',parent.model_id)]" />
                                        <field name="model_id" invisible="1" />
                                        <field name="related_model_id" />
                                        <field name="name" />
                                        <field name="ttype" />
                                    </tree>
                                </field>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>

        <record id="sh_m2o_global_search_form" model="ir.ui.view">
            <field name="name">sh.global.search.fields.form</field>
            <field name="model">global.search.fields</field>
            <field name="arch" type="xml">
                <form string="Global Search M2O Action">
                    <sheet>
                        <group>
                            <group>
                                <field name="related_model_id" readonly="1" />
                                <field name="model_id" invisible="1" />
                            </group>
                        </group>
                        <notebook>
                            <page string="Fields">
                                <field name="field_ids">
                                    <tree editable="bottom">
                                        <field name="sequence" widget="handle" />
                                        <field
                                            name="field_id"
                                            options="{'no_create':True,'no_create_edit':True}"
                                            required="1"
                                            domain="[('model_id','=',parent.model_id),('ttype','in',['many2one','char','boolean','date','datetime','text','float','integer','selection','monetary'])]"
                                        />
                                        <field name="name" />
                                    </tree>
                                </field>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>
        <record id="sh_o2m_dynamic_action_form" model="ir.ui.view">
            <field name="name">sh.dynamic.action.fields.form</field>
            <field name="model">global.search</field>
            <field name="arch" type="xml">
                <form string="全局搜索配置">
                    <sheet>
                        <group>
                            <group>
                                <field name="model_id" />
                                <field name="main_field_id" />
                            </group>
                        </group>
                        <notebook>
                            <page string="Fields">
                                <field name="global_field_ids">
                                    <tree editable="bottom">
                                        <field name="sequence" widget="handle" />
                                        <field name="field_id" options="{'no_create':True,'no_create_edit':True}" required="1" domain="[('model_id','=',parent.model_id)]" />
                                        <field name="related_model_id" />
                                        <field name="name" />
                                        <field name="ttype" />
                                        <field name="model_id" invisible="1" />
                                        <button name="sh_o2m_dynamic_action_action" string="Open Relation Fields" type="object" icon="fa-list" attrs="{'invisible':[('ttype','not in',['one2many'])]}" options='{"warn": true}' />
                                    </tree>
                                </field>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>

        <record id="sh_dynamic_action_tree" model="ir.ui.view">
            <field name="name">sh.dynamic.action.tree</field>
            <field name="model">global.search</field>
            <field name="arch" type="xml">
                <tree>
                    <field name="model_id" />
                </tree>
            </field>
        </record>
        <record id="sh_dynamic_action_action" model="ir.actions.act_window">
            <field name="name">全局搜索配置</field>
            <field name="res_model">global.search</field>
            <field name="view_mode">tree,form</field>
        </record>

        <menuitem id="sh_dynamic_action_action_menu" name="全局搜索配置" sequence="15" action="sh_dynamic_action_action" web_icon="sf_global_search,static/description/icon.png" groups="sf_global_search.group_global_search" />
    </data>
</odoo>
