← Back to team overview

openerp-dev-web team mailing list archive

lp:~openerp-dev/openobject-addons/addons1-crm-imp-uco-convert-opportunity into lp:~openerp-dev/openobject-addons/addons1-crm-imp

 

Ujjvala Collins (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/addons1-crm-imp-uco-convert-opportunity into lp:~openerp-dev/openobject-addons/addons1-crm-imp.

Requested reviews:
  OpenERP R&D Team (openerp-dev)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/addons1-crm-imp-uco-convert-opportunity/+merge/48605

4. Simplification of wizard convert to opportunity
Current behavior
    * step 1 : Create new partner, link with an existing one, or do not create partner
       * By default link with a partner if a partner with a name similar to the subject is found otherwise create a new partner
    *  step 2 : New opportunity, or merge
        *  step 2.1 : if merge : new windows with the merge wizard
        *  step 2.2 : if create a new opportunity, a windows to set some details of the new opportunity

Expected behavior
Only one step, one windows :
    * First part of the windows for the combobox "create new partner, link with partner"
    * By default : link with a partner if a partner with the same name is found otherwise create a new partner 
    * Second part of the windows : a combobox with new opportunity or merge
    * The many2many field of the step 2.1 has to be in the same windows but invisible unless "merge opportunity is selected"

When the lead is converted
    * Set next action date today on the converted opportunity (skip last windows) (merge wizard in one windows)

We delete the step 2.2 those information can be modify once the window of the new opportunity is open
So if we want to create a new opportunity with a new partner, only have to click on convert to opportunity and in the wizard on convert
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/addons1-crm-imp-uco-convert-opportunity/+merge/48605
Your team OpenERP R&D Team is requested to review the proposed merge of lp:~openerp-dev/openobject-addons/addons1-crm-imp-uco-convert-opportunity into lp:~openerp-dev/openobject-addons/addons1-crm-imp.
=== modified file 'crm/crm_lead.py'
--- crm/crm_lead.py	2011-01-17 13:57:06 +0000
+++ crm/crm_lead.py	2011-02-04 13:12:25 +0000
@@ -246,46 +246,28 @@
         context.update({'active_ids': ids})
 
         data_obj = self.pool.get('ir.model.data')
-        data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_action')
         value = {}
 
         view_id = False
-        if data_id:
-            view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
 
-        for case in self.browse(cr, uid, ids):
+        for case in self.browse(cr, uid, ids, context=context):
             context.update({'active_id': case.id})
-            if not case.partner_id:
-                data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_partner')
-                view_id1 = False
-                if data_id:
-                    view_id1 = data_obj.browse(cr, uid, data_id, context=context).res_id
-                value = {
-                        'name': _('Create Partner'),
-                        'view_type': 'form',
-                        'view_mode': 'form,tree',
-                        'res_model': 'crm.lead2opportunity.partner',
-                        'view_id': False,
-                        'context': context,
-                        'views': [(view_id1, 'form')],
-                        'type': 'ir.actions.act_window',
-                        'target': 'new',
-                        'nodestroy': True
-                        }
-                break
-            else:
-                value = {
-                        'name': _('Create Opportunity'),
-                        'view_type': 'form',
-                        'view_mode': 'form,tree',
-                        'res_model': 'crm.lead2opportunity.action',
-                        'view_id': False,
-                        'context': context,
-                        'views': [(view_id, 'form')],
-                        'type': 'ir.actions.act_window',
-                        'target': 'new',
-                        'nodestroy': True
-                        }
+            data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_partner')
+            view_id1 = False
+            if data_id:
+                view_id1 = data_obj.browse(cr, uid, data_id, context=context).res_id
+            value = {
+                    'name': _('Create Partner'),
+                    'view_type': 'form',
+                    'view_mode': 'form,tree',
+                    'res_model': 'crm.lead2opportunity.partner',
+                    'view_id': False,
+                    'context': context,
+                    'views': [(view_id1, 'form')],
+                    'type': 'ir.actions.act_window',
+                    'target': 'new',
+                    'nodestroy': True
+            }
         return value
 
     def write(self, cr, uid, ids, vals, context=None):

=== modified file 'crm/test/test_crm_lead.yml'
--- crm/test/test_crm_lead.yml	2011-01-14 00:11:01 +0000
+++ crm/test/test_crm_lead.yml	2011-02-04 13:12:25 +0000
@@ -60,24 +60,12 @@
 -
    !record {model: crm.lead2opportunity.partner, id: crm_lead2opportunity_partner_create_0}:
       action: 'create'
+      name: 'convert'
 -
-   I click on "Continue" button of this wizard.
+  Then, Click on "Create Opportunity" button of this wizard.
 -
    !python {model: crm.lead2opportunity.partner}: |
-      self.make_partner(cr, uid, [ref("crm_lead2opportunity_partner_create_0")], {'active_ids': [ref("crm_lead_newcustomer0")]})
--
-  Now, I give value to this wizard field.
--
-  !record {model: crm.lead2opportunity, id: crm_lead2opportunity_stonage_0}:
-      name:  Capegemini
-      planned_revenue: 0.00
-      probability: 0.00
--
-  Then, Click on "Create Opportunity" button of this wizard.
--
-  !python {model: crm.lead2opportunity}: |
-     self.action_apply(cr, uid, [ref('crm_lead2opportunity_stonage_0')], {'active_id': ref('crm_lead_newcustomer0')})
-
+      self.action_apply(cr, uid, [ref("crm_lead2opportunity_partner_create_0")], {'active_ids': [ref("crm_lead_newcustomer0")], 'active_id': ref("crm_lead_newcustomer0")})
 -  |
    In order to check the opportunity is created or not, I check type.
 -

=== modified file 'crm/test/test_crm_stage_changes.yml'
--- crm/test/test_crm_stage_changes.yml	2011-01-11 07:21:12 +0000
+++ crm/test/test_crm_stage_changes.yml	2011-02-04 13:12:25 +0000
@@ -32,15 +32,14 @@
 -
   I find that this lead can be converted to opportunity. 
 -
-  !record {model: crm.lead2opportunity, id: crm_lead2opportunity0}:
-    name: OpenERP Presentation
-    probability: 60.0
-    planned_revenue: 45000.0
+  !record {model: crm.lead2opportunity.partner, id: crm_lead2opportunity_partner0}:
+    action: 'create'
+    name: 'convert'
 -
   So I convert the lead to opportunity.
 -
-  !python {model: crm.lead2opportunity}: |
-    self.action_apply(cr, uid, [ref('crm_lead2opportunity0')], context={'active_id': ref('crm_lead_openerppresentation0')})
+  !python {model: crm.lead2opportunity.partner}: |
+    self.action_apply(cr, uid, [ref('crm_lead2opportunity_partner0')], context={'active_ids': [ref('crm_lead_openerppresentation0')]})
 -
   I check that lead is now converted to opportunity.
 -

=== modified file 'crm/wizard/crm_lead_to_opportunity.py'
--- crm/wizard/crm_lead_to_opportunity.py	2011-01-25 10:15:05 +0000
+++ crm/wizard/crm_lead_to_opportunity.py	2011-02-04 13:12:25 +0000
@@ -22,23 +22,40 @@
 from osv import osv, fields
 from tools.translate import _
 
-
-class crm_lead2opportunity(osv.osv_memory):
-    _name = 'crm.lead2opportunity'
-    _description = 'Lead To Opportunity'
-
-    def action_cancel(self, cr, uid, ids, context=None):
+import time
+
+class crm_lead2opportunity_partner(osv.osv_memory):
+    _name = 'crm.lead2opportunity.partner'
+    _description = 'Lead To Opportunity Partner'
+    _inherit = 'crm.lead2partner'
+
+    _columns = {
+        'partner_id': fields.many2one('res.partner', 'Partner'),
+        'action': fields.selection([('exist', 'Link to an existing partner'), ('create', 'Create a new partner')], 'Action'),
+        'name': fields.selection([('convert', 'Convert to Opportunity'), ('merge', 'Merge with existing Opportunity')],'Select Action', required=True),
+        'opportunity_ids': fields.many2many('crm.lead',  'merge_opportunity_rel', 'merge_id', 'opportunity_id', 'Opportunities', domain=[('type', '=', 'opportunity')]),
+    }
+    
+    def view_init(self, cr, uid, fields, context=None):
         """
-        Closes Lead To Opportunity form
+        This function checks for precondition before wizard executes
         @param self: The object pointer
         @param cr: the current row, from the database cursor,
         @param uid: the current user’s ID for security checks,
-        @param ids: List of Lead to Partner's IDs
+        @param fields: List of fields for default value
         @param context: A standard dictionary for contextual values
 
         """
-        return {'type': 'ir.actions.act_window_close'}
+        if context is None:
+            context = {}
+        lead_obj = self.pool.get('crm.lead')
 
+        for lead in lead_obj.browse(cr, uid, context.get('active_ids', []), context=context):
+            if lead.state in ['done', 'cancel']:
+                raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
+Leads Could not convert into Opportunity"))
+        return False
+    
     def action_apply(self, cr, uid, ids, context=None):
         """
         This converts lead to opportunity and opens Opportunity view
@@ -46,7 +63,7 @@
 
         @return : View dictionary opening the Opportunity form view
         """
-        record_id = context and context.get('active_id') or False
+        record_id = context and context.get('active_ids') or False
         if not record_id:
             return {'type': 'ir.actions.act_window_close'}
 
@@ -69,30 +86,42 @@
             opportunity_view_tree = models_data.browse(
                 cr, uid, opportunity_view_tree, context=context).res_id
 
-        lead = leads.browse(cr, uid, record_id, context=context)
-        if(lead.section_id):
-            stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('type','=','opportunity'),('sequence','>=',1), ('section_ids','=', lead.section_id.id)])
-        else:
-            stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('type','=','opportunity'),('sequence','>=',1)])
-        for this in self.browse(cr, uid, ids, context=context):
-            vals ={
-                'planned_revenue': this.planned_revenue,
-                'probability': this.probability,
-                'name': this.name,
-                'partner_id': this.partner_id.id,
-                'user_id': (this.partner_id.user_id and this.partner_id.user_id.id) or (lead.user_id and lead.user_id.id),
-                'type': 'opportunity',
-                'stage_id': stage_ids and stage_ids[0] or False
-            }
-            lead.write(vals, context=context)
-            leads.history(cr, uid, [lead], _('Opportunity'), details='Converted to Opportunity', context=context)
-            if lead.partner_id:
-                msg_ids = [ x.id for x in lead.message_ids]
-                self.pool.get('mailgate.message').write(cr, uid, msg_ids, {
-                    'partner_id': lead.partner_id.id
-                }, context=context)
-            leads.log(cr, uid, lead.id,
-                _("Lead '%s' has been converted to an opportunity.") % lead.name)
+        for lead in leads.browse(cr, uid, record_id, context=context):
+            if(lead.section_id):
+                stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('type','=','opportunity'),('sequence','>=',1), ('section_ids','=', lead.section_id.id)])
+            else:
+                stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('type','=','opportunity'),('sequence','>=',1)])
+            
+            data = self.browse(cr, uid, ids[0], context=context)
+            partner_ids = []
+            if data.action == 'create':
+                partner_ids = self._create_partner(cr, uid, ids, context=context)
+                
+            partner_id = partner_ids and partner_ids[0] or data.partner_id.id 
+            if data.name == 'convert':
+                vals = {
+                    'planned_revenue': lead.planned_revenue,
+                    'probability': lead.probability,
+                    'name': lead.name,
+                    'partner_id': partner_id,
+                    'user_id': (lead.user_id and lead.user_id.id),
+                    'type': 'opportunity',
+                    'stage_id': stage_ids and stage_ids[0] or False,
+                    'date_action': time.strftime('%Y-%m-%d %H:%M:%S')
+                }
+                lead.write(vals, context=context)
+                leads.history(cr, uid, [lead], _('Opportunity'), details='Converted to Opportunity', context=context)
+                if lead.partner_id:
+                    msg_ids = [ x.id for x in lead.message_ids]
+                    self.pool.get('mailgate.message').write(cr, uid, msg_ids, {
+                        'partner_id': lead.partner_id.id
+                    }, context=context)
+                leads.log(cr, uid, lead.id,
+                    _("Lead '%s' has been converted to an opportunity.") % lead.name)
+            elif data.name == 'merge':
+                merge_obj = self.pool.get('crm.merge.opportunity')
+                context.update({'opportunity_ids': data.opportunity_ids})
+                return merge_obj.action_merge(cr, uid, ids, context=context)
 
         return {
             'name': _('Opportunity'),
@@ -108,221 +137,7 @@
             'type': 'ir.actions.act_window',
             'search_view_id': opportunity_view_search
         }
