<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <menuitem icon="terp-partner" id="menu_base_partner" name="Sales" sequence="0"/>

        <menuitem id="menu_address_book" name="Address Book" parent="menu_base_partner" sequence="2"/>

        <menuitem id="menu_base_config" name="Configuration" parent="menu_base_partner" sequence="30"
            groups="group_system"/>

        <menuitem id="menu_config_address_book" name="Address Book" parent="menu_base_config" sequence="2"
            groups="group_system"/>

        <!--
          =====================
          Partner Address
          =====================
        -->

        <record id="view_res_partner_address_filter" model="ir.ui.view">
            <field name="name">res.partner.address.select</field>
            <field name="model">res.partner.address</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Contact">
                    <group>
                        <filter string="Customer" name="customer" icon="terp-personal" domain="[('is_customer_add','=','1')]" />
                        <filter string="Supplier" name="supplier"  icon="terp-personal" domain="[('is_supplier_add','=','1')]" />
                        <separator orientation="vertical"/>
                        <field name="partner_id" />
                        <field name="name" />
                        <field name="country_id" />
                    </group>
                    <newline/>
                    <group expand="0" string="Group By...">
                       <filter string="Partner" icon="terp-personal" domain="[]" context="{'group_by' : 'partner_id'}" />
                       <filter string="Country" icon="terp-go-home" domain="[]" context="{'group_by' : 'country_id'}" />
                       <filter string="Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by' : 'type'}" />
                   </group>
                 </search>
            </field>
        </record>

        <record id="view_partner_address_tree" model="ir.ui.view">
            <field name="name">res.partner.address.tree</field>
            <field name="model">res.partner.address</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Partner Addresses">
                    <field name="partner_id"/>
                    <field name="name"/>
                    <field name="phone"/>
                    <field name="email"/>
                    <field name="zip"/>
                    <field name="city"/>
                    <field name="country_id"/>
                    <field name="type"/>
                </tree>
            </field>
        </record>
        <record id="action_partner_addess_tree" model="ir.actions.act_window">
            <field name="name">Partner Contacts</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner.address</field>
            <field name="view_type">tree</field>
            <field name="view_id" ref="view_partner_address_tree"/>
        </record>

        <record id="view_partner_address_form1" model="ir.ui.view">
            <field name="name">res.partner.address.form1</field>
            <field name="model">res.partner.address</field>
            <field name="type">form</field>
            <field eval="8" name="priority"/>
            <field name="arch" type="xml">
                <form string="Address">
                    <group colspan="4" col="6">
                        <field name="partner_id" colspan="2"/>
                        <field name="company_id" groups="base.group_multi_company" widget="selection" colspan="2"/>
                        <newline/>
                        <field name="name"/>
                        <field domain="[('domain', '=', 'contact')]" name="title" widget="selection"/>
                        <field name="function"/>
                    </group>
                      <group colspan="2" col="2">
                        <separator string="Postal Address" colspan="4" col="4"/>
                        <field name="type"/>
                        <field name="street"/>
                        <field name="street2"/>
                        <field name="zip"/>
                        <field name="city"/>
                        <field name="country_id"/>
                        <field name="state_id"/>
                      </group>
                      <group colspan="2" col="2">
                        <separator string="Communication" colspan="4" col="4"/>
                        <field name="phone"/>
                        <field name="fax"/>
                        <field name="mobile"/>
                        <field name="email" widget="email"/>
                     </group>
                </form>
            </field>
        </record>
        <record id="action_partner_address_form" model="ir.actions.act_window">
            <field name="name">Addresses</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner.address</field>
            <field name="view_type">form</field>
            <field name="context">{"search_default_customer":1}</field>
            <field name="search_view_id" ref="view_res_partner_address_filter"/>
            <field name="help">Get an instant access to all your customer's contact with this menu.</field>
        </record>
        <record id="action_partner_address_form_view1" model="ir.actions.act_window.view">
            <field eval="10" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_partner_address_tree"/>
            <field name="act_window_id" ref="action_partner_address_form"/>
        </record>
        <record id="action_partner_address_form_view2" model="ir.actions.act_window.view">
            <field eval="20" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_partner_address_form1"/>
            <field name="act_window_id" ref="action_partner_address_form"/>
        </record>
        <menuitem action="action_partner_address_form" id="menu_partner_address_form"
            groups="base.group_extended,base.group_system,group_sale_manager,group_sale_salesman"
            parent="base.menu_address_book" sequence="30"/>

        <!--
          =========================================
          the short form used in the partner form
          =========================================
        -->
        <record id="view_partner_address_form2" model="ir.ui.view">
            <field name="name">res.partner.address.form2</field>
            <field name="model">res.partner.address</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Contacts">
                    <field name="name" select="1"/>
                    <field domain="[('domain', '=', 'contact')]" name="title" widget="selection"/>
                    <field name="street"/>
                    <field name="street2"/>
                    <field name="type"/>
                    <field name="function"/>
                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                    <newline/>
                    <field name="zip"/>
                    <field name="city"/>
                    <newline/>
                    <field completion="1" name="country_id" select="1"/>
                    <field name="state_id"/>
                    <newline/>
                    <field name="phone"/>
                    <field name="fax"/>
                    <newline/>
                    <field name="mobile"/>
                    <field name="email" widget="email"/>
                </form>
            </field>
        </record>

        <!--
          =======================
          Partner Titles
          =======================
        -->
        <record id="view_partner_title_tree" model="ir.ui.view">
            <field name="name">res.partner.title.tree</field>
            <field name="model">res.partner.title</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Partner Titles">
                    <field name="name" select="1"/>
                    <field name="shortcut" select="1"/>
                </tree>
            </field>
        </record>
        <record id="view_partner_title_form" model="ir.ui.view">
            <field name="name">res.partner.title.form</field>
            <field name="model">res.partner.title</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Partner Titles">
                    <field name="name" select="1"/>
                    <field name="shortcut" select="1"/>
                    <field name="domain"/>
                </form>
            </field>
        </record>

        <!--
        <record id="action_partner_title" model="ir.actions.act_window">
            <field name="name">Titles</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner.title</field>
            <field name="view_type">form</field>
        </record>
        <menuitem action="action_partner_title" id="menu_partner_title" parent="base.menu_base_config"/>
        -->

        <record id="action_partner_title_partner" model="ir.actions.act_window">
            <field name="name">Partner Titles</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner.title</field>
            <field name="view_type">form</field>
            <field name="domain">[('domain','=','partner')]</field>
        </record>

        <menuitem action="action_partner_title_partner" id="menu_partner_title_partner" name="Partner Title" parent="menu_config_address_book" sequence="2"/>

        <record id="action_partner_title_contact" model="ir.actions.act_window">
            <field name="name">Contact Titles</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner.title</field>
            <field name="view_type">form</field>
            <field name="domain">[('domain','=','contact')]</field>
        </record>

        <menuitem action="action_partner_title_contact" id="menu_partner_title_contact" name="Contact Titles" parent="menu_config_address_book" sequence="3"/>
        <!--
          =======================
          Partner
          =======================
        -->
        <record id="view_partner_tree" model="ir.ui.view">
            <field name="name">res.partner.tree</field>
            <field name="model">res.partner</field>
            <field name="type">tree</field>
            <field eval="8" name="priority"/>
            <field name="arch" type="xml">
                <tree string="Partners">
                    <field name="name"/>
                    <field name="ref" groups="base.group_extended"/>
                    <field name="phone"/>
                    <field name="email"/>
                    <field name="city"/>
                    <field name="country"/>
                    <field name="user_id"/>
                </tree>
            </field>
        </record>

        <record id="view_partner_form" model="ir.ui.view">
            <field name="name">res.partner.form</field>
            <field name="model">res.partner</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Partners" col='1'>
                    <group col="6" colspan="4">
                        <group colspan="5" col="6">
                            <field name="name" select="1"/>
                            <field name="ref"/>
                            <field domain="[('domain', '=', 'partner')]" name="title" size="0" groups="base.group_extended" widget="selection"/>
                            <field name="lang"/>
                        </group>
                        <group colspan="1" col="2">
                            <field name="customer" select="1"/>
                            <field name="supplier"/>
