[IMP] sales teams: in progress
authorChristophe Matthieu <chm@openerp.com>
Mon, 25 Mar 2013 10:25:55 +0000 (11:25 +0100)
committerChristophe Matthieu <chm@openerp.com>
Mon, 25 Mar 2013 10:25:55 +0000 (11:25 +0100)
bzr revid: chm@openerp.com-20130325102555-5q3j1y5dapohgax5

addons/crm/crm.py
addons/crm/crm_case_section_view.xml
addons/crm/crm_lead.py
addons/crm/static/src/css/crm.css

index d7e1fba..257e69e 100644 (file)
@@ -129,10 +129,11 @@ class crm_case_section(osv.osv):
                                     help="The email address associated with this team. New emails received will automatically "
                                          "create new leads assigned to the team."),
         'open_lead_ids': fields.one2many('crm.lead', 'section_id', 'Leads', readonly=True,
-            domain=[('type', '!=', 'opportunity'), ('state', 'not in', ['done', 'cancel'])]),
+            domain=['&', ('type', '!=', 'opportunity'), ('state', 'not in', ['done', 'cancel'])]),
         'open_opportunity_ids': fields.one2many('crm.lead', 'section_id', 'Opportunities', readonly=True,
-            domain=['&', ('type', '=', 'opportunity'), ('type', '=', 'both'), ('state', 'not in', ['done', 'cancel'])]),
+            domain=['&', '|', ('type', '=', 'opportunity'), ('type', '=', 'both'), ('state', 'not in', ['done', 'cancel'])]),
         'color': fields.integer('Color Index'),
+        'use_leads': fields.boolean('Leads', help="If checked, this sales teams will be available in the sales teams menu and you will be able to manage leads"),
     }
 
     def _get_stage_common(self, cr, uid, context):
@@ -142,6 +143,7 @@ class crm_case_section(osv.osv):
     _defaults = {
         'active': 1,
         'stage_ids': _get_stage_common,
+        'use_leads': True,
     }
 
     _sql_constraints = [
index 82e337e..446664a 100644 (file)
@@ -74,6 +74,7 @@
             <field name="model">crm.case.section</field>
             <field name="arch" type="xml">
                 <kanban version="7.0" class="oe_background_grey">
+                    <field name="use_leads"/>
                     <field name="name"/>
                     <field name="user_id"/>
                     <field name="member_ids"/>
                                 </div>
                                 <div class="oe_kanban_content">
                                     <h4><field name="name"/></h4>
-                                    <div class="oe_alias" t-if="record.alias_id.value">
+                                    <div class="oe_alias" t-if="record.use_leads.raw_value and record.alias_id.value">
                                         <span class="oe_e">%%</span><small><field name="alias_id"/></small>
                                     </div>
                                     <div class="oe_items_list">
-                                        <a name="%(crm_case_form_view_salesteams_lead)d" type="action">
+                                        <a t-if="record.use_leads.raw_value" name="%(crm_case_form_view_salesteams_lead)d" type="action">
                                             <t t-raw="record.open_lead_ids.raw_value.length"/>
                                             <t t-if="record.open_lead_ids.raw_value.length &gt;= 1">Leads</t><t t-if="record.open_lead_ids.raw_value.length &lt; 1">Lead</t></a>
                                         <a name="%(crm_case_form_view_salesteams_opportunity)d" type="action">
             <field name="arch" type="xml">
                 <form string="Sales Team" version="7.0">
                     <sheet>
+                        <div class="oe_title">
+                            <label for="name" class="oe_edit_only" string="Project Name"/>
+                            <h1>
+                                <field name="name" string="Project Name"/>
+                            </h1>
+                            <div name="options_active">
+                                <field name="use_leads" class="oe_inline"/><label for="use_leads"/>
+                            </div>
+                        </div>
                         <group>
                             <group>
-                                <field name="name" colspan="2"/>
                                 <field name="parent_id"/>
-                                <field name="code"/>
+                                <field name="resource_calendar_id"/>
+                                <field name="active"/>
                             </group>
                             <group>
                                 <field name="user_id"/>
-                                <field name="resource_calendar_id"/>
-                                <field name="active"/>
+                                <field name="code"/>
                             </group>
-                            <group colspan="4">
+                            <group colspan="4" attrs="{'invisible': [('use_leads', '=', True)]}">
                                 <label for="alias_id"/>
                                 <div class="oe_inline">
                                     <field name="alias_id" class="oe_inline oe_read_only" required="0" nolabel="1"/>
                                     <span class="oe_edit_only" name="edit_alias">
-                                        <field name="alias_name" class="oe_inline" attrs="{'required': [('alias_id', '!=', False)]}"/>@<field class="oe_inline" name="alias_domain"/>
+                                        <field name="alias_name" class="oe_inline" attrs="{'required': [('use_leads', '=', True), ('alias_id', '!=', False)]}"/>@<field class="oe_inline" name="alias_domain" readonly="1"/>
                                     </span>
                                  </div>
                             </group>
index 1f601c3..e62f33b 100644 (file)
@@ -85,9 +85,9 @@ class crm_lead(base_stage, format_address, osv.osv):
     }
 
     def get_empty_list_help(self, cr, uid, help, context=None):
-        if context.get('default_type', None) == 'lead':
+        if context.get('default_type') == 'lead':
             context['empty_list_help_model'] = 'crm.case.section'
-            context['empty_list_help_id'] = context.get('default_section_id', None)
+            context['empty_list_help_id'] = context.get('default_section_id')
             context['empty_list_help_document_name'] = _("leads")
         return super(crm_lead, self).get_empty_list_help(cr, uid, help, context=context)
 
index 5bdf51f..2815ed3 100644 (file)
@@ -52,4 +52,7 @@
 }
 .openerp .oe_kanban_view .oe_kanban_crm_salesteams .oe_center .oe_subsum {
     font-size: 10px;
+}
+.openerp .oe_form_editable .oe_form .oe_read_only {
+    display: none;
 }
\ No newline at end of file