<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <menuitem icon="terp-partner" id="menu_base_partner" name="Sales" sequence="0"
                  web_icon="data/sales.png"
                  web_icon_hover="data/sales-hover.png"
                  groups="base.group_sale_salesman"/>

        <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" string="Partner"/>
                        <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="active"/>
                        <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">Customers (also called Partners in other areas of the system) helps you manage your address book of companies whether they are prospects, customers and/or suppliers. The partner form allows you to track and record all the necessary information to interact with your partners from the company address to their contacts as well as pricelists, and much more. If you installed the CRM, with the history tab, you can track all the interactions with a partner such as opportunities, emails, or sales orders issued.</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" name="Contacts"
            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>
            <field name="help">Manage the partner titles you want to have available in your system. The partner titles is the legal status of the company: Private Limited, SA, etc.</field>
        </record>

        <menuitem action="action_partner_title_partner" id="menu_partner_title_partner" 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>
            <field name="help">Manage the contact titles you want to have available in your system and the way you want to print them in letters and other documents. Some example: Mr., Mrs. </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" groups="base.group_extended"/>
                            <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" invisible="True">
                        </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" groups="base.group_extended"/>
                        <field name="user_id" select="1">
                            <filter help="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">A customer is an entity you do business with, like a company or an organization. A customer can have several contacts or addresses which are the people working for this company. You can use the history tab, to follow all transactions related to a customer: sales order, emails, opportunities, claims, etc. If you use the email gateway, the Outlook or the Thunderbird plugin, don't forget to register emails to each contact so that the gateway will automatically attach incoming emails to the right partner.</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">{'search_default_supplier': 1}</field>
            <field name="filter" eval="True"/>
            <field name="help">You can access all information regarding your suppliers from the supplier form: accounting data, history of emails, meetings, purchases, etc. You can uncheck the 'Suppliers' filter button in order to search in all your partners, including customers and prospects.</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>
        <!--
          ======================
          Categories
          ======================
        -->
        <record id="view_partner_category_form" model="ir.ui.view">
            <field name="name">Partner Categories</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">Partner Categories</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>
            <field name="help">Manage the partner categories in order to better classify them for tracking and analysis purposes. A partner may belong to several categories and categories have a hierarchy structure: a partner belonging to a category also belong to his parent category.</field>
        </record>

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

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

    </data>
</openerp>
