[imp] improved lead and opportunity
authorHardik Ansodariy (OpenERP) <han@tinyerp.com>
Thu, 13 Oct 2011 09:38:04 +0000 (15:08 +0530)
committerHardik Ansodariy (OpenERP) <han@tinyerp.com>
Thu, 13 Oct 2011 09:38:04 +0000 (15:08 +0530)
bzr revid: han@tinyerp.com-20111013093804-phr519y2k9vcy17d

addons/crm/crm_lead_demo.xml
addons/crm/crm_lead_view.xml
addons/crm/report/crm_lead_report_view.xml
addons/crm/wizard/crm_lead_to_partner.py
addons/crm/wizard/crm_opportunity_to_phonecall.py
addons/crm/wizard/crm_opportunity_to_phonecall_view.xml

index 390932c..ec6620f 100644 (file)
             <field name="categ_id" ref="crm.categ_oppor3"/>
             <field name="stage_id" ref="crm.stage_lead2"/>
             <field eval="'Pricing Information of Onsite Intervention'" name="name"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 1) +'/'+ time.strftime('%d')" name="date_action"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 2) +'/'+ time.strftime('%d')" name="date_deadline"/>
            <field eval="'Send price list regarding our interventions'" name="title_action"/>
             <field name="partner_name">BalmerInc S.A.</field>
             <field name="street">Rue des Palais 51, bte 33</field>
             <field name="categ_id" ref="crm.categ_oppor3"/>
             <field name="stage_id" ref="crm.stage_lead2"/>
             <field eval="'Interest in your Kitchen Design Project'" name="name"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 1) +'/'+ time.strftime('%d')" name="date_action"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 2) +'/'+ time.strftime('%d')" name="date_deadline"/>
            <field eval="'Send Catalogue by E-Mail'" name="title_action"/>
             <field name="partner_name">Lucie Vonck</field>
             <field name="street">Chaussée de Namur</field>
             <field name="categ_id" ref="crm.categ_oppor6"/>
             <field name="stage_id" ref="crm.stage_lead2"/>
             <field eval="'Plan train our students on your product'" name="name"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 1) +'/'+ time.strftime('%d')" name="date_action"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 2) +'/'+ time.strftime('%d')" name="date_deadline"/>
            <field eval="'Call to define real needs about training'" name="title_action"/>
             <field eval="4000" name="zip"/>
             <field name="partner_name">Université de Liège</field>
             <field name="categ_id" ref="crm.categ_oppor2"/>
             <field name="stage_id" ref="crm.stage_lead2"/>
             <field eval="'Plan to buy 66 keyboards and 66 mouses'" name="name"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 1) +'/'+ time.strftime('%d')" name="date_action"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 2) +'/'+ time.strftime('%d')" name="date_deadline"/>
            <field eval="'Propose the kit keyboard+mouse'" name="title_action"/>
             <field name="partner_name">Bank Wealthy and sons</field>
             <field name="street">1 rue Rockfeller</field>
             <field name="categ_id" ref="crm.categ_oppor7"/>
             <field name="stage_id" ref="crm.stage_lead5"/>
             <field eval="'Need 20 Days of Consultancy'" name="name"/>
+            <field eval="time.strftime('%Y-%m-%d')" name="date_deadline"/>
             <field eval="'info@mycompany.net'" name="email_from"/>
         </record>
         <record id="crm_case_abcfuelcounits0" model="crm.lead">
             <field name="categ_id" ref="crm.categ_oppor5"/>
             <field name="stage_id" ref="crm.stage_lead4"/>
             <field eval="'Need new design for my website'" name="name"/>
