<?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_product_admin">
            <field name="name">Product Administration</field>
        </record>
        <record model="res.user" id="res.user_admin">
            <field name="groups" eval="[('add', ref('group_product_admin'))]"/>
        </record>
        <record model="res.user" id="res.user_trigger">
            <field name="groups" eval="[('add', ref('group_product_admin'))]"/>
        </record>

        <record model="ir.ui.icon" id="product_icon">
            <field name="name">tryton-product</field>
            <field name="path">icons/tryton-product.svg</field>
        </record>
        <menuitem name="Product" id="menu_main_product" sequence="1"
            icon="tryton-product"/>

        <record model="ir.ui.view" id="template_view_tree">
            <field name="model">product.template</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <![CDATA[
                    <tree string="Product Templates">
                        <field name="name" select="1"/>
                        <field name="list_price_uom" select="2"/>
                        <field name="cost_price_uom" select="2"/>
                        <field name="type" select="2"/>
                        <field name="category" select="1"/>
                        <field name="default_uom" select="2"/>
                        <field name="active" select="2" tree_invisible="1"/>
                    </tree>
                    ]]>
            </field>
        </record>

        <record model="ir.ui.view" id="template_view_form">
            <field name="model">product.template</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <![CDATA[
                    <form string="Product Template">
                      <label name="name"/>
                      <field name="name" xexpand="1"/>
                      <label name="active"/>
                      <field name="active" xexpand="0" width="100"/>
                      <notebook colspan="4">
                          <page string="General" id="general">
                              <label name="type"/>
                              <field name="type"/>
                              <newline/>
                              <label name="category"/>
                              <field name="category" />
                              <label name="default_uom"/>
                              <field name="default_uom" />
                              <label name="list_price"/>
                              <field name="list_price"/>
                              <newline/>
                              <label name="cost_price"/>
                              <field name="cost_price"/>
                              <label name="cost_price_method"/>
                              <field name="cost_price_method"/>
                          </page>
                      </notebook>
                    </form>
                    ]]>
            </field>
        </record>

        <record model="ir.ui.view" id="product_view_tree">
            <field name="model">product.product</field>
            <field name="type">tree</field>
            <field name="inherit" ref="template_view_tree"/>
            <field name="arch" type="xml">
                <![CDATA[
                <data>
                    <xpath
                        expr="/tree"
                        position="replace_attributes">
                        <tree string="Products"/>
                    </xpath>
                    <xpath
                        expr="/tree/field[@name=&quot;name&quot;]"
                        position="after">
                        <field name="code" select="1"/>
                    </xpath>
                </data>
                ]]>
            </field>
        </record>

        <record model="ir.ui.view" id="product_view_form">
            <field name="model">product.product</field>
            <field name="type">form</field>
            <field name="inherit" ref="template_view_form"/>
            <field name="arch" type="xml">
                <![CDATA[
                <data>
                    <xpath
                        expr="/form"
                        position="replace_attributes">
                        <form string="Products"/>
                    </xpath>
                    <xpath
                        expr="/form/notebook/page[@id=&quot;general&quot;]/label[@name=&quot;type&quot;]"
                        position="before">
                        <label name="code"/>
                        <field name="code"/>
                    </xpath>
                    <xpath
                        expr="/form/notebook/page[@id=&quot;general&quot;]"
                        position="inside">
                        <separator name="description" colspan="4"/>
                        <field name="description" colspan="4"/>
                    </xpath>
                </data>
                ]]>
            </field>
        </record>

        <record model="ir.action.act_window" id="act_product_form">
            <field name="name">Products</field>
            <field name="res_model">product.product</field>
        </record>


        <record model="ir.action.act_window.view" id="act_product_list_view">
            <field name="sequence" eval="10"/>
            <field name="view" ref="product_view_tree"/>
            <field name="act_window" ref="act_product_form"/>
        </record>

        <record model="ir.action.act_window.view" id="act_product_form_view">
            <field name="sequence" eval="20"/>
            <field name="view" ref="product_view_form"/>
            <field name="act_window" ref="act_product_form"/>
        </record>

        <menuitem name="Products" parent="menu_main_product"
                  sequence="1" id="menu_product_product"
                  action="act_product_form"/>

        <record model="ir.action.act_window" id="act_product_form2">
            <field name="name">Products</field>
            <field name="res_model">product.product</field>
        </record>

        <record model="ir.action.act_window.view" id="act_product_list_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="product_view_tree"/>
            <field name="act_window" ref="act_product_form2"/>
        </record>

        <record model="ir.action.act_window.view" id="act_product_form_view2">
            <field name="sequence" eval="10"/>
            <field name="view" ref="product_view_form"/>
            <field name="act_window" ref="act_product_form2"/>
        </record>

        <menuitem name="New Product" parent="menu_product_product"
                  sequence="1" id="menu_product_product_new"
                  action="act_product_form2" groups="group_product_admin"/>

        <record model="ir.action.act_window" id="act_product_by_category">
            <field name="name">Product by Category</field>
            <field name="res_model">product.product</field>
            <field name="context">{'categories': [Eval('active_id')]}</field>
            <field name="domain">[('category','child_of', [Eval('active_id')], 'parent')]</field>
        </record>
        <record model="ir.action.act_window.view" id="act_product_by_category_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="product_view_tree"/>
            <field name="act_window" ref="act_product_by_category"/>
        </record>
        <record model="ir.action.act_window.view" id="act_product_by_category_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="product_view_form"/>
            <field name="act_window" ref="act_product_by_category"/>
        </record>
        <record model="ir.action.keyword" id="act_product_by_category_keyword1">
            <field name="keyword">tree_open</field>
            <field name="model">product.category,0</field>
            <field name="action" ref="act_product_by_category"/>
        </record>

        <record model="ir.model.access" id="access_product">
            <field name="model" search="[('model', '=', 'product.product')]"/>
            <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_product_admin">
            <field name="model" search="[('model', '=', 'product.product')]"/>
            <field name="group" ref="group_product_admin"/>
            <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="ir.model.access" id="access_product_template">
            <field name="model" search="[('model', '=', 'product.template')]"/>
            <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_product_template_admin">
            <field name="model" search="[('model', '=', 'product.template')]"/>
            <field name="group" ref="group_product_admin"/>
            <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="ir.property" id="property_product_cost_price_method">
            <field name="name">cost_price_method</field>
            <field name="field"
                search="[('model.model', '=', 'product.template'), ('name', '=', 'cost_price_method')]"/>
            <field name="value">,fixed</field>
        </record>

    </data>
</tryton>
