<odoo>
    <record id="runbot_merge_action_batches" model="ir.actions.act_window">
        <field name="name">Batches</field>
        <field name="res_model">runbot_merge.batch</field>
        <field name="view_mode">tree,form</field>
    </record>

    <record id="runbot_merge_batch_search" model="ir.ui.view">
        <field name="name">batches search</field>
        <field name="model">runbot_merge.batch</field>
        <field name="arch" type="xml">
            <search>
                <filter name="all" domain="['|', ('active', '=', True), ('active', '=', False)]"/>
                <filter name="inactive" domain="[('active', '=', False)]"/>

                <field name="name"/>
                <field name="target"/>
                <field name="id"/>
            </search>
        </field>
    </record>

    <record id="runbot_merge_batch_tree" model="ir.ui.view">
        <field name="name">batches list</field>
        <field name="model">runbot_merge.batch</field>
        <field name="arch" type="xml">
            <tree decoration-muted="not active">
                <field name="id"/>
                <field name="name"/>
                <field name="target"/>
                <field name="prs" widget="many2many_tags"/>
                <field name="blocked"/>
                <field name="active" invisible="1"/>
            </tree>
        </field>
    </record>

    <record id="runbot_merge_batch_form" model="ir.ui.view">
        <field name="name">Batch form</field>
        <field name="model">runbot_merge.batch</field>
        <field name="arch" type="xml">
            <form>
                <sheet>
                    <div class="oe_title"><h1><field name="name"/></h1></div>
                    <group>
                        <group>
                            <field name="target"/>
                            <field name="merge_date"/>
                            <field name="priority" invisible="merge_date"/>
                            <field name="skipchecks" invisible="merge_date"/>
                            <field name="cancel_staging" invisible="merge_date"/>
                            <field name="fw_policy"/>
                        </group>
                        <group>
                            <field name="blocked"/>
                        </group>
                    </group>
                    <group string="Pull Requests">
                        <group colspan="4">
                            <field colspan="2" name="all_prs" nolabel="1" readonly="1">
                                <tree>
                                    <button type="object" name="get_formview_action" icon="fa-external-link" title="open PR"/>
                                    <field name="display_name"/>
                                    <field name="repository"/>
                                    <field name="state"/>
                                </tree>
                            </field>
                        </group>
                    </group>
                    <group string="Genealogy">
                        <group colspan="4">
                            <field colspan="2" name="genealogy_ids" nolabel="1" readonly="1">
                                <tree decoration-muted="id == parent.id">
                                    <button type="object" name="get_formview_action" icon="fa-external-link" title="open batch"/>
                                    <field name="name"/>
                                    <field name="target"/>
                                    <field name="all_prs" widget="many2many_tags"/>
                                </tree>
                            </field>
                        </group>
                    </group>
                    <group string="Stagings">
                        <group colspan="4">
                            <field colspan="2" name="staging_ids" nolabel="1" readonly="1">
                                <tree>
                                    <button type="object" name="get_formview_action" icon="fa-external-link" title="open staging"/>
                                    <field name="staged_at"/>
                                    <field name="state"/>
                                    <field name="reason"/>
                                </tree>
                            </field>
                        </group>
                    </group>
                </sheet>
            </form>
        </field>
    </record>
</odoo>