-
-    _columns = {
-        'name' : fields.char('Opportunity', size=64, required=True, select=1),
-        'probability': fields.float('Success Rate (%)'),
-        'planned_revenue': fields.float('Expected Revenue'),
-        'partner_id': fields.many2one('res.partner', 'Partner'),
-    }
-
-    def view_init(self, cr, uid, fields, context=None):
-        """
-        This function checks for precondition before wizard executes
-        @param self: The object pointer
-        @param cr: the current row, from the database cursor,
-        @param uid: the current user’s ID for security checks,
-        @param fields: List of fields for default value
-        @param context: A standard dictionary for contextual values
-
-        """
-        if context is None:
-            context = {}
-        lead_obj = self.pool.get('crm.lead')
-
-        for lead in lead_obj.browse(cr, uid, context.get('active_ids', []), context=context):
-            if lead.state in ['done', 'cancel']:
-                raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
-Leads Could not convert into Opportunity"))
-        return False
-
-    def default_get(self, cr, uid, fields, context=None):
-        """
-        This function gets default values
-        @param self: The object pointer
-        @param cr: the current row, from the database cursor,
-        @param uid: the current user’s ID for security checks,
-        @param fields: List of fields for default value
-        @param context: A standard dictionary for contextual values
-
-        @return : default values of fields.
-        """
-        lead_obj = self.pool.get('crm.lead')
-        data = context and context.get('active_ids', []) or []
-        res = super(crm_lead2opportunity, self).default_get(cr, uid, fields, context=context)
-        for lead in lead_obj.browse(cr, uid, data, context=context):
-            if 'name' in fields:
-                res.update({'name': lead.name})
-            if 'partner_id' in fields:
-                res.update({'partner_id': lead.partner_id.id or False})
-        return res
-
-crm_lead2opportunity()
-
-
-class crm_lead2opportunity_partner(osv.osv_memory):
-    _name = 'crm.lead2opportunity.partner'
-    _description = 'Lead To Opportunity Partner'
-    _inherit = 'crm.lead2partner'
-
-    _columns = {
-        'partner_id': fields.many2one('res.partner', 'Partner'),
-        'action': fields.selection([('exist', 'Link to an existing partner'), ('create', 'Create a new partner'), ('no','Do not create a partner')], 'Action'),
-    }
-
-    def make_partner(self, cr, uid, ids, context=None):
-        """
-        This function Makes partner based on action.
-        @param self: The object pointer
-        @param cr: the current row, from the database cursor,
-        @param uid: the current user’s ID for security checks,
-        @param ids: List of Lead to Partner's IDs
-        @param context: A standard dictionary for contextual values
-
-        @return : Dictionary value for created Partner form.
-        """
-        if context is None:
-            context = {}
-
-        partner_ids = self._create_partner(cr, uid, ids, context=context)
-        value = {}
-        data_obj = self.pool.get('ir.model.data')
-        data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_action')
-        view_id = False
-        if data_id:
-            view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
-
-        context.update({'partner_id': partner_ids})
-        value = {
-            'name': _('Create Opportunity'),
-            'view_type': 'form',
-            'view_mode': 'form,tree',
-            'res_model': 'crm.lead2opportunity.action',
-            'view_id': False,
-            'context': context,
-            'views': [(view_id, 'form')],
-            'type': 'ir.actions.act_window',
-            'target': 'new',
-        }
-        return value
-
-    def action_skip(self, cr, uid, ids, context=None):
-        """
-        This skips partner creation
-        @param self: The object pointer
-        @param cr: the current row, from the database cursor,
-        @param uid: the current user’s ID for security checks,
-        @param ids: List of Lead to Opportunity IDs
-        @param context: A standard dictionary for contextual values
-
-        @return : Dictionary value for Opportunity form
-        """
-        value = {}
-        if context is None:
-            context = {}
-        data_obj = self.pool.get('ir.model.data')
-        data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create')
-        view_id = False
-        if data_id:
-            view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
-
-        context.update({'partner_id': False})
-        value = {
-            'name': _('Create Opportunity'),
-            'view_type': 'form',
-            'view_mode': 'form,tree',
-            'res_model': 'crm.lead2opportunity',
-            'view_id': False,
-            'context': context,
-            'views': [(view_id, 'form')],
-            'type': 'ir.actions.act_window',
-            'target': 'new',
-        }
-        return value
-
-
-    def view_init(self, cr, uid, fields, context=None):
-        """
-        This function checks for precondition before wizard executes
-        @param self: The object pointer
-        @param cr: the current row, from the database cursor,
-        @param uid: the current user’s ID for security checks,
-        @param fields: List of fields for default value
-        @param context: A standard dictionary for contextual values
-
-        """
-        if context is None:
-            context = {}
-        lead_obj = self.pool.get('crm.lead')
-
-        for lead in lead_obj.browse(cr, uid, context.get('active_ids', []), context=context):
-            if lead.state in ['done', 'cancel']:
-                raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
-Leads Could not convert into Opportunity"))
-        return False
-
+        
 crm_lead2opportunity_partner()
 
