<?xml version="1.0" encoding="UTF-8"?>
<odoo>
        <!-- Asset Custody Multi Operation -->
    <record model="ir.ui.view" id="view_account_asset_multi_operation_tree">
        <field name="name">account.asset.multi.operation.tree</field>
        <field name="model">account.asset.multi.operation</field>
        <field name="arch" type="xml">
            <list>
                <field name="name"/>
                <field name="date"/>
                <field name="type"/>
                <field name="responsible_user_id"/>
                <field name="note"/>
                <field name="state"/>
            </list>
        </field>
    </record>

    <record model="ir.ui.view" id="view_account_asset_multi_assignment_form">
        <field name="name">account.asset.multi.assignment.form</field>
        <field name="model">account.asset.multi.operation</field>
        <field name="arch" type="xml">
            <form duplicate="0">
                <header>

                    <button name="act_progress" invisible="state != 'draft'"  string="Start" type="object" class="oe_highlight"/>
                    <button name="act_confirm"  groups='exp_asset_base.group_assets_manager' invisible="state != 'in_progress'"  string="Confirm" type="object"
                            class="oe_highlight"/>
                    <button name="act_reject" groups="exp_asset_base.group_assets_manager" invisible="state != 'in_progress'"  string="Reject" type="object"/>
                    <button name="act_draft" groups="exp_asset_base.group_assets_manager" invisible="state != 'cancel'" string="Set to Draft" type="object" class="oe_highlight"/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,in_progress,done"/>
                </header>
                <sheet>
                    <div class="oe_title">
                        <h1>
                            <field name="barcode" nolabel="1" placeholder="Barcode..."/>
                        </h1>
                    </div>

                    <group>
                        <group>
                            <field name="name" readonly="1"/>
                            <field name="date"/>
                            <field name="responsible_department_id" readonly="1"/>
                            <field name="manual" readonly="1"/>
                        </group>
                        <group>
                            <field name="type" invisible="1"/>
                            <field name="responsible_user_id"/>
                            <field name="note"/>

                        </group>
                    </group>
                    <group string="Assignment Info">
                        <group>
                            <field name="new_location_id"/>
                            <field name="new_employee_id"/>
                            <field name="new_department_id"/>
                        </group>
                    </group>
                    <notebook colspan="4">
                        <page string="Assets Assignment">
                            <field name="operation_ids" nolabel="1"
                                   context="{'default_user_id':responsible_user_id, 'default_type':type, 'default_date':date,
                                            'default_note':note, 'default_new_employee_id':new_employee_id,
                                            'default_new_department_id':new_department_id, 'default_new_location_id':new_location_id}">
                                <list editable="top">
                                    <field name="asset_id" required="1"
                                           domain="[('status', 'in', ['new','available']), ('asset_type', '=', 'purchase'),
                                                   ('state', '!=', 'model'), ('parent_id', '=', False)]"/>
                                     <field name="custody_type" required="1"/>
                                    <field name="custody_period" required="1"/>
                                    <field name="return_date"
                                           readonly="custody_period != 'temporary'"
                                           required="custody_period == 'temporary'"/>
                                    <field name="new_employee_id" invisible="1"/>
                                    <field name="new_department_id" invisible="1"/>
                                    <field name="new_location_id" invisible="1"/>
                                    <field name="date" invisible="1"/>
                                    <field name="type" invisible="1"/>
                                    <field name="note" invisible="1"/>
                                    <field name="user_id" invisible="1"/>
                                    <field name="department_id" invisible="1"/>
                                    <field name="state" invisible="1"/>
                                </list>
                            </field>
                        </page>
                    </notebook>
                </sheet>
                <chatter/>
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="view_account_asset_multi_release_form">
        <field name="name">account.asset.multi.release.form</field>
        <field name="model">account.asset.multi.operation</field>
        <field name="arch" type="xml">
            <form duplicate="0">
                <header>
                    <button name="act_progress" invisible="state != 'draft'" string="Start" type="object" class="oe_highlight"/>
                    <button  groups="exp_asset_base.group_assets_manager" name="act_confirm"  invisible="state != 'in_progress'" string="Confirm" type="object"
                            class="oe_highlight"/>
                    <button groups="exp_asset_base.group_assets_manager" name="act_reject" invisible="state != 'in_progress'" string="Reject" type="object"/>
                    <button groups="exp_asset_base.group_assets_manager" name="act_draft" invisible="state != 'cancel'" string="Set to Draft" type="object" class="oe_highlight"/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,in_progress,done"/>
                </header>
                <sheet>
                    <div class="oe_title">
                        <h1>
                            <field name="_barcode_scanned" widget="barcode_handler"/>
                            <field name="barcode" nolabel="1" placeholder="Barcode..."/>
                        </h1>
                    </div>

                    <group>
                        <group>
                            <field name="name" readonly="1"/>
                            <field name="date"/>
                            <field name="responsible_department_id" readonly="1"/>
                            <field name="manual" readonly="1"/>
                        </group>
                        <group>
                            <field name="type" invisible="1"/>
                            <field name="responsible_user_id"/>
                            <field name="note"/>
                        </group>
                    </group>
                    <group>
                        <group string="Release Info">
                            <field name="new_location_id" string="Release Location" required="1"/>
                        </group>
                    </group>
                    <notebook colspan="4">
                        <page string="Assets Release">
                            <field name="operation_ids" nolabel="1"
                                   context="{'default_user_id':responsible_user_id, 'default_type':type, 'default_date':date,
                                            'default_note':note, 'default_new_location_id':new_location_id}">
                                <list editable="top">
                                    <field name="asset_id" required="1"
                                           domain="[('status', 'in', ['assigned']), ('asset_type', '=', 'purchase'),
                                                   ('state', '!=', 'model'), ('parent_id', '=', False)]"/>
                                     <field name="current_employee_id"/>
                                    <field name="current_department_id"/>
                                    <field name="current_location_id"/>
                                    <field name="asset_status2"/>
                                    <field name="new_employee_id" invisible="1"/>
                                    <field name="new_department_id" invisible="1"/>
                                    <field name="new_location_id" invisible="1"/>
                                    <field name="date" invisible="1"/>
                                    <field name="type" invisible="1"/>
                                    <field name="note" invisible="1"/>
                                    <field name="user_id" invisible="1"/>
                                    <field name="department_id" invisible="1"/>
                                    <field name="state" invisible="1"/>
                                </list>
                            </field>
                        </page>
                    </notebook>
                </sheet>
                <chatter/>
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="view_account_asset_multi_transfer_form">
        <field name="name">account.asset.multi.transfer.form</field>
        <field name="model">account.asset.multi.operation</field>
        <field name="arch" type="xml">
            <form duplicate="0">
                <header>
                    <button name="act_progress" invisible="state != 'draft'" string="Start" type="object" class="oe_highlight"/>
                    <button groups="exp_asset_base.group_assets_manager" name="act_confirm"  invisible="state != 'in_progress'" string="Confirm" type="object"
                            class="oe_highlight"/>
                    <button groups="exp_asset_base.group_assets_manager" name="act_reject" invisible="state != 'in_progress'" string="Reject" type="object"/>
                    <button groups="exp_asset_base.group_assets_manager" name="act_draft"  invisible="state != 'cancel'" string="Set to Draft" type="object" class="oe_highlight"/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,in_progress,done"/>
                </header>
                <sheet>
                    <div class="oe_title">
                        <h1>
                            <field name="barcode" nolabel="1" placeholder="Barcode..."/>
                        </h1>
                    </div>

                    <group>
                        <group>
                            <field name="name" readonly="1"/>
                            <field name="date"/>
                            <field name="responsible_department_id" readonly="1"/>
                            <field name="manual" readonly="1"/>
                        </group>
                        <group>
                            <field name="type" invisible="1"/>
                            <field name="responsible_user_id"/>
                            <field name="note"/>

                        </group>
                    </group>
                    <group invisible="type != 'transfer'" >
                        <group string="New">
                            <field name="new_employee_id"/>
                            <field name="new_department_id"/>
                            <field name="new_location_id"/>
                        </group>
                    </group>
                    <notebook colspan="4">
                        <page string="Assets Transfer">
                            <field name="operation_ids" nolabel="1"
                                   context="{'default_user_id':responsible_user_id, 'default_type':type, 'default_date':date,
                                            'default_note':note, 'default_new_employee_id':new_employee_id,
                                            'default_new_department_id':new_department_id, 'default_new_location_id':new_location_id}">
                                <list editable="top">
                                    <field name="asset_id" required="1"
                                           domain="[('status', 'in', ['assigned']), ('asset_type', '=', 'purchase'),
                                                   ('state', '!=', 'model'), ('parent_id', '=', False)]"/>
                                    <field name="current_employee_id"/>
                                    <field name="current_department_id"/>
                                    <field name="current_location_id"/>
                                    <field name="custody_type" required="1"/>
                                    <field name="custody_period" required="1"/>
                                    <field name="return_date"
                                           required="custody_period == 'temporary'"
                                           readonly="custody_period != 'temporary'"/>
                                    <field name="new_employee_id" invisible="1"/>
                                    <field name="new_department_id" invisible="1"/>
                                    <field name="new_location_id" invisible="1"/>
                                    <field name="date" invisible="1"/>
                                    <field name="type" invisible="1"/>
                                    <field name="note" invisible="1"/>
                                    <field name="user_id" invisible="1"/>
                                    <field name="department_id" invisible="1"/>
                                    <field name="state" invisible="1"/>
                                </list>
                            </field>
                        </page>
                    </notebook>
                </sheet>
                <chatter/>
            </form>
        </field>
    </record>

    <record id="action_multi_asset_assignment" model="ir.actions.act_window">
        <field name="name">Multiple Assignment</field>
        <field name="res_model">account.asset.multi.operation</field>
        <field name="view_mode">list,form</field>
        <field name="context">{'default_manual':1, 'default_type':'assignment'}</field>
        <field name="domain">[('type','=','assignment')]</field>
        <field name="view_ids" eval="[(5, 0, 0),
            (0, 0, {'view_mode': 'list'}),
            (0, 0, {'view_mode': 'form', 'view_id': ref('view_account_asset_multi_assignment_form')})]"/>
    </record>
    <record id="action_multi_asset_release" model="ir.actions.act_window">
        <field name="name">Multiple Release</field>
        <field name="res_model">account.asset.multi.operation</field>
        <field name="view_mode">list,form</field>
        <field name="context">{'default_manual':1, 'default_type':'release'}</field>
        <field name="domain">[('type','=','release')]</field>
        <field name="view_ids" eval="[(5, 0, 0),
            (0, 0, {'view_mode': 'list'}),
            (0, 0, {'view_mode': 'form', 'view_id': ref('view_account_asset_multi_release_form')})]"/>
    </record>
    <record id="action_multi_asset_transfer" model="ir.actions.act_window">
        <field name="name">Multiple Transfer</field>
        <field name="res_model">account.asset.multi.operation</field>
        <field name="view_mode">list,form</field>
        <field name="context">{'default_manual':1, 'default_type':'transfer'}</field>
        <field name="domain">[('type','=','transfer')]</field>
        <field name="view_ids" eval="[(5, 0, 0),
            (0, 0, {'view_mode': 'list'}),
            (0, 0, {'view_mode': 'form', 'view_id': ref('view_account_asset_multi_transfer_form')})]"/>
    </record>
</odoo>