From fa8f714a590206f7923ef62a88bc39fe1b70491f Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 8 Nov 2012 15:01:00 +0100 Subject: [PATCH 01/60] [WIP] imp crm tests bzr revid: abo@openerp.com-20121108140100-wmpa3ko8cpo840zq --- addons/crm/test/process/lead2opportunity2win.yml | 6 +++--- addons/crm/test/ui/crm_demo.yml | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/crm/test/process/lead2opportunity2win.yml b/addons/crm/test/process/lead2opportunity2win.yml index dc5aadbcf16..d6f1c53de63 100644 --- a/addons/crm/test/process/lead2opportunity2win.yml +++ b/addons/crm/test/process/lead2opportunity2win.yml @@ -1,12 +1,12 @@ - - In order to test convert customer lead into opportunity, + In order to test the conversion of a lead into a opportunity, - - I open customer lead. + I open a lead. - !python {model: crm.lead}: | self.case_open(cr, uid, [ref("crm_case_4")]) - - I check lead state is "Open". + I check if the lead state is "Open". - !assert {model: crm.lead, id: crm.crm_case_4, string: Lead in open state}: - state == "open" diff --git a/addons/crm/test/ui/crm_demo.yml b/addons/crm/test/ui/crm_demo.yml index 842b3a4e887..9154ffdf513 100644 --- a/addons/crm/test/ui/crm_demo.yml +++ b/addons/crm/test/ui/crm_demo.yml @@ -1,5 +1,5 @@ - - I create lead record to call of partner onchange, stage onchange and Mailing opt-in onchange method. + I create a lead record to call a partner onchange, stage onchange and mailing opt-in onchange method. - !record {model: crm.lead, id: crm_case_25}: name: 'Need more info about your pc2' @@ -8,7 +8,7 @@ stage_id: crm.stage_lead1 state: draft - - I create lead record to call Mailing opt-out onchange method. + I create a lead record to call a mailing opt-out onchange method. - !record {model: crm.lead, id: crm_case_18}: name: 'Need 20 Days of Consultancy' @@ -16,13 +16,13 @@ state: draft opt_out: True - - I create phonecall record to call partner onchange method. + I create a phonecall record to call a partner onchange method. - !record {model: crm.phonecall, id: crm_phonecall_5}: name: 'Bad time' partner_id: base.res_partner_5 - - I setting next stage "New" for the lead. + I set the next stage to "New" for the lead. - !python {model: crm.lead}: | self.stage_next(cr, uid, [ref("crm_case_4")], context={'stage_type': 'lead'}) From 9c3aefeb022f2b795a67779b46ed62dedbbf96f9 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 8 Nov 2012 18:58:41 +0100 Subject: [PATCH 02/60] [IMP] indentation bzr revid: abo@openerp.com-20121108175841-mf5c1jhywj07cvvk --- addons/crm/test/process/lead2opportunity2win.yml | 2 +- addons/crm/wizard/crm_lead_to_partner_view.xml | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/crm/test/process/lead2opportunity2win.yml b/addons/crm/test/process/lead2opportunity2win.yml index d6f1c53de63..0523c2d6296 100644 --- a/addons/crm/test/process/lead2opportunity2win.yml +++ b/addons/crm/test/process/lead2opportunity2win.yml @@ -8,7 +8,7 @@ - I check if the lead state is "Open". - - !assert {model: crm.lead, id: crm.crm_case_4, string: Lead in open state}: + !assert {model: crm.lead, id: crm.crm_case_4, string: Lead state is Open}: - state == "open" - I fill in a lead2partner wizard. diff --git a/addons/crm/wizard/crm_lead_to_partner_view.xml b/addons/crm/wizard/crm_lead_to_partner_view.xml index 21a14dd3726..136985dca65 100644 --- a/addons/crm/wizard/crm_lead_to_partner_view.xml +++ b/addons/crm/wizard/crm_lead_to_partner_view.xml @@ -1,9 +1,8 @@ - + - - - + + crm.lead2partner.view crm.lead2partner @@ -20,9 +19,8 @@ - + - Create a Partner @@ -33,5 +31,5 @@ new - + From cccbbdfbb24d95e0514e214b4c477394bbbe741a Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Mon, 12 Nov 2012 11:15:14 +0100 Subject: [PATCH 03/60] [IMP] indentation bzr revid: abo@openerp.com-20121112101514-5da79d21g009t8o1 --- addons/crm/wizard/crm_lead_to_opportunity.py | 16 +++++++++------- addons/crm/wizard/crm_lead_to_partner.py | 8 +++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index ea96e1d16f1..0888dc74356 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -30,13 +30,15 @@ class crm_lead2opportunity_partner(osv.osv_memory): _inherit = 'crm.lead2partner' _columns = { - 'action': fields.selection([('exist', 'Link to an existing customer'), \ - ('create', 'Create a new customer'), \ - ('nothing', 'Do not link to a customer')], \ - 'Related Customer', required=True), - 'name': fields.selection([('convert', 'Convert to opportunity'), \ - ('merge', 'Merge with existing opportunities')], \ - 'Conversion Action', required=True), + 'action': fields.selection([ + ('exist', 'Link to an existing customer'), + ('create', 'Create a new customer'), + ('nothing', 'Do not link to a customer') + ], 'Related Customer', required=True), + 'name': fields.selection([ + ('convert', 'Convert to opportunity'), + ('merge', 'Merge with existing opportunities') + ], 'Conversion Action', required=True), 'opportunity_ids': fields.many2many('crm.lead', string='Opportunities', domain=[('type', '=', 'opportunity')]), } diff --git a/addons/crm/wizard/crm_lead_to_partner.py b/addons/crm/wizard/crm_lead_to_partner.py index c48990f5866..fdd8d9e12d1 100644 --- a/addons/crm/wizard/crm_lead_to_partner.py +++ b/addons/crm/wizard/crm_lead_to_partner.py @@ -28,11 +28,13 @@ class crm_lead2partner(osv.osv_memory): _description = 'Lead to Partner' _columns = { - 'action': fields.selection([('exist', 'Link to an existing customer'), \ - ('create', 'Create a new customer')], \ - 'Action', required=True), + 'action': fields.selection([ + ('exist', 'Link to an existing customer'), + ('create', 'Create a new customer') + ], 'Related Customer', required=True), 'partner_id': fields.many2one('res.partner', 'Customer'), } + def view_init(self, cr, uid, fields, context=None): """ Check for precondition before wizard executes. From 730c3f940c1f860fbc14798488702706b3b38267 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Mon, 12 Nov 2012 12:41:08 +0100 Subject: [PATCH 04/60] [IMP] indentation bzr revid: abo@openerp.com-20121112114108-p7qt0owe8lnljn27 --- .../wizard/crm_phonecall_to_partner_view.xml | 81 +++++++++---------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/addons/crm/wizard/crm_phonecall_to_partner_view.xml b/addons/crm/wizard/crm_phonecall_to_partner_view.xml index 7231876b0c1..bda4265b224 100644 --- a/addons/crm/wizard/crm_phonecall_to_partner_view.xml +++ b/addons/crm/wizard/crm_phonecall_to_partner_view.xml @@ -1,47 +1,45 @@ + - + - - - - crm.phonecall2partner.view.create - crm.phonecall2partner - -
-
-
- - - - - crm.phonecall2partner.view - crm.phonecall2partner - -
- - - - -
-
-
-
-
+ + + crm.phonecall2partner.view.create + crm.phonecall2partner + +
+
+
- + + + crm.phonecall2partner.view + crm.phonecall2partner + +
+ + + + +
+
+
+
+
+ Create a Partner ir.actions.act_window @@ -50,5 +48,6 @@ new -
+ +
From ef241cf6bb01109b87384b84cc8ca68e566807b0 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Mon, 12 Nov 2012 12:46:39 +0100 Subject: [PATCH 05/60] [IMP] remove dead code from the deprecated lead2partner wizard view bzr revid: abo@openerp.com-20121112114639-411nkyl7ne188ug8 --- addons/crm/__openerp__.py | 1 - .../crm/wizard/crm_lead_to_partner_view.xml | 35 ------------------- 2 files changed, 36 deletions(-) delete mode 100644 addons/crm/wizard/crm_lead_to_partner_view.xml diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index 03885f541d0..402936f3587 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -67,7 +67,6 @@ Dashboard for CRM will include: 'security/crm_security.xml', 'security/ir.model.access.csv', - 'wizard/crm_lead_to_partner_view.xml', 'wizard/crm_lead_to_opportunity_view.xml', 'wizard/crm_phonecall_to_phonecall_view.xml', diff --git a/addons/crm/wizard/crm_lead_to_partner_view.xml b/addons/crm/wizard/crm_lead_to_partner_view.xml deleted file mode 100644 index 136985dca65..00000000000 --- a/addons/crm/wizard/crm_lead_to_partner_view.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - crm.lead2partner.view - crm.lead2partner - -
- - - - - -
-
-
-
-
- - - - Create a Partner - ir.actions.act_window - crm.lead2partner - form - - new - - -
-
From 5b5951143c5052b2242ce2ae5f88f4de0e1f99ad Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Mon, 12 Nov 2012 13:15:05 +0100 Subject: [PATCH 06/60] [IMP] remove dead code from the deprecated phonecall2partner wizard view bzr revid: abo@openerp.com-20121112121505-0oaozvs14xr8i1gv --- addons/crm/__openerp__.py | 1 - .../process/communication_with_customer.yml | 16 ----- addons/crm/wizard/__init__.py | 3 - addons/crm/wizard/crm_phonecall_to_partner.py | 67 ------------------- .../wizard/crm_phonecall_to_partner_view.xml | 53 --------------- 5 files changed, 140 deletions(-) delete mode 100644 addons/crm/wizard/crm_phonecall_to_partner.py delete mode 100644 addons/crm/wizard/crm_phonecall_to_partner_view.xml diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index 402936f3587..08266d8a3c4 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -70,7 +70,6 @@ Dashboard for CRM will include: 'wizard/crm_lead_to_opportunity_view.xml', 'wizard/crm_phonecall_to_phonecall_view.xml', - 'wizard/crm_phonecall_to_partner_view.xml', 'wizard/crm_phonecall_to_opportunity_view.xml', 'wizard/crm_opportunity_to_phonecall_view.xml', diff --git a/addons/crm/test/process/communication_with_customer.yml b/addons/crm/test/process/communication_with_customer.yml index 2137616ae3e..387d4589714 100644 --- a/addons/crm/test/process/communication_with_customer.yml +++ b/addons/crm/test/process/communication_with_customer.yml @@ -34,19 +34,3 @@ !python {model: crm.lead}: | lead_ids = self.search(cr, uid, [('email_from','=', 'Mr. John Right ')]) self.convert_partner(cr, uid, lead_ids, context=context) -- - I convert one phonecall request to a customer and put him into regular customer list. -- - !python {model: crm.phonecall2partner}: | - context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_phonecall_4")], 'active_id': ref("crm.crm_phonecall_4")}) - new_id = self.create(cr, uid, {}, context=context) - self.make_partner(cr, uid, [new_id], context=context) -- - I check converted phonecall to partner. -- - !python {model: res.partner}: | - partner_id = self.search(cr, uid, [('phonecall_ids', '=', ref('crm.crm_phonecall_4'))]) - assert partner_id, "Customer is not found in regular customer list." - data = self.browse(cr, uid, partner_id, context=context)[0] - assert data.user_id.id == ref("base.user_root"), "User not assigned properly" - assert data.name == "Wanted information about pricing of laptops", "Bad partner name" diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py index 15ca8df670d..d3849af2308 100644 --- a/addons/crm/wizard/__init__.py +++ b/addons/crm/wizard/__init__.py @@ -23,12 +23,9 @@ import crm_lead_to_partner import crm_lead_to_opportunity import crm_phonecall_to_phonecall import crm_opportunity_to_phonecall -import crm_phonecall_to_partner import crm_partner_to_opportunity import crm_phonecall_to_opportunity - import crm_merge_opportunities - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/wizard/crm_phonecall_to_partner.py b/addons/crm/wizard/crm_phonecall_to_partner.py deleted file mode 100644 index 715b7396c66..00000000000 --- a/addons/crm/wizard/crm_phonecall_to_partner.py +++ /dev/null @@ -1,67 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from osv import osv, fields -from tools.translate import _ - -class crm_phonecall2partner(osv.osv_memory): - """ Converts phonecall to partner """ - - _name = 'crm.phonecall2partner' - _inherit = 'crm.lead2partner' - _description = 'Phonecall to Partner' - - def _select_partner(self, cr, uid, context=None): - """ - This function Searches for Partner from selected phonecall. - """ - if context is None: - context = {} - - phonecall_obj = self.pool.get('crm.phonecall') - partner_obj = self.pool.get('res.partner') - rec_ids = context and context.get('active_ids', []) - value = {} - partner_id = False - for phonecall in phonecall_obj.browse(cr, uid, rec_ids, context=context): - partner_ids = partner_obj.search(cr, uid, [('name', '=', phonecall.name or phonecall.name)]) - if not partner_ids and (phonecall.partner_phone or phonecall.partner_mobile): - partner_ids = partner_obj.search(cr, uid, ['|', ('phone', '=', phonecall.partner_phone), ('mobile','=',phonecall.partner_mobile)]) - - partner_id = partner_ids and partner_ids[0] or False - return partner_id - - - def _create_partner(self, cr, uid, ids, context=None): - """ - This function Creates partner based on action. - """ - if context is None: - context = {} - phonecall = self.pool.get('crm.phonecall') - data = self.browse(cr, uid, ids, context=context)[0] - call_ids = context and context.get('active_ids') or [] - partner_id = data.partner_id and data.partner_id.id or False - return phonecall.convert_partner(cr, uid, call_ids, data.action, partner_id, context=context) - -crm_phonecall2partner() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/wizard/crm_phonecall_to_partner_view.xml b/addons/crm/wizard/crm_phonecall_to_partner_view.xml deleted file mode 100644 index bda4265b224..00000000000 --- a/addons/crm/wizard/crm_phonecall_to_partner_view.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - crm.phonecall2partner.view.create - crm.phonecall2partner - -
-
-
- - - - crm.phonecall2partner.view - crm.phonecall2partner - -
- - - - -
-
-
-
-
- - - - Create a Partner - ir.actions.act_window - crm.phonecall2partner - form - - new - - -
-
From ffbb5bacbd8cf21c32ea2337611a146a3e25e515 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Mon, 12 Nov 2012 13:17:43 +0100 Subject: [PATCH 07/60] [WIP] remove dead code from previous 2partner wizards, and start refactirubg some parts of the code bzr revid: abo@openerp.com-20121112121743-ilsr59d6juacodj2 --- addons/crm/wizard/crm_lead_to_opportunity.py | 5 -- addons/crm/wizard/crm_lead_to_partner.py | 89 ++++++++------------ 2 files changed, 34 insertions(+), 60 deletions(-) diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index 0888dc74356..8fccd8ba219 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -30,11 +30,6 @@ class crm_lead2opportunity_partner(osv.osv_memory): _inherit = 'crm.lead2partner' _columns = { - 'action': fields.selection([ - ('exist', 'Link to an existing customer'), - ('create', 'Create a new customer'), - ('nothing', 'Do not link to a customer') - ], 'Related Customer', required=True), 'name': fields.selection([ ('convert', 'Convert to opportunity'), ('merge', 'Merge with existing opportunities') diff --git a/addons/crm/wizard/crm_lead_to_partner.py b/addons/crm/wizard/crm_lead_to_partner.py index fdd8d9e12d1..0e4c5b77a8d 100644 --- a/addons/crm/wizard/crm_lead_to_partner.py +++ b/addons/crm/wizard/crm_lead_to_partner.py @@ -23,81 +23,60 @@ from osv import osv, fields from tools.translate import _ class crm_lead2partner(osv.osv_memory): - """ Converts lead to partner """ _name = 'crm.lead2partner' - _description = 'Lead to Partner' - + _description = 'Generate a partner from a CRM item (lead, phonecall, ...) either by explicitly converting the element to a partner, either by triggering an action that will create a partner (e.g. convert a lead into an opportunity).' _columns = { 'action': fields.selection([ ('exist', 'Link to an existing customer'), - ('create', 'Create a new customer') + ('create', 'Create a new customer'), + ('nothing', 'Do not link to a customer') ], 'Related Customer', required=True), 'partner_id': fields.many2one('res.partner', 'Customer'), } - def view_init(self, cr, uid, fields, context=None): + def _find_matching_partner(self, cr, uid, context=None): """ - Check for precondition before wizard executes. + Try to find a matching partner regarding the active model data, like the customer's name, email, phone number, etc. + @return partner_id if any, False otherwise """ if context is None: context = {} - model = context.get('active_model') - model = self.pool.get(model) - rec_ids = context and context.get('active_ids', []) - for this in model.browse(cr, uid, rec_ids, context=context): - if this.partner_id: - raise osv.except_osv(_('Warning!'), - _('A partner is already defined.')) - - def _select_partner(self, cr, uid, context=None): - if context is None: - context = {} - if not context.get('active_model') == 'crm.lead' or not context.get('active_id'): - return False - partner = self.pool.get('res.partner') - lead = self.pool.get('crm.lead') - this = lead.browse(cr, uid, context.get('active_id'), context=context) - if this.partner_id: - return this.partner_id.id partner_id = False - if this.email_from: - partner_ids = partner.search(cr, uid, [('email', '=', this.email_from)], context=context) - if partner_ids: - partner_id = partner_ids[0] - if not this.partner_id and this.partner_name: - partner_ids = partner.search(cr, uid, [('name', '=', this.partner_name)], context=context) - if partner_ids: - partner_id = partner_ids[0] + partner_obj = self.pool.get('res.partner') + + # The active model has to be a lead or a phonecall + if (context.get('active_model') == 'crm.lead') and context.get('active_id'): + lead_obj = self.pool.get('crm.lead') + lead = lead_obj.browse(cr, uid, context.get('active_id'), context=context) + if lead.partner_id: + partner_id = lead.partner_id.id + if lead.email_from: + partner_ids = partner_obj.search(cr, uid, [('email', '=', lead.email_from)], context=context) + if partner_ids: + partner_id = partner_ids[0] + if not lead.partner_id and lead.partner_name: + partner_ids = partner_obj.search(cr, uid, [('name', '=', lead.partner_name)], context=context) + if partner_ids: + partner_id = partner_ids[0] + elif (context.get('active_model') == 'crm.phonecall') and context.get('active_id'): + phonecall_obj = self.pool.get('crm.phonecall') + phonecall = phonecall_obj.browse(cr, uid, context.get('active_id'), context=context) + print ">>>>>>>>>> Phonecall case" + #do stuff + return partner_id def default_get(self, cr, uid, fields, context=None): res = super(crm_lead2partner, self).default_get(cr, uid, fields, context=context) - partner_id = self._select_partner(cr, uid, context=context) + partner_id = self._find_matching_partner(cr, uid, context=context) - 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 'partner_id' in fields: + res.update({'partner_id': partner_id}) return res - def open_create_partner(self, cr, uid, ids, context=None): - """ - Open form of create partner. - """ - view_obj = self.pool.get('ir.ui.view') - view_id = view_obj.search(cr, uid, [('model', '=', self._name), \ - ('name', '=', self._name+'.view')]) - return { - 'view_mode': 'form', - 'view_type': 'form', - 'view_id': view_id or False, - 'res_model': self._name, - 'context': context, - 'type': 'ir.actions.act_window', - 'target': 'new', - } - def _create_partner(self, cr, uid, ids, context=None): """ Create partner based on action. @@ -115,10 +94,10 @@ class crm_lead2partner(osv.osv_memory): Make a partner based on action. Only called from form view, so only meant to convert one lead at a time. """ - lead_id = context and context.get('active_id') or False + if context is None: + context = {} + lead_id = context.get('active_id', False) partner_ids_map = self._create_partner(cr, uid, ids, context=context) return self.pool.get('res.partner').redirect_partner_form(cr, uid, partner_ids_map.get(lead_id, False), context=context) -crm_lead2partner() - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 3b2b5f31b92eb4c8108c82681b69507cd184d55f Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Mon, 12 Nov 2012 14:30:33 +0100 Subject: [PATCH 08/60] [WIP] rename 'lead2partner' into 'generate.partner' for more clarity bzr revid: abo@openerp.com-20121112133033-urh3emybeabfvdxm --- addons/crm/__openerp__.py | 1 - .../crm/test/process/lead2opportunity2win.yml | 6 +++--- addons/crm/wizard/__init__.py | 5 ++--- ...ad_to_partner.py => crm_generate_partner.py} | 17 ++++++++++++----- addons/crm/wizard/crm_lead_to_opportunity.py | 2 +- .../crm/wizard/crm_lead_to_opportunity_view.xml | 4 ++-- 6 files changed, 20 insertions(+), 15 deletions(-) rename addons/crm/wizard/{crm_lead_to_partner.py => crm_generate_partner.py} (88%) diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index 08266d8a3c4..9e9cf42a5bc 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -97,7 +97,6 @@ Dashboard for CRM will include: 'board_crm_view.xml', 'res_config_view.xml', - ], 'demo': [ 'crm_demo.xml', diff --git a/addons/crm/test/process/lead2opportunity2win.yml b/addons/crm/test/process/lead2opportunity2win.yml index 0523c2d6296..981a11a59ed 100644 --- a/addons/crm/test/process/lead2opportunity2win.yml +++ b/addons/crm/test/process/lead2opportunity2win.yml @@ -13,13 +13,13 @@ - I fill in a lead2partner wizard. - - !record {model: crm.lead2partner, id: crm_lead2partner_id1, context: '{"active_model": "crm.lead", "active_ids": [ref("crm_case_4")]}'}: + !record {model: crm.generate.partner, id: crm_generate_partner_id1, context: '{"active_model": "crm.lead", "active_ids": [ref("crm_case_4")]}'}: - I create a partner from the lead2partner wizard. - - !python {model: crm.lead2partner}: | + !python {model: crm.generate.partner}: | context.update({'active_model': 'crm.lead', 'active_ids': [ref('crm_case_4')], 'active_id': ref('crm_case_4')}) - self.make_partner(cr, uid ,[ref("crm_lead2partner_id1")], context=context) + self.make_partner(cr, uid ,[ref("crm_generate_partner_id1")], context=context) - I convert lead into opportunity for exiting customer. - diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py index d3849af2308..ea522a036b8 100644 --- a/addons/crm/wizard/__init__.py +++ b/addons/crm/wizard/__init__.py @@ -19,13 +19,12 @@ # ############################################################################## -import crm_lead_to_partner -import crm_lead_to_opportunity +import crm_generate_partner import crm_phonecall_to_phonecall import crm_opportunity_to_phonecall +import crm_lead_to_opportunity import crm_partner_to_opportunity import crm_phonecall_to_opportunity import crm_merge_opportunities # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/crm/wizard/crm_lead_to_partner.py b/addons/crm/wizard/crm_generate_partner.py similarity index 88% rename from addons/crm/wizard/crm_lead_to_partner.py rename to addons/crm/wizard/crm_generate_partner.py index 0e4c5b77a8d..6e7c31d69a7 100644 --- a/addons/crm/wizard/crm_lead_to_partner.py +++ b/addons/crm/wizard/crm_generate_partner.py @@ -22,9 +22,15 @@ from osv import osv, fields from tools.translate import _ -class crm_lead2partner(osv.osv_memory): - _name = 'crm.lead2partner' - _description = 'Generate a partner from a CRM item (lead, phonecall, ...) either by explicitly converting the element to a partner, either by triggering an action that will create a partner (e.g. convert a lead into an opportunity).' +class crm_generate_partner(osv.osv_memory): + """ + Handle the partner generation from any CRM item (lead, phonecall, ...) + either by explicitly converting the element to a partner, either by + triggering an action that will create a partner (e.g. convert a lead into + an opportunity). + """ + _name = 'crm.generate.partner' + _description = 'Generate a partner from a CRM item.' _columns = { 'action': fields.selection([ ('exist', 'Link to an existing customer'), @@ -36,7 +42,8 @@ class crm_lead2partner(osv.osv_memory): def _find_matching_partner(self, cr, uid, context=None): """ - Try to find a matching partner regarding the active model data, like the customer's name, email, phone number, etc. + Try to find a matching partner regarding the active model data, like + the customer's name, email, phone number, etc. @return partner_id if any, False otherwise """ if context is None: @@ -67,7 +74,7 @@ class crm_lead2partner(osv.osv_memory): return partner_id def default_get(self, cr, uid, fields, context=None): - res = super(crm_lead2partner, self).default_get(cr, uid, fields, context=context) + res = super(crm_generate_partner, self).default_get(cr, uid, fields, context=context) partner_id = self._find_matching_partner(cr, uid, context=context) if 'action' in fields: diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index 8fccd8ba219..eea1e90a254 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -27,7 +27,7 @@ import re class crm_lead2opportunity_partner(osv.osv_memory): _name = 'crm.lead2opportunity.partner' _description = 'Lead To Opportunity Partner' - _inherit = 'crm.lead2partner' + _inherit = 'crm.generate.partner' _columns = { 'name': fields.selection([ diff --git a/addons/crm/wizard/crm_lead_to_opportunity_view.xml b/addons/crm/wizard/crm_lead_to_opportunity_view.xml index 3390ad8f547..415e02587e1 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity_view.xml +++ b/addons/crm/wizard/crm_lead_to_opportunity_view.xml @@ -7,7 +7,7 @@ crm.lead2opportunity.partner
- + @@ -18,7 +18,7 @@ - + Date: Mon, 12 Nov 2012 14:48:08 +0100 Subject: [PATCH 09/60] [IMP] hide coma when necessary bzr revid: abo@openerp.com-20121112134808-empw3eoba8ism9o4 --- addons/crm/crm_lead_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 5ff1bc15f69..8598b8c59f8 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -169,7 +169,7 @@ - @@ -253,12 +253,12 @@ - + - + @@ -276,8 +276,8 @@ - - + + @@ -354,14 +354,14 @@ - + - + - - + + @@ -415,7 +415,7 @@ name="action_makeMeeting" type="object" context="{'search_default_attendee_id': active_id, 'default_attendee_id' : active_id}" - /> + />