-class crm_lead2opportunity_action(osv.osv_memory):
-    '''
-    Merge with Existing Opportunity or Convert to Opportunity
-    '''
-    _name = 'crm.lead2opportunity.action'
-    _description = 'Convert/Merge Opportunity'
-    _columns = {
-        'name': fields.selection([('convert', 'Convert to Opportunity'), ('merge', 'Merge with existing Opportunity')],'Select Action', required=True),
-    }
-    _defaults = {
-        'name': 'convert',
-    }
-    def do_action(self, cr, uid, ids, context=None):
-        """
-        This function opens form according to selected Action
-        @param self: The object pointer
-        @param cr: the current row, from the database cursor,
-        @param uid: the current user’s ID for security checks,
-        @param ids: List of Lead to Opportunity IDs
-        @param context: A standard dictionary for contextual values
-        @return : Dictionary value for Opportunity form
-        """
-        value = {}
-        if context is None:
-            context = {}
-        data_obj = self.pool.get('ir.model.data')
-        view_id = False
-        for this in self.browse(cr, uid, ids, context=context):
-            if this.name == 'convert':
-                data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create')
-                if data_id:
-                    view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
-                value = {
-                        'name': _('Create Opportunity'),
-                        'view_type': 'form',
-                        'view_mode': 'form,tree',
-                        'res_model': 'crm.lead2opportunity',
-                        'view_id': False,
-                        'context': context,
-                        'views': [(view_id, 'form')],
-                        'type': 'ir.actions.act_window',
-                        'target': 'new',
-                    }
-            elif this.name == 'merge':
-                data_id = data_obj._get_id(cr, uid, 'crm', 'merge_opportunity_form')
-                if data_id:
-                    view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
-                value = {
-                        'name': _('Merge with Existing Opportunity'),
-                        'view_type': 'form',
-                        'view_mode': 'form,tree',
-                        'res_model': 'crm.merge.opportunity',
-                        'view_id': False,
-                        'context': context,
-                        'views': [(view_id, 'form')],
-                        'type': 'ir.actions.act_window',
-                        'target': 'new',
-                    }
-        return value
-
-crm_lead2opportunity_action()
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'crm/wizard/crm_lead_to_opportunity_view.xml'
--- crm/wizard/crm_lead_to_opportunity_view.xml	2011-01-14 00:11:01 +0000
+++ crm/wizard/crm_lead_to_opportunity_view.xml	2011-02-04 13:12:25 +0000
@@ -1,85 +1,39 @@
 <openerp>
       <data>
 
