[IMP] improve crm_partner_assing demo file
[odoo/odoo.git] / addons / crm / crm_lead_view.xml
index 113355e..62cee9f 100644 (file)
             <field name="model">crm.case.stage</field>
             <field name="arch" type="xml">
                 <search string="Stage Search">
-                    <field name="name" string="Stage Name"/>
-                    <field name="state"/>
+                    <field name="name"/>
                     <field name="type"/>
+                    <field name="sequence"/>
+                    <field name="probability"/>
                 </search>
             </field>
         </record>
@@ -78,9 +79,9 @@
                 view_type="form"/>
 
         <act_window
-                id="act_crm_opportunity_crm_meeting_new"
+                id="act_crm_opportunity_calendar_event_new"
                 name="Meetings"
-                res_model="crm.meeting"
+                res_model="calendar.event"
                 view_mode="tree,form,calendar"
                 context="{'default_duration': 4.0, 'default_opportunity_id': active_id}"
                 view_type="form"/>
             <form string="Leads Form" version="7.0">
                 <header>
                     <button name="%(crm.action_crm_lead2opportunity_partner)d" string="Convert to Opportunity" type="action"
-                            states="draft,open,pending" help="Convert to Opportunity" class="oe_highlight"/>
+                            help="Convert to Opportunity" class="oe_highlight"/>
                     <field name="stage_id" widget="statusbar" clickable="True"
                             domain="['&amp;', '|', ('case_default', '=', True), ('section_ids', '=', section_id), '|', ('type', '=', type), ('type', '=', 'both')]"
+                            options="{'fold_field': 'fold'}"
                             on_change="onchange_stage_id(stage_id)"/>
                 </header>
                 <sheet>
                     <div class="oe_right oe_button_box" name="buttons">
-                        <button string="Schedule/Log Call" 
-                                name="%(opportunity2phonecall_act)d"
-                                type="action"/>
+                        <button class="oe_inline" type="action" string="Calls" 
+                            name="%(crm.crm_case_categ_phone_incoming0)d" 
+                            context="{'default_opportunity_id': active_id, 'search_default_opportunity_id': active_id, 'default_partner_id': partner_id, 'default_duration': 1.0}"/>
                     </div>
                     <div class="oe_title">
                         <label for="name" class="oe_edit_only"/>
                             <field name="phone"/>
                             <field name="mobile"/>
                             <field name="fax"/>
-                            <!--
-                            This should be integrated in Open Chatter
-                            <button string="Mail"
-                                name="%(mail.action_email_compose_message_wizard)d"
-                                icon="terp-mail-message-new" type="action" colspan="1"/>
-                            -->
                         </group>
                         <group>
                             <field name="user_id" on_change="on_change_user(user_id, context)"
-                                context="{'default_groups_ref': ['base.group_user', 'base.group_sale_salesman_all_leads'] }"/>
+                                context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'base.group_sale_salesman_all_leads'] }"/>
                             <label for="section_id" groups="base.group_multi_salesteams"/>
                             <div groups="base.group_multi_salesteams">
                                 <field name="section_id"/>
                                 <button name="case_escalate" string="Escalate"
                                         type="object" class="oe_link"
-                                        attrs="{'invisible': ['|', ('section_id','=',False), ('state', 'not in', ['draft','open','pending'])]}"/>
+                                        attrs="{'invisible': ['|', ('section_id','=',False), ('probability', '=', 100)]}"/>
                             </div>
                             <field name="type" invisible="1"/>
                         </group>
                             <group string="Categorization" groups="base.group_multi_company,base.group_no_one" name="categorization">
                                 <field name="company_id"
                                     groups="base.group_multi_company"
-                                    widget="selection" colspan="2"/>
-                                <field name="state" groups="base.group_no_one"/>
+                                    widget="selection"/>
                             </group>
                             <group string="Mailings">
                                 <field name="opt_out"/>
                                 <field name="message_bounce"/>
                             </group>
                             <group string="Misc">
+                                <field name="probability" groups="base.group_no_one"/>
                                 <field name="active"/>
                                 <field name="referred"/>
                             </group>
+                            <group>
+                                <field name="date_open" groups="base.group_no_one"/>
+                                <field name="date_closed" groups="base.group_no_one"/>
+                            </group>
                         </group>
                     </page>
                     </notebook>
             <field name="model">crm.lead</field>
             <field name="arch" type="xml">
                 <graph string="Opportunities" type="bar">
