From b17de5f75f6899dd157ce03286e713ab2213afa8 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Tue, 4 Dec 2012 14:30:00 +0100 Subject: [PATCH] [IMP] regroup leads' fields to merge in a global var and therefore avoid their duplication bzr revid: abo@openerp.com-20121204133000-541vbw9vmts77myq --- addons/crm/crm_lead.py | 43 ++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 05acba1baae..246a98a1575 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -30,6 +30,37 @@ from tools import html2plaintext from base.res.res_partner import format_address +CRM_LEAD_FIELDS_TO_MERGE = ['name', + 'partner_id', + 'channel_id', + 'company_id', + 'country_id', + 'section_id', + 'stage_id', + 'state_id', + 'type_id', + 'user_id', + 'categ_ids', + 'title', + 'city', + 'contact_name', + 'description', + 'email', + 'fax', + 'mobile', + 'partner_name', + 'phone', + 'probability', + 'planned_revenue', + 'street', + 'street2', + 'zip', + 'create_date', + 'date_action_last', + 'date_action_next', + 'email_from', + 'email_cc', + 'partner_name'] CRM_LEAD_PENDING_STATES = ( crm.AVAILABLE_STATES[2][0], # Cancelled crm.AVAILABLE_STATES[3][0], # Done @@ -527,15 +558,10 @@ class crm_lead(base_stage, format_address, osv.osv): details = [] merge_message = _('Merged opportunities') subject = [merge_message] - fields = ['name', 'partner_id', 'stage_id', 'section_id', 'user_id', - 'categ_ids', 'channel_id', 'company_id', 'contact_name', - 'email_from', 'phone', 'fax', 'mobile', 'state_id', 'description', - 'probability', 'planned_revenue', 'country_id', 'city', 'street', - 'street2', 'zip'] for opportunity in opportunities: subject.append(opportunity.name) title = "%s : %s" % (merge_message, opportunity.name) - details.append(self._mail_body(cr, uid, opportunity, fields, title=title, context=context)) + details.append(self._mail_body(cr, uid, opportunity, CRM_LEAD_FIELDS_TO_MERGE, title=title, context=context)) # Chatter message's subject subject = subject[0] + ": " + ", ".join(subject[1:]) @@ -604,10 +630,7 @@ class crm_lead(base_stage, format_address, osv.osv): first_opportunity = opportunities_list[0] tail_opportunities = opportunities_list[1:] - fields_to_merge = ['partner_id', 'title', 'name', 'categ_ids', 'channel_id', 'city', 'company_id', 'contact_name', 'country_id', 'type_id', 'user_id', 'section_id', 'state_id', 'description', 'email', 'fax', 'mobile', - 'partner_name', 'phone', 'probability', 'planned_revenue', 'street', 'street2', 'zip', 'create_date', 'date_action_last', - 'date_action_next', 'email_from', 'email_cc', 'partner_name'] - merged_data = self._merge_data(cr, uid, ids, oldest, fields_to_merge, context=context) + merged_data = self._merge_data(cr, uid, ids, oldest, CRM_LEAD_FIELDS_TO_MERGE, context=context) # Merge messages and attachements into the first opportunity self._merge_opportunity_history(cr, uid, first_opportunity.id, tail_opportunities, context=context)