-        <!-- Lead to Opportunity view -->
-
-      <record id="view_crm_lead2opportunity_create" model="ir.ui.view">
-          <field name="name">crm.lead2opportunity.create</field>
-          <field name="model">crm.lead2opportunity</field>
-          <field name="type">form</field>
-          <field name="arch" type="xml">
-              <form string="Convert To Opportunity">
-                <field name="name"/>
-                <group attrs="{'invisible':[('partner_id','=',False)]}" col="2" colspan="2">
-                    <field name="partner_id"/>
-                </group>
-                <newline/>
-                <field name="planned_revenue"/>
-                <field name="probability"/>
-                <separator colspan="4"/>
-                <group col="4" colspan="4">
-                    <label string="" colspan="2"/>
-                    <button special="cancel" string="Cancel" icon="gtk-cancel"/>
-                    <button name="action_apply" string="Create Opportunity" type="object" icon="gtk-go-forward"/>
-                </group>
-            </form>
-          </field>
-       </record>
-       
-       <!-- Lead to Opportunity action -->
-       
-       <record id="action_crm_lead2opportunity" model="ir.actions.act_window">
-          <field name="name">Create Opportunity</field>
-          <field name="type">ir.actions.act_window</field>
-          <field name="res_model">crm.lead2opportunity</field>
-          <field name="view_type">form</field>
-          <field name="view_mode">form</field>
-          <field name="target">new</field>
-       </record>
-
-
         <record id="view_crm_lead2opportunity_partner" model="ir.ui.view">
           <field name="name">crm.lead2opportunity.partner.form</field>
           <field name="model">crm.lead2opportunity.partner</field>
           <field name="type">form</field>
           <field name="arch" type="xml">