-                    <field name="stage_id"/>
-                    <field name="planned_revenue" operator="+"/>
+                    <field name="stage_id" type="row"/>
+                    <field name="planned_revenue" type="measure"/>
                 </graph>
             </field>
         </record>
             <field name="name">Leads</field>
             <field name="model">crm.lead</field>
             <field name="arch" type="xml">
-                <tree string="Leads" fonts="bold:message_unread==True" colors="grey:state in ('cancel', 'done')">
+                <tree string="Leads" fonts="bold:message_unread==True" colors="grey:probability == 100">
                     <field name="date_deadline" invisible="1"/>
                     <field name="create_date"/>
                     <field name="name"/>
                     <field name="user_id" invisible="1"/>
                     <field name="partner_id" invisible="1"/>
                     <field name="section_id" invisible="context.get('invisible_section', True)" groups="base.group_multi_salesteams"/>
-                    <field name="state" invisible="1"/>
+                    <field name="probability" invisible="1"/>
                     <field name="type_id" invisible="1"/>
                     <field name="referred" invisible="1"/>
                     <field name="channel_id" invisible="1"/>
             <field name="model">crm.lead</field>
             <field name="arch" type="xml">
                 <kanban default_group_by="stage_id">
-                    <field name="state" groups="base.group_no_one"/>
                     <field name="stage_id"/>
                     <field name="color"/>
                     <field name="priority"/>
                                         <t t-if="widget.view.is_action_enabled('edit')"><li><a type="edit">Edit...</a></li></t>
                                         <t t-if="widget.view.is_action_enabled('delete')"><li><a type="delete">Delete</a></li></t>
                                         <li><a name="%(mail.action_email_compose_message_wizard)d" type="action">Send Email</a></li>
-                                        <li><a name="%(opportunity2phonecall_act)d" type="action">Schedule/Log Call</a></li>
-                                        <li><a name="action_makeMeeting" type="object">Schedule Meeting</a></li>
+                                        <li><a type="action" name="%(crm.crm_case_categ_phone_incoming0)d" >Calls</a></li>
+                                        <li><a name="action_schedule_meeting" type="object">Schedule Meeting</a></li>
                                         <li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
                                     </ul>
                                 </div>
             <field name="model">crm.lead</field>
             <field name="arch" type="xml">
                 <search string="Search Leads">
-                    <field name="name" string="Lead / Customer" filter_domain="['|','|',('partner_name','ilike',self),('email_from','ilike',self),('name','ilike',self)]"/>
-                    <field name="categ_ids" string="Category" filter_domain="[('categ_ids','ilike',self)]"/>
+                    <field name="name" string="Lead / Customer" filter_domain="['|','|','|',('partner_name','ilike',self),('email_from','ilike',self),('contact_name','ilike',self),('name','ilike',self)]"/>
+                    <field name="categ_ids" string="Tag" filter_domain="[('categ_ids', 'ilike', self)]"/>
                     <field name="section_id" context="{'invisible_section': False}" groups="base.group_multi_salesteams"/>
                     <field name="user_id"/>
                     <field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/>
                     <field name="create_date"/>
                     <field name="country_id" context="{'invisible_country': False}"/>
                     <separator/>
-                    <filter string="Open" name="open" domain="[('state','!=','cancel')]" help="Open Leads"/>
-                    <filter string="Dead" name="dead" domain="[('state','=','cancel')]"/>
-                    <filter string="Unassigned" name="unassigned" domain="[('user_id','=', False)]" help="No salesperson"/>
-                    <filter string="Unread Messages" name="message_unread" domain="[('message_unread','=',True)]" help="Unread messages"/>
-                    <filter string="Assigned to Me"
+                    <filter string="Unassigned" name="unassigned"
+                            domain="[('user_id','=', False)]"
+                            help="No salesperson"/>
+                    <filter string="My Leads"
                             domain="[('user_id','=',uid)]" context="{'invisible_section': False}"
                             help="Leads that are assigned to me"/>
-                    <filter string="Assigned to My Team(s)"
+                    <filter string="My Team(s)" groups="base.group_multi_salesteams"
                             domain="[('section_id.member_ids', 'in', [uid])]" context="{'invisible_section': False}"
-                            help="Leads that are assigned to any sales teams I am member of" groups="base.group_multi_salesteams"/>
+                            help="Leads that are assigned to any sales teams I am member of"/>
+                    <filter string="Dead" name="dead"
+                            domain="[('probability', '=', '0'), ('stage_id.fold', '=', True)]"/>
+                    <filter string="Unread Messages" name="message_unread" domain="[('message_unread','=',True)]"/>
                     <separator />
                     <filter string="Available for mass mailing"
                             name='not_opt_out' domain="[('opt_out', '=', False)]"
                         <filter string="Campaign" domain="[]" context="{'group_by':'type_id'}"/>
                         <filter string="Channel" domain="[]" context="{'group_by':'channel_id'}"/>
                         <filter string="Creation" domain="[]" context="{'group_by':'create_date'}"/>
