<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
    <record model="ir.ui.view" id="stock_request_order_tree">
        <field name="name">stock.request.order.tree</field>
        <field name="model">stock.request.order</field>
        <field name="arch" type="xml">
            <tree>
                <field name="name" />
                <field name="allow_virtual_location" invisible="1" />
                <field name="warehouse_id" groups="stock.group_stock_multi_locations" />
                <field name="location_id" groups="stock.group_stock_multi_locations" />
                <field name="state" />
            </tree>
        </field>
    </record>
    <record model="ir.ui.view" id="stock_request_order_form">
        <field name="name">stock.request.order.form</field>
        <field name="model">stock.request.order</field>
        <field name="arch" type="xml">
            <form>
                <field name="allow_virtual_location" invisible="1" />
                <field name="company_id" invisible="1" />
                <field name="warehouse_id" invisible="1" />
                <field name="location_id" invisible="1" />
                <field name="procurement_group_id" invisible="1" />
                <header>
                    <button
                        name="action_confirm"
                        string="Confirm"
                        type="object"
                        attrs="{'invisible': [('state', 'not in', ['draft'])]}"
                    />
                    <button
                        name="action_cancel"
                        states="draft,open"
                        type="object"
                        string="Cancel"
                    />
                    <button
                        name="action_draft"
                        states="cancel"
                        type="object"
                        string="Set to Draft"
                    />
                    <field name="state" widget="statusbar" />
                </header>
                <sheet>
                    <div class="oe_button_box" name="button_box">
                        <field
                            name="picking_ids"
                            invisible="1"
                            groups="stock.group_stock_user"
                        />
                        <button
                            type="object"
                            name="action_view_transfer"
                            class="oe_stat_button"
                            icon="fa-truck"
                            attrs="{'invisible': [('picking_count', '=', 0)]}"
                            groups="stock.group_stock_user"
                        >
                            <field
                                name="picking_count"
                                groups="stock.group_stock_user"
                                widget="statinfo"
                                string="Transfers"
                            />
                        </button>
                        <button
                            type="object"
                            name="action_view_stock_requests"
                            class="oe_stat_button"
                            icon="fa-chain"
                            attrs="{'invisible': [('state', '=', 'draft')]}"
                            groups="stock.group_stock_user"
                        >
                            <field
                                name="stock_request_count"
                                widget="statinfo"
                                string="Stock Requests"
                            />
                        </button>
                    </div>
                    <div class="oe_title">
                        <label for="name" string="Stock request Order" />
                        <h1>
                            <field name="name" readonly="1" />
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="expected_date" />
                            <field name="picking_policy" />
                        </group>
                        <group>
                            <field
                                name="warehouse_id"
                                widget="selection"
                                groups="stock.group_stock_multi_locations"
                            />
                            <field
                                name="location_id"
                                groups="stock.group_stock_multi_locations"
                            />
                            <field name="route_ids" invisible="1" />
                            <field
                                name="route_id"
                                groups="stock.group_stock_multi_locations"
                                domain="[('id','in',route_ids)]"
                            />
                            <field
                                name="procurement_group_id"
                                groups="stock.group_adv_location"
                            />
                            <field
                                name="company_id"
                                groups="base.group_multi_company"
                                options="{'no_create': True}"
                            />
                        </group>
                    </group>
                    <notebook>
                        <page name="items" string="Items">
                            <field
                                name="stock_request_ids"
                                context="{
                            'default_expected_date':expected_date,
                            'default_picking_policy': picking_policy,
                            'default_warehouse_id': warehouse_id,
                            'default_location_id': location_id,
                            'default_procurement_group_id': procurement_group_id,
                            'default_company_id': company_id,
                            'default_state': state,
                            }"
                                attrs="{'readonly': [('state', '!=', 'draft')]}"
                            >
                                <tree editable="bottom">
                                    <field name="name" readonly="1" />
                                    <field name="product_id" />
                                    <field name="allowed_uom_categ_id" invisible="1" />
                                    <field
                                        name="product_uom_id"
                                        options="{'no_open': True, 'no_create': True}"
                                        groups="uom.group_uom"
                                    />
                                    <field name="product_uom_id" invisible="1" />
                                    <field
                                        name="route_id"
                                        options="{'no_create': True}"
                                        groups="stock.group_stock_multi_locations"
                                    />
                                    <field name="route_ids" invisible="1" />
                                    <field name="product_uom_qty" />
                                    <field name="qty_in_progress" />
                                    <field name="qty_done" />
                                    <field name="expected_date" invisible="1" />
                                    <field name="picking_policy" invisible="1" />
                                    <field
                                        name="allow_virtual_location"
                                        invisible="1"
                                    />
                                    <field name="warehouse_id" invisible="1" />
                                    <field name="location_id" invisible="1" />
                                    <field name="procurement_group_id" invisible="1" />
                                    <field name="company_id" invisible="1" />
                                    <field name="state" />
                                </tree>
                            </field>
                        </page>
                    </notebook>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers" />
                    <field name="activity_ids" widget="mail_activity" />
                    <field name="message_ids" widget="mail_thread" />
                </div>
            </form>
        </field>
    </record>
    <record model="ir.ui.view" id="stock_request_order_search">
        <field name="name">stock.request.order.search</field>
        <field name="model">stock.request.order</field>
        <field name="arch" type="xml">
            <search string="Stock Requests Order Search">
                <field name="name" string="Stock Request Orders" />
                <field name="state" />
                <field name="warehouse_id" />
                <field name="location_id" groups="stock.group_stock_multi_locations" />
                <field name="company_id" groups="base.group_multi_company" />
                <separator />
                <filter string="Draft" name="draft" domain="[('state','=','draft')]" />
                <filter
                    string="In Progress"
                    name="open"
                    domain="[('state','=','open')]"
                />
                <filter string="Finished" name="done" domain="[('state','=','done')]" />
                <filter
                    string="Cancelled"
                    name="cancel"
                    domain="[('state','=','cancel')]"
                />
                <group expand="0" string="Group By">
                    <filter
                        string="Warehouse"
                        name="warehouse"
                        domain="[]"
                        context="{'group_by':'warehouse_id'}"
                    />
                    <filter
                        string="Location"
                        name="location"
                        domain="[]"
                        context="{'group_by':'location_id'}"
                    />
                </group>
            </search>
        </field>
    </record>
    <record model="ir.actions.act_window" id="stock_request_order_action">
        <field name="name">Stock Request Orders</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">stock.request.order</field>
        <field name="view_mode">tree,form</field>
    </record>
</odoo>
