<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="view_record_changeset_change_tree" model="ir.ui.view">
        <field name="model">record.changeset.change</field>
        <field name="arch" type="xml">
            <tree delete="false" create="false">
                <field name="record_id" />
                <field name="changeset_id" optional="hidden" />
                <field name="field_id" />
                <field name="field_type" />
                <field name="origin_value_display" />
                <field name="new_value_display" />
                <field name="date" />
                <field name="modified_by_id" />
                <field name="verified_on_date" />
                <field name="verified_by_id" />
                <field name="state" />
                <field name="user_can_validate_changeset" invisible="1" />
                <button
                    name="apply"
                    string="Apply"
                    type="object"
                    icon="fa-plus-circle"
                    attrs="{'invisible': [('user_can_validate_changeset', '=', False)]}"
                />
                <button
                    name="cancel"
                    string="Reject"
                    type="object"
                    icon="fa-times"
                    attrs="{'invisible': [('user_can_validate_changeset', '=', False)]}"
                />
            </tree>
        </field>
    </record>
    <record id="view_record_changeset_change_form" model="ir.ui.view">
        <field name="model">record.changeset.change</field>
        <field name="arch" type="xml">
            <form delete="false" create="false">
                <header>
                    <button
                        name="apply"
                        string="Apply"
                        type="object"
                        class="oe_highlight"
                        attrs="{'invisible': [('user_can_validate_changeset', '=', False)]}"
                    />
                    <button
                        name="cancel"
                        string="Reject"
                        type="object"
                        class="oe_highlight"
                        attrs="{'invisible': [('user_can_validate_changeset', '=', False)]}"
                    />
                    <field
                        name="state"
                        widget="statusbar"
                        statusbar_visible="draft,done"
                    />
                </header>
                <sheet>
                    <group name="main">
                        <group>
                            <field name="record_id" />
                            <field name="field_id" options="{'no_open': True}" />
                            <field name="field_type" />
                            <field name="date" />
                            <field name="modified_by_id" />
                            <field name="verified_on_date" />
                            <field name="verified_by_id" />
                            <field name="user_can_validate_changeset" invisible="1" />
                        </group>
                        <group>
                            <field name="origin_value_display" />
                            <field name="new_value_display" />
                            <field name="changeset_id" />
                        </group>
                    </group>
                </sheet>
            </form>
        </field>
    </record>
    <record id="view_record_changeset_change_search" model="ir.ui.view">
        <field name="model">record.changeset.change</field>
        <field name="arch" type="xml">
            <search>
                <field name="field_name" />
                <filter
                    string="Pending"
                    name="pending"
                    domain="[('state','=','draft')]"
                />
                <filter string="Done" name="done" domain="[('state','=','done')]" />
                <group expand="0" string="Group By">
                    <filter
                        string="State"
                        name="groupby_state"
                        context="{'group_by': 'state'}"
                    />
                </group>
            </search>
        </field>
    </record>
    <record id="action_record_changeset_change_view" model="ir.actions.act_window">
        <field name="name">Changes</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">record.changeset.change</field>
        <field name="view_mode">tree,form</field>
        <field name="context">{'search_default_pending': 1}</field>
        <field name="search_view_id" ref="view_record_changeset_change_search" />
    </record>
</odoo>