+                        <filter string="Last Post (weekly)" name="group_message_last_post" domain="[]" context="{'group_by':'message_last_post:week'}"/>
                     </group>
                     <group string="Display">
                         <filter string="Show Countries" context="{'invisible_country': False}" help="Show Countries"/>
             <field name="arch" type="xml">
                 <form string="Opportunities" version="7.0">
                     <header>
-                        <button name="case_mark_won" string="Mark Won" type="object"
-                                states="draft,open,pending" class="oe_highlight"/>
-                        <button name="case_mark_lost" string="Mark Lost" type="object"
-                                states="draft,open" class="oe_highlight"/>
-                        <field name="stage_id" widget="statusbar" clickable="True"/>
+                        <button name="case_mark_won" string="Mark Won" type="object" class="oe_highlight"/>
+                        <button name="case_mark_lost" string="Mark Lost" type="object" class="oe_highlight"/>
+                        <field name="stage_id" widget="statusbar" clickable="True"
+                            options="{'fold_field': 'fold'}"
+                            domain="['&amp;', ('section_ids', '=', section_id), '|', ('type', '=', type), ('type', '=', 'both')]"/>
                     </header>
                     <sheet>
                         <div class="oe_right oe_button_box">
-                            <button string="Schedule/Log Call"
-                                name="%(opportunity2phonecall_act)d"
-                                type="action"/>
-                            <button string="Meeting"
-                                name="action_makeMeeting"
-                                type="object"
-                                context="{'search_default_attendee_id': active_id, 'default_attendee_id' : active_id}"/>
+                            <button class="oe_inline" type="action" string="Calls" 
+                                name="%(crm.crm_case_categ_phone_incoming0)d" 
+                                context="{'default_opportunity_id': active_id, 'search_default_opportunity_id': active_id, 'default_partner_id': partner_id, 'default_duration': 1.0}"/>
+                            <button class="oe_inline" string="Schedule a Meeting" type="object"
+                                name="action_schedule_meeting" context="{'partner_id': partner_id}"/>
                         </div>
                         <div class="oe_title">
                             <label for="name" class="oe_edit_only"/>
                                     on_change="on_change_partner_id(partner_id)"
                                     string="Customer"
                                     context="{'default_name': partner_name, 'default_email': email_from, 'default_phone': phone}"/>
-                                <field name="email_from" string="Email"/>
+                                <field name="email_from" string="Email" widget="email"/>
                                 <field name="phone"/>
                             </group>
 
                             </group>
 
                             <group>
-                                <field name="user_id" on_change="on_change_user(user_id, context)" context="{'default_groups_ref': ['base.group_user', 'base.group_sale_salesman_all_leads']}"/>
+                                <field name="user_id" on_change="on_change_user(user_id, context)" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'base.group_sale_salesman_all_leads']}"/>
                                 <label for="section_id" groups="base.group_multi_salesteams"/>
                                 <div groups="base.group_multi_salesteams">
                                     <field name="section_id" widget="selection"/>
-                                    <button name="case_escalate" string="Escalate" type="object" class="oe_link" attrs="{'invisible': ['|', ('section_id','=',False), ('state', 'not in', ['draft','open','pending'])]}"/>
+                                    <button name="case_escalate" string="Escalate" type="object" class="oe_link"
+                                            attrs="{'invisible': ['|', ('section_id','=',False), ('probability', '=', 100)]}"/>
                                 </div>
                             </group>
                             <group>
                                 <field name="categ_ids"
-                                    string="Categories" widget="many2many_tags"
+                                    widget="many2many_tags"
                                     context="{'object_name': 'crm.lead'}"
                                     domain="[('object_id.model', '=', 'crm.lead')]"/>
 
                                     <field name="day_open" groups="base.group_no_one"/>
                                     <field name="day_close" groups="base.group_no_one"/>
                                     <field name="referred"/>
-                                    <field name="state" invisible="1"/>
                                     <field name="type" invisible="1"/>
                                 </group>
                                 <group string="References">
             <field name="name">Opportunities Tree</field>
             <field name="model">crm.lead</field>
             <field name="arch" type="xml">