-               <form string="Create a Partner">
-                <label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
-                <label string="You may have to verify that this partner does not exist already." colspan="4"/>
-                <group colspan="4" col="1" attrs="{'invisible':[('msg','=',False)]}">
-                    <field name="msg" colspan="4" nolabel="1"  height="50"/>
-                </group>
-                <newline />
-                <field name="action"/>
-                <group attrs="{'invisible':[('action','!=','exist')]}">
-                    <field name="partner_id" attrs="{'required': [('action', '=', 'exist')]}"/>
-                </group>
-                <separator string="" colspan="4" />
-                <group col="4" colspan="4">
-                    <button special="cancel" string="Cancel" icon="gtk-cancel"/>
-                    <button name="make_partner" string="Continue" type="object" icon="gtk-ok"/>
-                </group>
-            </form>
-          </field>
-       </record> 
-
-    <record id="view_crm_lead2opportunity_action" model="ir.ui.view">
-          <field name="name">crm.lead2opportunity.action.form</field>
-          <field name="model">crm.lead2opportunity.action</field>
-          <field name="type">form</field>
-          <field name="arch" type="xml">
-               <form string="Select Action">
-               <separator string="Select Action" colspan="4" />
-                <label string="If you select Merge with existing Opportunity, the lead details(with the communication history) will be merged with existing Opportunity of Selected partner." colspan="4"/>
-                <newline/>
-                <field name="name" colspan="4"/>
-                <separator colspan="4" />
-                <group col="4" colspan="4">
-                    <label colspan="2"/>
-                    <button special="cancel" string="Cancel" icon="gtk-cancel"/>
-                    <button name="do_action" string="Next" type="object" icon="gtk-go-forward"/>
-                </group>
-            </form>
+               <form string="Convert to Opportunity">
+                    <group width="540" height="450">
+		                <label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
+		                <label string="You may have to verify that this partner does not exist already." colspan="4"/>
+		                <group colspan="4" col="1" attrs="{'invisible':[('msg','=',False)]}">
+		                    <field name="msg" colspan="4" nolabel="1" height="50"/>
+		                </group>
+		                <newline />
+		                <field name="action"/>
+		                <group attrs="{'invisible':[('action','!=','exist')]}">
+		                    <field name="partner_id" attrs="{'required': [('action', '=', 'exist')]}"/>
+		                </group>
+		                <separator string="Convert to Opportunity" colspan="4"/>
+		                <field name="name" colspan="4"/>
+		                <group col="4" colspan="4" attrs="{'invisible': [('name', '=', 'convert')]}">
+		                    <separator string="Select Opportunities" colspan="4"/>
+		                    <field name="opportunity_ids" colspan="4" nolabel="1" height="130"/>
+                        </group>
+                        <group attrs="{'invisible':[('name','=','merge')]}">
+                            <separator orientation="vertical" rowspan="7"/>
+                        </group>
+		                <separator string="" colspan="4" />
+		                <group col="4" colspan="4">
+		                    <button special="cancel" string="Cancel" icon="gtk-cancel"/>
+		                    <button name="action_apply" string="Create Opportunity" type="object" icon="gtk-ok"/>
+		                </group>
+		          </group>
+              </form>
           </field>
        </record> 
 

