Lead to opportunity wizard: partner not created when existing partner found, even when choosing 'create' in the wizard

Bug #1208436 reported by Karel Marissens
28
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP Publisher's Warranty Team

Bug Description

Steps to reproduce:
1) Launch the lead to opportunity wizard for a lead with contact info that corresponds to an existing partner (but this partner is not selected in the lead).
2) When the wizard opens, it automatically suggests to 'link with existing partner'.
3) Choose 'create new partner' instead and click 'create opportunity'.

Result:
The opportunity is linked to the existing partner. No new partner is created, even though that's what I selected in the wizard.

Cause:
In crm_lead2opportunity_partner._create_partner, the following 2 lines are defined:
        partner_id = data.partner_id and data.partner_id.id or False
        return lead.handle_partner_assignation(cr, uid, lead_ids, data.action, partner_id, context=context)

Since an existing partner was found, 'data.partner_id' exists, thus this will be given as input for the 'handle_partner_assignation' method. This last method defines the following lines:
        force_partner_id = partner_id
        for lead in self.browse(cr, uid, ids, context=context):
            # If the action is set to 'create' and no partner_id is set, create a new one
            if action == 'create':
                partner_id = force_partner_id or self._create_lead_partner(cr, uid, lead, context)

Thus, when a partner_id is given, the lead/opportunity is linked to it, even when the action is 'create'!

So as far as I can see, there's 2 errors in the code:
1) If the 'handle_partner_assignation' method has 'create' as action, it should always do a create, whether the partner_id is given or not.
2) The '_create_partner' method should check the action, and call 'handle_partner_assignation' with our without partner_id accordingly.

Tags: maintenance

Related branches

Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) wrote :

Hi,

Thanks for the clear description, it helped reproduce the issue quickly.

However, the root cause of the issue lies in the wizard itself, i.e. once the wizard set the automatically suggested partner in partner field and when one selected the other options than "Link to an existing customer", it just hid the partner field but never cleared the value of it, and thus, the partner value always going to be there in data(_create_partner(...)) and hence resulting into this bug.

So, it is better to fix the issue by clearing the partner when the wizard tells not to link the opportunity to an existing partner. This can be done by introducing an onchange(...) on the "action" field.

I will soon create a branch with the fix and link it to this bug.

Thanks.

Changed in openobject-addons:
status: New → In Progress
importance: Undecided → Low
Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) wrote :

Hi,

This issue has been fixed in the Branch: lp:~openerp-dev/openobject-addons/7.0-opw-596231-rgo with Revision Id: <email address hidden> and Rev #: 9350.

It will soon be reviewed by our experts and after their approval, the fix will be integrated with main stable V7.

Thanks.

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Fixed in 7.0 at revision 9664 (Revision ID: <email address hidden>).

Changed in openobject-addons:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.