-                <tree string="Opportunities" fonts="bold:message_unread==True" colors="gray:state in ('cancel', 'done');red:date_deadline and (date_deadline &lt; current_date)">
+                <tree string="Opportunities" fonts="bold:message_unread==True" colors="gray:probability == 100;red:date_deadline and (date_deadline &lt; current_date)">
                     <field name="date_deadline" invisible="1"/>
                     <field name="create_date"/>
                     <field name="name" string="Opportunity"/>
                     <field name="referred" invisible="1"/>
                     <field name="priority" invisible="1"/>
                     <field name="message_unread" invisible="1"/>
-                    <field name="state" invisible="1"/>
+                    <field name="probability" invisible="1"/>
+                    <field name="write_date" invisible="1"/>
                 </tree>
             </field>
         </record>
             <field name="arch" type="xml">
                 <search string="Search Opportunities">
                     <field name="name" string="Opportunity" filter_domain="['|','|','|',('partner_id','ilike',self),('partner_name','ilike',self),('email_from','ilike',self),('name', 'ilike', self)]"/>
-                    <field name="categ_ids" string="Category" filter_domain="[('categ_ids','ilike', self)]"/>
+                    <field name="categ_ids" string="Tag" filter_domain="[('categ_ids', 'ilike', self)]"/>
                     <field name="section_id" context="{'invisible_section': False}" groups="base.group_multi_salesteams"/>
                     <field name="user_id"/>
                     <field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/>
+                    <field name="stage_id" domain="[]"/>
+                    <field name="probability"/>
                     <separator/>
-                    <filter string="New" name="new" domain="[('state','=','draft')]" help="New Opportunities"/>
-                    <filter string="In Progress" name="open" domain="[('state','=','open')]" help="Open Opportunities"/>
-                    <filter string="Won" name="won" domain="[('state','=','done')]"/>
-                    <filter string="Lost" name="lost" domain="[('state','=','cancel')]"/>
-                    <filter string="Unassigned" name="unassigned" domain="[('user_id','=', False)]" help="No salesperson"/>
-                    <filter string="Unread Messages" name="message_unread" domain="[('message_unread','=',True)]" help="Unread messages"/>
+                    <filter string="Won" name="won"
+                            domain="[('probability', '=', 100), ('stage_id.fold', '=', True)]"/>
+                    <filter string="Lost" name="lost"
+                            domain="[('probability', '=', 0), ('stage_id.fold', '=', True)]"/>
+                    <filter string="Unassigned" name="unassigned"
+                            domain="[('user_id','=', False)]" help="No salesperson"/>
                     <filter string="My Opportunities" name="assigned_to_me"
-                            domain="[('user_id','=',uid)]" context="{'invisible_section': False}"
+                            domain="[('user_id', '=', uid)]" context="{'invisible_section': False}"
                             help="Opportunities that are assigned to me"/>
-                    <filter string="Assigned to My Team(s)"
+                    <filter string="My Team(s)"
                             domain="[('section_id.member_ids', 'in', [uid])]" context="{'invisible_section': False}"
                             help="Opportunities that are assigned to any sales teams I am member of"/>
+                    <filter string="Unread Messages" name="message_unread" domain="[('message_unread','=',True)]"/>
                     <separator/>
                     <group expand="0" string="Group By..." colspan="16">
                         <filter string="Salesperson" domain="[]" context="{'group_by':'user_id'}"/>
                         <filter string="Campaign" domain="[]" context="{'group_by':'type_id'}"/>
                         <filter string="Channel" domain="[]" context="{'group_by':'channel_id'}"/>
                         <filter string="Creation" domain="[]" context="{'group_by':'create_date'}"/>
+                        <filter string="Last Update Month" domain="[]" context="{'group_by':'write_date'}"/>
+                        <filter string="Last Post (weekly)" name="group_message_last_post" domain="[]" context="{'group_by':'message_last_post:week'}"/>
                     </group>
                     <group string="Display">
                         <filter string="Show Sales Team" context="{'invisible_section': False}" domain="[]" help="Show Sales Team" groups="base.group_multi_salesteams"/>
                 id="crm.action_lead_mass_mail"
                 context="{
                             'default_composition_mode': 'mass_mail',
-                            'default_email_to':'{$object.email or \'\'}',
+                            'default_email_to':'{($object.email or \'\')|safe}',
                             'default_use_template': True,
                             'default_template_id': ref('crm.email_template_opportunity_mail'),
                         }"
                 if context.get('active_model') == 'crm.lead' and context.get('active_ids'):
                     self.case_mark_lost(cr, uid, context['active_ids'], context=context)
             </field>
-            <field name="groups_id" eval="[(4,ref('base.group_sale_salesman'))]"/>
         </record>
 
         <record id="ir_mark_as_lost" model="ir.values">