=== modified file 'crm/wizard/crm_lead_to_partner.py'
--- crm/wizard/crm_lead_to_partner.py	2011-01-14 00:11:01 +0000
+++ crm/wizard/crm_lead_to_partner.py	2011-02-04 13:12:25 +0000
@@ -116,11 +116,15 @@
                     label = opp_ids and 'name' or False
                 if label:
                     res.update({'msg': "An existing opportunity seems to match the %s of this lead, you should double-check before converting it." % (label)})
-
+            
             if 'partner_id' in fields:
                 res.update({'partner_id': partner_id})
             if 'action' in fields:
                 res.update({'action': partner_id and 'exist' or 'create'})
+            if 'name' in fields:
+                res.update({'name': 'convert'})
+            if 'opportunity_ids' in fields:
+                res.update({'opportunity_ids': data})
 
         return res
     
@@ -205,14 +209,6 @@
                         contact_id = partner_obj.address_get(cr, uid, [partner_id])['default']
 
                 partner_ids.append(partner_id)
-
-                if data.action<>'no':
-                    vals = {}
-                    if partner_id:
-                        vals.update({'partner_id': partner_id})
-                    if contact_id:
-                        vals.update({'partner_address_id': contact_id})
-                    lead_obj.write(cr, uid, [lead.id], vals)
         return partner_ids
 
     def make_partner(self, cr, uid, ids, context=None):


Follow ups