<!--                            <field name="employee"/>-->
                        </group>
                    </group>
                    <notebook colspan="4">
                        <page string="General">
                            <field colspan="4" mode="form,tree" name="address" nolabel="1" select="1" height="260">
                                <form string="Partner Contacts">
                                    <group colspan="4" col="6">
                                        <field name="name"/>
                                        <field domain="[('domain', '=', 'contact')]" name="title" size="0" widget="selection"/>
                                        <field name="function"/>
                                    </group>
                                    <newline/>
                                      <group colspan="2" col="4">
                                        <separator string="Postal Address" colspan="4" col="4" />
                                        <field name="type" string="Type" colspan="2"/>
                                        <field name="street" colspan="4"/>
                                        <field name="street2" colspan="4"/>
                                        <field name="zip"/>
                                        <field name="city"/>
                                        <field name="country_id" completion="1"/>
                                        <field name="state_id"/>
                                     </group>
                                     <group colspan="2" col="2">
                                        <separator string="Communication" colspan="2" col="2" />
                                        <field name="phone"/>
                                        <field name="mobile"/>
                                        <field name="fax"/>
                                        <field name="email" widget="email"/>
                                     </group>
                                </form>
                                <tree string="Partner Contacts">
                                    <field name="name"/>
                                    <field name="zip"/>
                                    <field name="city"/>
                                    <field name="country_id"/>
                                    <field name="phone"/>
                                    <field name="email"/>
                                </tree>
                            </field>
                            <group  groups="base.group_extended">
                                    <separator colspan="4" string="Categories"/>
                                    <field  colspan="4" name="category_id" nolabel="1"/>
                            </group>
                        </page>
                        <page string="Sales &amp; Purchases">
                            <separator string="General Information" colspan="4"/>
                            <field name="user_id"/>
                            <field name="active" groups="base.group_extended"/>
                            <field name="website" widget="url"/>
                            <field name="date"/>
                            <field name="parent_id" groups="base.group_extended"/>
                            <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                            <newline/>
                        </page>
                        <page string="History" groups="base.group_extended">
                        </page>
                        <page string="Notes">
                            <field colspan="4" name="comment" nolabel="1"/>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>

       <record id="view_res_partner_filter" model="ir.ui.view">
            <field name="name">res.partner.select</field>
            <field name="model">res.partner</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Partner">
                   <group col='10' colspan='4'>
                        <filter string="Customers" name="customer" icon="terp-personal" domain="[('customer','=',1)]" help="Customer Partners"/>
                        <filter string="Suppliers" name="supplier" icon="terp-personal" domain="[('supplier','=',1)]" help="Supplier Partners"/>
                        <separator orientation="vertical"/>
                        <field name="name" select="1"/>
                        <field name="address" select="1"/>
                        <field name="country" select="1"/>
                        <field name="category_id" select="1"/>
                        <field name="user_id" select="1">
                            <filter string="My Partners" icon="terp-personal+" domain="[('user_id','=',uid)]"/>
                        </field>
                   </group>
                   <newline />
                   <group expand="0" string="Group By...">
                       <filter string="Salesman" icon="terp-personal" domain="[]" context="{'group_by' : 'user_id'}" />
                   </group>
               </search>
            </field>
        </record>

        <record id="action_partner_form" model="ir.actions.act_window">
            <field name="name">Customers</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner</field>
            <field name="view_type">form</field>
            <field name="context">{"search_default_customer":1}</field>
            <field name="search_view_id" ref="view_res_partner_filter"/>
            <field name="help">The Address book manages your customers list. The form for customer allows you to record detailed on your customers (address, contacts, pricelist, account, etc.). With the history tab, you can follow all moves transactions related to a customer, like sales order, claims.</field>
        </record>
        <record id="action_partner_form_view1" model="ir.actions.act_window.view">
            <field eval="10" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_partner_tree"/>
            <field name="act_window_id" ref="action_partner_form"/>
        </record>
        <record id="action_partner_form_view2" model="ir.actions.act_window.view">
            <field eval="20" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_partner_form"/>
            <field name="act_window_id" ref="action_partner_form"/>
        </record>
        <menuitem
            action="action_partner_form"
            id="menu_partner_form"
            parent="base.menu_address_book"
            sequence="2"/>

        <record id="action_partner_customer_form" model="ir.actions.act_window">
            <field name="name">Customers</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner</field>
            <field name="view_type">form</field>
            <field name="domain">[('customer','=',1)]</field>
            <field name="context">{'default_customer':1, 'search_default_customer':1}</field>
            <field name="filter" eval="True"/>
        </record>

        <record id="action_partner_supplier_form" model="ir.actions.act_window">
            <field name="name">Suppliers</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner</field>
            <field name="view_type">form</field>
            <field name="domain">[]</field>
            <field name="context">{'default_customer':0, 'search_default_supplier': 1, 'default_supplier':1}</field>
            <field name="filter" eval="True"/>
            <field name="help">With the Suppliers menu, you have access to all informations regarding your suppliers, including an history to track event (crm) and his accounting properties.</field>
        </record>

        <record id="action_partner_employee_form" model="ir.actions.act_window">
            <field name="name">Employees</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner</field>
            <field name="view_type">form</field>
            <field name="domain">[('employee','=',1)]</field>
            <field name="context">{'default_customer':0, 'default_supplier':0 , 'default_employee':1}</field>
            <field name="filter" eval="True"/>
        </record>

        <record id="action_partner_other_form" model="ir.actions.act_window">
            <field name="name">Other Partners</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner</field>
            <field name="view_type">form</field>
            <field name="domain">[('supplier','&lt;&gt;',1),('customer','&lt;&gt;',1)]</field>
            <field name="filter" eval="True"/>
        </record>

        <record id="view_payterm_form" model="ir.ui.view">
            <field name="name">res.payterm</field>
            <field name="model">res.payterm</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Payment Term">
                    <field colspan="4" name="name"/>
                </form>
            </field>
        </record>
        <record id="action_payterm_form" model="ir.actions.act_window">
            <field name="name">Payment term</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.payterm</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="view_payterm_form"/>
        </record>

        <record id="view_partner_bank_type_form" model="ir.ui.view">
            <field name="name">res.partner.bank.type.form</field>
            <field name="model">res.partner.bank.type</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Bank Account Type">
                    <field name="name" select="1"/>
                    <field name="code" select="1"/>
                </form>
            </field>
        </record>

        <record id="view_partner_bank_type_tree" model="ir.ui.view">
            <field name="name">res.partner.bank.type.tree</field>
            <field name="model">res.partner.bank.type</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Bank Account Type">
                    <field name="name" select="1"/>
                    <field name="code" select="1"/>
                </tree>
            </field>
        </record>


        <record id="view_partner_bank_form" model="ir.ui.view">
            <field name="name">res.partner.bank.form</field>
            <field name="model">res.partner.bank</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Bank account">
                    <field name="state"/>
                    <field name="partner_id" select="1"/>
                    <newline/>
                    <field name="acc_number" select="1"/>
                    <newline/>
                    <field name="bank"/>
                    <newline/>
                    <field name="sequence"/>
                    <field colspan="4" name="name"/>
                    <separator colspan="4" string="Bank Account Owner"/>
                    <field colspan="4" name="owner_name"/>
                    <field colspan="4" name="street"/>
                    <field name="city"/>
                    <field name="zip"/>
                    <field completion="1" name="country_id"/>
                    <field name="state_id"/>
                </form>
            </field>
        </record>
        <record id="view_partner_bank_tree" model="ir.ui.view">
            <field name="name">res.partner.bank.tree</field>
            <field name="model">res.partner.bank</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Bank Accounts">
                    <field name="state"/>
                    <field name="acc_number"/>
                    <field name="partner_id"/>
                    <field name="owner_name"/>
                </tree>
            </field>
        </record>

        <!--
          ======================
          Categories
          ======================
        -->
        <record id="view_partner_category_form" model="ir.ui.view">
            <field name="name">res.partner.category.form</field>
            <field name="model">res.partner.category</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Partner Category">
                    <field name="name" select="1"/>
                    <field name="active" groups="base.group_extended"/>
                    <field name="parent_id"/>
                    <separator colspan="4" string="Partners"/>
                    <field colspan="4" name="partner_ids" nolabel="1"/>
                </form>
            </field>
        </record>
        <record id="view_partner_category_list" model="ir.ui.view">
            <field name="name">res.partner.category.list</field>
            <field name="model">res.partner.category</field>
            <field name="type">tree</field>
            <field eval="6" name="priority"/>
            <field name="arch" type="xml">
                <tree string="Partner Categories">
                    <field name="complete_name"/>
                </tree>
            </field>
        </record>
        <record id="view_partner_category_tree" model="ir.ui.view">
            <field name="name">res.partner.category.tree</field>
            <field name="model">res.partner.category</field>
            <field name="type">tree</field>
            <field name="field_parent">child_ids</field>
            <field name="arch" type="xml">
                <tree toolbar="1" string="Partner Categories">
                    <field name="name"/>
                </tree>
            </field>
        </record>
        <!--
        <record id="action_partner_category" model="ir.actions.act_window">
            <field name="name">Partners by Categories</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner.category</field>
            <field name="view_type">tree</field>
            <field name="view_id" ref="view_partner_category_tree"/>
            <field name="domain">[('parent_id','=',False)]</field>
        </record>
        <menuitem action="action_partner_category" id="menu_partner_category_main" parent="base.menu_address_book" sequence="1"
            groups="base.group_extended"/>
        -->

        <record id="action_partner_by_category" model="ir.actions.act_window">
            <field name="name">Partner Categories</field>
            <field name="res_model">res.partner</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('category_id','child_of', [active_id])]</field>
            <field name="context">{'category_id':active_id}</field>
            <field name="search_view_id" ref="view_res_partner_filter"/>
        </record>

        <record id="ir_action_partner_by_category" model="ir.values">
            <field eval="'tree_but_open'" name="key2"/>
            <field eval="'res.partner.category'" name="model"/>
            <field name="name">Open partners</field>
            <field eval="'ir.actions.act_window,%d'%action_partner_by_category" name="value"/>
            <field eval="True" name="object"/>
        </record>

        <record id="action_partner_category_form" model="ir.actions.act_window">
            <field name="name">Partner Categories</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.partner.category</field>
            <field name="view_type">form</field>
        </record>

        <menuitem action="action_partner_category_form" id="menu_partner_category_form" name="Partner Categories" sequence="4" parent="menu_config_address_book"/>

        <act_window domain="[('partner_id', '=', active_id)]"
            id="act_res_partner_event" name="Events"
            res_model="res.partner.event"
            src_model="res.partner"
            groups="base.group_extended"
            />

        <record id="ir_ui_view_sc_partner0" model="ir.ui.view_sc">
            <field name="name">Address Book</field>
            <field name="resource">ir.ui.menu</field>
            <field name="user_id" ref="base.user_root"/>
             <field name="res_id" ref="menu_partner_form"/>
        </record>

    </data>
</openerp>