+            <field eval="time.strftime('%Y') +'/'+ time.strftime('%m') +'/'+ str(int(time.strftime('%d')) + 15)" name="date_action"/>
+            <field eval="time.strftime('%Y') +'/'+ time.strftime('%m') +'/'+ str(int(time.strftime('%d')) + 15)" name="date_deadline"/>
             <field eval="'info@opensides.be'" name="email_from"/>
            <field eval="'Convert to quote'" name="title_action"/>
             <field name="partner_name">Dubois sprl</field>
             <field name="categ_id" ref="crm.categ_oppor2"/>
             <field name="stage_id" ref="crm.stage_lead2"/>
             <field eval="'Plan to attend a training'" name="name"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 1) +'/'+ time.strftime('%d')" name="date_action"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 2) +'/'+ time.strftime('%d')" name="date_deadline"/>
            <field eval="'Call to give info about next training session'" name="title_action"/>
             <field name="partner_name">Axelor</field>
             <field name="street">12 rue Albert Einstein</field>
             <field name="categ_id" ref="crm.categ_oppor1"/>
             <field name="stage_id" ref="crm.stage_lead3"/>
             <field eval="'Need customize the solution'" name="name"/>
+            <field eval="time.strftime('%Y') +'/'+ time.strftime('%m') +'/'+ str(int(time.strftime('%d')) + 15)" name="date_action"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 1) +'/'+ time.strftime('%d')" name="date_deadline"/>
             <field eval="'Conf call with technical service'" name="title_action"/>
             <field name="partner_name">Thymbra</field>
             <field name="street">Palermo, Capital Federal</field>
             <field name="categ_id" ref="crm.categ_oppor1"/>
             <field name="stage_id" ref="crm.stage_lead3"/>
             <field eval="'Interest in your customizable PC'" name="name"/>
+            <field eval="time.strftime('%Y') +'/'+ time.strftime('%m') +'/'+ str(int(time.strftime('%d')) + 15)" name="date_action"/>
+            <field eval="time.strftime('%Y') +'/'+ str(int(time.strftime('%m')) + 1) +'/'+ time.strftime('%d')" name="date_deadline"/>
             <field eval="'Ask for the good receprion of the proposition'" name="title_action"/>
             <field name="partner_name">Eric Dubois</field>
             <field name="street">Chaussée de Binche, 27</field>
index 42587ee..350e85b 100644 (file)
                     <field name="user_id"/>
 
                     <button string="Schedule/Log Call"
-                    name="%(opportunity2phonecall_act)d" icon="terp-call-start" type="action" groups="base.group_extended"/>
+                    name="%(opportunity2phonecall_act)d" icon="terp-call-start" type="action"/>
 
                     <field name="planned_revenue"/>
                     <field name="probability"/>
index 4c165d5..18d4f56 100644 (file)
             parent="base.next_id_64" action="action_report_crm_lead" sequence="3"/>
 
        <menuitem name="Opportunities Analysis" id="menu_report_crm_opportunities_tree"
-            groups="base.group_extended"
             parent="base.next_id_64" action="action_report_crm_opportunity" sequence="4"/>
 
     </data>
index 88ccacf..65ecdca 100644 (file)
@@ -86,8 +86,20 @@ class crm_lead2partner(osv.osv_memory):
                     partner_ids = partner_obj.search(cr, uid, [('address', 'in', address_ids)], context=context)
                     
             # Find partner name that matches the name of the lead
-            if not partner_ids and lead.partner_name:
-                partner_ids = partner_obj.search(cr, uid, [('name', '=', lead.partner_name)], context=context)
+            if type(lead.partner_name).__name__ == 'unicode':
+                partner_name = str(lead.partner_name)
+            partner_name = partner_name.capitalize()
+            partner = ''
+            upper = False
+            for name in partner_name:
+                   if upper:
+                           partner+=name.upper()
+                   else:
+                           partner+=name
+                   upper = name.isspace()
+               
+            if not partner_ids and partner:
+                partner_ids = partner_obj.search(cr, uid, [('name', '=', partner)], context=context)
                 
             partner_id = partner_ids and partner_ids[0] or False
             
