[IMP, ADD]: Improved wizards code. Added opportunity2meeting wizard on business oppor...
authoruco (OpenERP) <uco@tinyerp.co.in>
Wed, 13 Jan 2010 06:41:10 +0000 (12:11 +0530)
committeruco (OpenERP) <uco@tinyerp.co.in>
Wed, 13 Jan 2010 06:41:10 +0000 (12:11 +0530)
bzr revid: uco@tinyerp.co.in-20100113064110-z4q6041wr86gbv7w

addons/crm/crm_lead_view.xml
addons/crm/crm_opportunity_view.xml
addons/crm/crm_opportunity_wizard.xml
addons/crm/wizard/crm_lead_wizard.py
addons/crm/wizard/crm_opportunity_wizard.py
addons/crm/wizard/crm_phonecall_wizard.py

index 3bbf1ac..0776699 100644 (file)
                     </group>
                     <field name="categ_id" select="1" on_change="onchange_categ_id(categ_id)" string="Lead Source"/>
                     <field name="category2_id" string="Campaign Type" select="1"/>
-                    <newline/>
-                    <field name="opportunity_id" string="Opportunity Case"/>
-                    <button string="Convert to Opportunity" name="%(wizard_crm_lead_opportunity_set)d" icon="gtk-index" type="action"/>
+                </group>
+                <group colspan="2" col="4">
+                       <field name="opportunity_id" string="Opportunity Case"/>
+                       <button string="Convert to Opportunity" name="%(wizard_crm_lead_opportunity_set)d" icon="gtk-index" type="action"/>
                 </group>
                 <notebook colspan="4">
                 <page string="Leads">
index cbd76c2..c6ed8b5 100644 (file)
@@ -55,7 +55,7 @@
                     <field name="section_id" colspan="1" widget="selection"/>
                     <field name="user_id" select="2" string="Responsible"/>
                                        <button string="Schedule a Meeting"
-                        name="%(wizard_crm_phonecall_meeting_set)d" icon="gtk-redo" type="action" />
+                        name="%(wizard_crm_opportunity_meeting_set)d" icon="gtk-redo" type="action" />
                         <newline/>
                         <label string="Sales Stage: " align="1.0"/>
                         <group colspan="1" col="2">
index d8b880e..5ba7ed0 100644 (file)
             name="crm.case.opportunity.partner_opportunity"
             menu="False"
             string="Create Opportunity"/>
-
-        
-            
+         
+         <wizard
+            id="wizard_crm_opportunity_meeting_set"
+            keyword="client_action_multi"
+            model="crm.opportunity"
+                       name="crm.opportunity.meeting_set"
+                       menu="False"
+            string="Schedule Meeting"/>        
+       
           <wizard
           id="wizard_partner_create_opportunity1"
             keyword="client_action_relate"
index 280d56a..fb48955 100644 (file)
@@ -115,7 +115,7 @@ class lead2opportunity(wizard.interface):
 
             lead_case_obj.write(cr, uid, [lead.id], vals)
             lead_case_obj.case_cancel(cr, uid, [lead.id])
-      #      opportunity_case_obj.case_open(cr, uid, [new_opportunity_id])
+            opportunity_case_obj.case_open(cr, uid, [new_opportunity_id])
         
         value = {            
             'name': _('Opportunity'),
index 5cd188e..d6ef051 100644 (file)
@@ -123,6 +123,75 @@ class opportunity2phonecall(wizard.interface):
 
 opportunity2phonecall('crm.opportunity.reschedule_phone_call')
 
+class opportunity2meeting(wizard.interface):
+    case_form = """<?xml version="1.0"?>
+    <form string="Plan Meeting">
+        <field name="date"/>
+        <field name="duration" widget="float_time"/>
+        <label string="Note that you can also use the calendar view to graphically schedule your next meeting." colspan="4"/>
+    </form>"""
+
+    case_fields = {
+        'date': {'string': 'Meeting date', 'type': 'datetime', 'required': 1},
+        'duration': {'string': 'Duration (Hours)', 'type': 'float', 'required': 1}
+    }
+
+    def _selectPartner(self, cr, uid, data, context):
+        case_obj = pooler.get_pool(cr.dbname).get('crm.opportunity')
+        case = case_obj.browse(cr, uid, data['id'])
+        return {'date': case.date, 'duration': 2.0}
+
+    def _makeMeeting(self, cr, uid, data, context):
+        pool = pooler.get_pool(cr.dbname)
+        opportunity_case_obj = pool.get('crm.opportunity')
+        meeting_case_obj = pool.get('crm.meeting')        
+        for opportunity in opportunity_case_obj.browse(cr, uid, data['ids']):
+            new_meeting_id = meeting_case_obj.create(cr, uid, {
+                'name': opportunity.name,
+                'date': data['form']['date'],
+                'duration': data['form']['duration'],
+                })
+            new_meeting = meeting_case_obj.browse(cr, uid, new_meeting_id)
+            vals = {}
+            opportunity_case_obj.write(cr, uid, [opportunity.id], vals)
+            opportunity_case_obj.case_cancel(cr, uid, [opportunity.id])
+            meeting_case_obj.case_open(cr, uid, [new_meeting_id])
+
+        data_obj = pool.get('ir.model.data')
+        result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
+        id = data_obj.read(cr, uid, result, ['res_id'])
+        id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet')
+        id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet')
+        id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet')
+        if id1:
+            id1 = data_obj.browse(cr, uid, id1, context=context).res_id
+        if id2:
+            id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+        if id3:
+            id3 = data_obj.browse(cr, uid, id3, context=context).res_id
+        return {            
+            'name': _('Meetings'),
+            'view_type': 'form',
+            'view_mode': 'calendar,form,tree',
+            'res_model': 'crm.meeting',
+            'view_id': False,
+            'views': [(id1,'calendar'),(id2,'form'),(id3,'tree'),(False,'graph')],
+            'type': 'ir.actions.act_window',
+            'search_view_id': id['res_id']
+            }
+
+    states = {
+        'init': {
+            'actions': [_selectPartner],
+            'result': {'type': 'form', 'arch': case_form, 'fields': case_fields,
+                'state' : [('end', 'Cancel','gtk-cancel'),('order', 'Set Meeting','gtk-go-forward')]}
+        },
+        'order': {
+            'actions': [],
+            'result': {'type': 'action', 'action': _makeMeeting, 'state': 'end'}
+        }
+    }
+opportunity2meeting('crm.opportunity.meeting_set')
 
 class partner_opportunity(wizard.interface):
 
index 7efbaa5..227b874 100644 (file)
@@ -113,7 +113,7 @@ class phonecall2opportunity(wizard.interface):
                 vals.update({'opportunity_id' : new_opportunity.id})
             phonecall_case_obj.write(cr, uid, [phonecall.id], vals)
             phonecall_case_obj.case_cancel(cr, uid, [phonecall.id])
-         #   opportunity_case_obj.case_open(cr, uid, [new_opportunity_id])
+            opportunity_case_obj.case_open(cr, uid, [new_opportunity_id])
         value = {            
             'name': _('Opportunity'),
             'view_type': 'form',