From fac1d52e2e69d39a69c2d6c702311ab47e9bb117 Mon Sep 17 00:00:00 2001 From: tfr Date: Sun, 6 Feb 2011 22:28:34 +0100 Subject: [PATCH] [IMP] Convert to opportunity merge with opportunity with the link partner bzr revid: tfr@openerp.com-20110206212834-pkhlzurbdxznntsd --- addons/crm/wizard/crm_lead_to_opportunity.py | 28 ++++++++++++++++++++ addons/crm/wizard/crm_lead_to_partner.py | 1 + 2 files changed, 29 insertions(+) diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index 2bcea68befb..1d8bfbe3de2 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -36,6 +36,34 @@ class crm_lead2opportunity_partner(osv.osv_memory): 'opportunity_ids': fields.many2many('crm.lead', 'merge_opportunity_rel', 'merge_id', 'opportunity_id', 'Opportunities', domain=[('type', '=', 'opportunity')]), } + def default_get(self, cr, uid, fields, context=None): + """ + Default get for name, opportunity_ids + if there is an exisitng partner link to the lead, find all existing opportunity link with this partnet to merge + all information together + """ + lead_obj = self.pool.get('crm.lead') + partner_id = False + + + res = super(crm_lead2opportunity_partner, self).default_get(cr, uid, fields, context=context) + opportunities = res.get('opportunity_ids') or [] + name = 'convert' + if res.get('partner_id'): + name = 'merge' + partner_id = res.get('partner_id') + ids = lead_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', '=', 'opportunity')]) + opportunities += ids + + + if 'name' in fields: + res.update({'name' : name}) + if 'opportunity_ids' in fields: + res.update({'opportunity_ids': opportunities}) + + + return res + def view_init(self, cr, uid, fields, context=None): """ This function checks for precondition before wizard executes diff --git a/addons/crm/wizard/crm_lead_to_partner.py b/addons/crm/wizard/crm_lead_to_partner.py index 32afd7b13fd..d7ff765a5b7 100644 --- a/addons/crm/wizard/crm_lead_to_partner.py +++ b/addons/crm/wizard/crm_lead_to_partner.py @@ -66,6 +66,7 @@ class crm_lead2partner(osv.osv_memory): @return : default values of fields. """ + print "SUPER DEFAULT GET" lead_obj = self.pool.get('crm.lead') partner_obj = self.pool.get('res.partner') contact_obj = self.pool.get('res.partner.address')