<odoo>
  <data>
    <record id="build_form_params" model="ir.ui.view">
        <field name="model">runbot.build.params</field>
        <field name="arch" type="xml">
            <form string="Build Params">
                <sheet>
                    <group>
                        <group colspan="2">
                            <field name="config_id"/>
                            <field name="config_data"/>
                            <field name="extra_params"/>
                            <field name="dockerfile_id"/>
                            <field name="dump_db"/>
                        </group>
                        <group colspan="2">
                            <field name="trigger_id"/>
                            <field name="create_batch_id"/>
                            <field name="version_id"/>
                            <field name="used_custom_trigger"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Commits">
                            <field name="commit_link_ids">
                                <list>
                                    <field name="commit_id"/>
                                    <field name="match_type"/>
                                </list>
                            </field>
                        </page>
                        <page string="Builds">
                            <field name="build_ids"/>
                        </page>
                        <page string="Reference Builds">
                            <field name="builds_reference_ids"/>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>
    <record id="view_build_params_tree" model="ir.ui.view">
        <field name="model">runbot.build.params</field>
        <field name="arch" type="xml">
            <list string="Build params">
                <field name="config_id"/>
                <field name="version_id"/>
                <field name="commit_link_ids"/>
            </list>
        </field>
    </record>
    <record id="build_form" model="ir.ui.view">
        <field name="model">runbot.build</field>
        <field name="arch" type="xml">
            <form string="Build">
                <sheet>
                    <group>
                        <field name="description"/>
                        <field name="params_id"/>
                        <field name="config_id"/>
                        <field name="port" groups="base.group_no_one"/>
                        <field name="dest"/>
                        <field name="local_state"/>
                        <field name="global_state"/>
                        <field name="requested_action" groups="base.group_no_one"/>
                        <field name="local_result"/>
                        <field name="global_result"/>
                        <field name="host"/>
                        <field name="keep_host"/>
                        <field name="host_id"/>
                        <field name="job_start" groups="base.group_no_one"/>
                        <field name="job_end" groups="base.group_no_one"/>
                        <field name="job_time" groups="base.group_no_one"/>
                        <field name="build_start" groups="base.group_no_one"/>
                        <field name="build_end" groups="base.group_no_one"/>
                        <field name="build_time" groups="base.group_no_one"/>
                        <field name="build_age" groups="base.group_no_one"/>
                        <field name="build_type"/>
                        <field name="parent_id"/>
                        <field name="orphan_result"/>
                        <field name="build_url" widget="url" readonly="1"/>
                        <field name="keep_running"/>
                        <field name="gc_date" readonly="1"/>
                        <field name="gc_delay"/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>
    <record id="view_build_tree" model="ir.ui.view">
        <field name="model">runbot.build</field>
        <field name="arch" type="xml">
            <list string="Builds">
                <field name="dest" 
                    decoration-bg-danger="global_result == 'ko'"
                    decoration-bg-warning="global_result == 'warn'"
                    decoration-bg-success="global_result == 'ok' and global_state == 'done'"
                    decoration-bg-info="global_result == 'ok' and global_state != 'done'"
                />
                <field name="create_bundle_id"/>
                <field name="global_result" optional="hide"/>
                <field name="global_state"/>
                <field name="trigger_id"/>
                <field name="config_id"/>
                <field name="job" string="Active_Step"/>
                <field name="host"/>
                <field name="build_time"/>
                <field name="build_age"/>
                <field name="build_url" widget="url"/>
            </list>
        </field>
    </record>
    <record id="view_build_pivot" model="ir.ui.view">
        <field name="name">runbot.pivot</field>
        <field name="model">runbot.build</field>
        <field name="arch" type="xml">
            <pivot string="Builds analysis">
                <field name="create_date" interval="week" type="row"/>
                <field name="global_state" type="col"/>
            </pivot>
        </field>
    </record>
    <record id="view_build_search" model="ir.ui.view">
        <field name="model">runbot.build</field>
        <field name="arch" type="xml">
            <search string="Search builds">
                <field name="id"/>
                <field name="global_state"/>
                <field name="dest"/>
                <field name="host" operator="="/>
                <filter string="Pending" name='pending' domain="[('global_state','=', 'pending')]"/>
                <filter string="Testing" name='testing' domain="[('global_state','in', ('testing', 'waiting'))]"/>
                <filter string="Running" name='running' domain="[('global_state','=', 'running')]"/>
                <filter string="Done" name='done' domain="[('global_state','=','done')]"/>
                <filter string="Duplicate" name='duplicate' domain="[('local_state','=', 'duplicate')]"/>
                <group expand="0" string="Group By...">
                    <filter string="Status" name='status' domain="[]" context="{'group_by':'global_state'}"/>
                    <filter string="Result" name='result' domain="[]" context="{'group_by':'global_result'}"/>
                    <filter string="Start" name='start' domain="[]" context="{'group_by':'job_start'}"/>
                    <filter string="Host" name='host' domain="[]" context="{'group_by':'host'}"/>
                    <filter string="Create Date" name='create_date' domain="[]" context="{'group_by':'create_date'}"/>
                </group>
            </search>
        </field>
    </record>
    <record id="action_build" model="ir.actions.act_window">
        <field name="name">Builds</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">runbot.build</field>
        <field name="view_mode">list,form,graph,pivot</field>
    </record>
    <record id="action_build_params" model="ir.actions.act_window">
        <field name="name">Builds Params</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">runbot.build.params</field>
        <field name="view_mode">list,form</field>
    </record>
  </data>
</odoo>