<?xml version="1.0"?>
<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
    <data>

        <record model="res.group" id="group_purchase_request">
            <field name="name">Purchase Request</field>
        </record>

        <record model="ir.ui.view" id="purchase_request_view_form">
            <field name="model">purchase.request</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <![CDATA[
                    <form string="Purchase Request">
                        <separator string="Product Info" colspan="4" id="product"/>
                        <label name="product"/>
                        <field name="product"/>
                        <newline/>
                        <label name="quantity"/>
                        <field name="quantity"/>
                        <label name="uom"/>
                        <field name="uom"/>
                        <label name="computed_quantity"/>
                        <field name="computed_quantity"/>
                        <label name="computed_uom"/>
                        <field name="computed_uom"/>
                        <separator string="Supply Info" colspan="4" id="supply"/>
                        <label name="party"/>
                        <field name="party"/>
                        <newline/>
                        <label name="warehouse"/>
                        <field name="warehouse"/>
                        <label name="company"/>
                        <field name="company"/>
                        <label name="purchase_date"/>
                        <field name="purchase_date"/>
                        <label name="supply_date"/>
                        <field name="supply_date"/>
                        <label name="purchase"/>
                        <field name="purchase"/>
                        <label name="stock_level"/>
                        <field name="stock_level"/>
                        <label name="origin"/>
                        <field name="origin"/>
                        <label name="state"/>
                        <field name="state"/>
                    </form>
                ]]>
            </field>
        </record>
        <record model="ir.ui.view" id="purchase_request_view_tree">
            <field name="model">purchase.request</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <![CDATA[
                    <tree string="Purchase Requests">
                        <field name="product"/>
                        <field name="quantity"/>
                        <field name="uom"/>
                        <field name="warehouse"/>
                        <field name="party"/>
                        <field name="purchase_date"/>
                        <field name="stock_level"/>
                        <field name="company"/>
                        <field name="state"/>
                    </tree>
                ]]>
            </field>
        </record>

        <record model="ir.action.act_window" id="act_purchase_request_form">
            <field name="name">Purchase Requests</field>
            <field name="res_model">purchase.request</field>
        </record>
        <record model="ir.action.act_window.view" id="act_purchase_request_form_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="purchase_request_view_tree"/>
            <field name="act_window" ref="act_purchase_request_form"/>
        </record>
        <record model="ir.action.act_window.view" id="act_purchase_request_form_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="purchase_request_view_form"/>
            <field name="act_window" ref="act_purchase_request_form"/>
        </record>

        <record model="ir.ui.menu-res.group" id="menu_purchase_group_purchase_request">
            <field name="menu" ref="purchase.menu_purchase"/>
            <field name="group" ref="group_purchase_request"/>
        </record>

        <menuitem parent="purchase.menu_purchase" sequence="20"
            action="act_purchase_request_form" id="menu_purchase_request_form"/>

        <record model="ir.action.act_window" id="act_purchase_request_form_draft">
            <field name="name">Draft Purchase Requests</field>
            <field name="res_model">purchase.request</field>
            <field name="domain">[('purchase_line', '=', False)]</field>
        </record>
        <record model="ir.action.act_window.view" id="act_purchase_request_form_draft_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="purchase_request_view_tree"/>
            <field name="act_window" ref="act_purchase_request_form_draft"/>
        </record>
        <record model="ir.action.act_window.view" id="act_purchase_request_form_draft_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="purchase_request_view_form"/>
            <field name="act_window" ref="act_purchase_request_form_draft"/>
        </record>

        <menuitem parent="menu_purchase_request_form" sequence="20"
            action="act_purchase_request_form_draft" id="menu_purchase_request_form_draft"/>

        <record model="ir.action.wizard" id="act_purchase_request_create_purchase_request">
            <field name="name">Create Purchase Requests</field>
            <field name="wiz_name">purchase.request.create_purchase_request</field>
        </record>

        <record model="ir.ui.view" id="create_purchase_request_init_view_form">
            <field name="model">purchase.request.create_purchase_request.init</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <![CDATA[
                <form string="Create Purchase Request" col="2">
                    <image name="tryton-dialog-information" xexpand="0"
                        xfill="0"/>
                    <label string="Create Purchase Request?" id="create"
                        yalign="0.0" xalign="0.0" xexpand="1"/>
                </form>
                ]]>
            </field>
        </record>

        <menuitem parent="menu_purchase_request_form" sequence="10"
            action="act_purchase_request_create_purchase_request"
            id="menu_create_purchase_request"/>

        <record model="ir.ui.view" id="purchase_request_create_purchase_ask_view_form">
            <field name="model">purchase.request.create_purchase.ask_term</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <![CDATA[
                <form string="Create Purchase: Missing Payment Term" col="2" cursor="payment_term">
                    <label name="party"/>
                    <field name="party"/>
                    <label name="company"/>
                    <field name="company"/>
                    <label name="payment_term"/>
                    <field name="payment_term"/>
                </form>
                ]]>
            </field>
        </record>
        <record model="ir.ui.view" id="purchase_request_create_purchase_ask_party">
            <field name="model">purchase.request.create_purchase.ask_party</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <![CDATA[
                <form string="Create Purchase: Missing Supplier" col="2" cursor="party">
                    <label name="product"/>
                    <field name="product"/>
                    <label name="company"/>
                    <field name="company"/>
                    <label name="party"/>
                    <field name="party"/>
                </form>
                ]]>
            </field>
        </record>
        <record model="ir.action.wizard" id="wizard_create_purchase">
            <field name="name">Create Purchase</field>
            <field name="wiz_name">purchase.request.create_purchase</field>
            <field name="model">purchase.request</field>
        </record>
        <record model="ir.action-res.group"
            id="wizard_create_purchase_group_purchase_request">
            <field name="action" ref="wizard_create_purchase"/>
            <field name="group" ref="group_purchase_request"/>
        </record>

        <record model="ir.action.keyword" id="create_purchase_keyword">
            <field name="keyword">form_action</field>
            <field name="model">purchase.request,-1</field>
            <field name="action" ref="wizard_create_purchase"/>
        </record>

        <record model="ir.action.act_window" id="act_purchase_form">
            <field name="name">Purchases</field>
            <field name="res_model">purchase.purchase</field>
            <field name="domain">[("id", "=", Eval('purchase'))]</field>
        </record>
        <record model="ir.action.act_window.view" id="act_purchase_form_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="purchase.purchase_view_tree"/>
            <field name="act_window" ref="act_purchase_form"/>
        </record>
        <record model="ir.action.act_window.view" id="act_purchase_form_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="purchase.purchase_view_form"/>
            <field name="act_window" ref="act_purchase_form"/>
        </record>
        <record model="ir.action.keyword"
                id="act_open_purchase_keyword1">
            <field name="keyword">form_relate</field>
            <field name="model">purchase.request,-1</field>
            <field name="action" ref="act_purchase_form"/>
        </record>


        <record model="ir.rule.group" id="rule_group_purchase_request">
            <field name="model" search="[('model', '=', 'purchase.request')]"/>
            <field name="global_p" eval="True"/>
        </record>
        <record model="ir.rule" id="rule_purchase_request">
            <field name="field" search="[('name', '=', 'company'), ('model.model', '=', 'purchase.request')]"/>
            <field name="operator">=</field>
            <field name="operand">User/Current Company</field>
            <field name="rule_group" ref="rule_group_purchase_request"/>
        </record>

        <record model="ir.model.access" id="access_purchase_request">
            <field name="model" search="[('model', '=', 'purchase.request')]"/>
            <field name="perm_read" eval="False"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_delete" eval="False"/>
        </record>
        <record model="ir.model.access" id="access_purchase_request_sale">
            <field name="model" search="[('model', '=', 'purchase.request')]"/>
            <field name="group" ref="purchase.group_purchase"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_delete" eval="False"/>
        </record>
        <record model="ir.model.access" id="access_purchase_request_admin">
            <field name="model" search="[('model', '=', 'purchase.request')]"/>
            <field name="group" ref="group_purchase_request"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="True"/>
            <field name="perm_delete" eval="True"/>
        </record>

        <record model="res.user-res.group"
            id="user_admin_group_purchase_request">
            <field name="user" ref="res.user_admin"/>
            <field name="group" ref="group_purchase_request"/>
        </record>
        <record model="res.user-res.group"
            id="user_trigger_group_purchase_request">
            <field name="user" ref="res.user_trigger"/>
            <field name="group" ref="group_purchase_request"/>
        </record>

        <record model="res.user" id="user_generate_request">
            <field name="login">user_cron_purchase_request</field>
            <field name="name">Cron Purchase Request</field>
            <field name="signature"></field>
            <field name="active" eval="False"/>
        </record>
        <record model="res.user-res.group"
            id="user_generate_request_group_purchase_request">
            <field name="user" ref="user_generate_request"/>
            <field name="group" ref="group_purchase_request"/>
        </record>

        <record model="ir.cron" id="cron_generate_request">
            <field name="name">Generate Purchase Requests</field>
            <field name="request_user" ref="res.user_admin"/>
            <field name="user" ref="user_generate_request"/>
            <field name="active" eval="True"/>
            <field name="interval_number">1</field>
            <field name="interval_type">days</field>
            <field name="number_calls">-1</field>
            <field name="repeat_missed" eval="False"/>
            <field name="model">purchase.request</field>
            <field name="function">generate_requests</field>
        </record>

    </data>
</tryton>