index 7143767..b0bfbf3 100644 (file)
@@ -35,13 +35,16 @@ class crm_opportunity2phonecall(osv.osv_memory):
     _columns = {
         'name' : fields.char('Call summary', size=64, required=True, select=1),
         'user_id' : fields.many2one('res.users', "Assign To"),
+        'contact_name':fields.char('Contact', size=64),
+        'phone':fields.char('Phone', size=64),
         'partner_id' : fields.many2one('res.partner', "Partner"),
         'date': fields.datetime('Date'),
         'section_id': fields.many2one('crm.case.section', 'Sales Team'),
         'categ_id': fields.many2one('crm.case.categ', 'Category',  \
                         domain="['|',('section_id','=',False),('section_id','=',section_id),\
                         ('object_id.model', '=', 'crm.phonecall')]"),
-        'action': fields.selection([('schedule','Schedule a call'), ('log','Log a call')], 'Action', required=True), 
+        'action': fields.selection([('schedule','Schedule a call'), ('log','Log a call')], 'Action', required=True),
+        'note':fields.text('Note'), 
     }
 
     def default_get(self, cr, uid, fields, context=None):
@@ -64,7 +67,7 @@ class crm_opportunity2phonecall(osv.osv_memory):
 
         record_ids = context and context.get('active_ids', []) or []
         res = super(crm_opportunity2phonecall, self).default_get(cr, uid, fields, context=context)
-        res.update({'action': 'schedule', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
+        res.update({'action': 'log', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
         for opp in opp_obj.browse(cr, uid, record_ids, context=context):
             if 'name' in fields:
                 res.update({'name': opp.name})
@@ -76,6 +79,12 @@ class crm_opportunity2phonecall(osv.osv_memory):
                 res.update({'categ_id': categ_id})
             if 'partner_id' in fields:
                 res.update({'partner_id': opp.partner_id and opp.partner_id.id or False})
+            if 'note' in fields:
+                res.update({'note': opp.description})
+            if 'contact_name' in fields:
+                res.update({'contact_name': opp.partner_address_id and opp.partner_address_id.name or False})
+            if 'phone' in fields:
+                res.update({'phone': opp.phone or (opp.partner_address_id and opp.partner_address_id.phone or False)})
         return res
 
     def action_cancel(self, cr, uid, ids, context=None):
@@ -142,6 +151,7 @@ class crm_opportunity2phonecall(osv.osv_memory):
                
                 if this.action == 'log':
                     phonecall_obj.case_close(cr, uid, [new_case])
+                    return {'type': 'ir.actions.act_window_close'}
 
             value = {
                 'name': _('Phone Call'),
index 764648a..980b935 100644 (file)
                     <field name="name"/>
                     <field name="date" string="Planned Date" attrs="{'invisible': [('action','=','log')]}"/>
                     <newline/>
-                    <field name="partner_id" readonly="True"/>
-                    <field name="user_id" />                    
-                    <field name="section_id" widget="selection" />
-                    <field name="categ_id" string="Type" widget="selection" domain="[('object_id.model', '=', 'crm.phonecall')]"/>
+                    <group colspan="4">
+                        <field name="partner_id" readonly="True"/>
+                        <field name="categ_id" string="Type" widget="selection" domain="[('object_id.model', '=', 'crm.phonecall')]"/>
+                        <field name="contact_name"/>
+                        <field name="phone"/>
+                    </group>
+                    <group colspan="4">
+                        <field name="user_id" attrs="{'invisible': [('action','=','log')]}"/>                    
+                        <field name="section_id" widget="selection" attrs="{'invisible': [('action','=','log')]}"/>
+                    </group>
+                    <group colspan="4">
+                        <field name="note"/>
+                    </group>
                     <separator string="" colspan="4"/>
                     <group colspan="4" col="3">
                         <button name="action_cancel" string="_Cancel" icon="gtk-cancel" special="cancel" />