From 1b96cdd626d92ec4337ec95b5611e056e6ebb925 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 20 Jun 2013 17:21:47 +0200 Subject: [PATCH] [FIX]crm_channel: missing files (bzr add forget) + sequence of stage + remove of useless data from crm bzr revid: dle@openerp.com-20130620152147-uic86m8pbq3x471u --- addons/crm/crm_lead_data.xml | 7 -- addons/crm_channel/crm_data.xml | 4 +- .../wizard/crm_channel_interested.py | 77 +++++++++++++++++++ .../wizard/crm_channel_interested_view.xml | 45 +++++++++++ 4 files changed, 124 insertions(+), 9 deletions(-) create mode 100644 addons/crm_channel/wizard/crm_channel_interested.py create mode 100644 addons/crm_channel/wizard/crm_channel_interested_view.xml diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 91644dcafac..92914542d9d 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -189,13 +189,6 @@ section_id - - Lead to Opportunity - - crm.case.section - - section_id - Opportunity Stage Changed crm.case.section diff --git a/addons/crm_channel/crm_data.xml b/addons/crm_channel/crm_data.xml index 6cdb6e6999d..a3a8d140f96 100644 --- a/addons/crm_channel/crm_data.xml +++ b/addons/crm_channel/crm_data.xml @@ -6,14 +6,14 @@ Assigned - + lead To Recycle - + lead diff --git a/addons/crm_channel/wizard/crm_channel_interested.py b/addons/crm_channel/wizard/crm_channel_interested.py new file mode 100644 index 00000000000..ab0e1d5d735 --- /dev/null +++ b/addons/crm_channel/wizard/crm_channel_interested.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# 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 openerp.osv import fields, osv +from openerp.tools.translate import _ +from openerp import SUPERUSER_ID + + +class crm_lead_forward_to_partner(osv.TransientModel): + """ Forward info history to partners. """ + _name = 'crm.lead.channel.interested' + _columns = { + 'interested': fields.boolean('Interested by this lead'), + 'contacted': fields.boolean('Did you contact the lead?', help="The lead has been contacted"), + 'comment': fields.text('Comment', help="What are the elements that have led to this decision?", required=True), + } + _defaults = { + 'interested': lambda self, cr, uid, c: c.get('interested', True), + 'contacted': False, + } + + def action_confirm(self, cr, uid, ids, context=None): + wizard = self.browse(cr, uid, ids[0], context=context) + if wizard.interested and not wizard.contacted: + raise osv.except_osv(_('Error!'), _("You must contact the lead before saying that you are interested")) + lead_obj = self.pool.get('crm.lead') + lead_obj.check_access_rights(cr, uid, 'write') + if wizard.interested: + message = _('

I am interested by this lead.

') + values = {} + else: + stage = 'stage_portal_lead_recycle' + message = _('

I am not interested by this lead. I %scontacted the lead.

') % (not wizard.contacted and 'have not ' or '') + values = {'partner_assigned_id': False} + user = self.pool.get('res.users').browse(cr, uid, uid, context=context) + partner_id = user.parent_id.id or user.partner_id.id + partner_ids = self.pool.get('res.partner').search(cr, SUPERUSER_ID, ['|', ('id', '=', partner_id), ('parent_id', '=', partner_id)], context=context) + lead_obj.message_unsubscribe(cr, SUPERUSER_ID, context.get('active_ids'), partner_ids, context=None) + try: + stage_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_channel', stage)[1] + except ValueError: + stage_id = False + if stage_id: + values.update({'stage_id': stage_id}) + if wizard.comment: + message += '

%s

' % wizard.comment + lead_obj.message_post(cr, uid, context.get('active_ids'), body=message, context=context) + if values: + lead_obj.write(cr, SUPERUSER_ID, context.get('active_ids'), values) + if wizard.interested: + for lead in lead_obj.browse(cr, uid, context.get('active_ids'), context=context): + lead_obj.convert_opportunity(cr, SUPERUSER_ID, [lead.id], lead.partner_id and lead.partner_id.id or None, context=None) + return { + 'type': 'ir.actions.client', + 'tag': 'next_or_list', + 'params': { + }, + } diff --git a/addons/crm_channel/wizard/crm_channel_interested_view.xml b/addons/crm_channel/wizard/crm_channel_interested_view.xml new file mode 100644 index 00000000000..400e02cd48a --- /dev/null +++ b/addons/crm_channel/wizard/crm_channel_interested_view.xml @@ -0,0 +1,45 @@ + + + + + crm_lead_channel_interested + crm.lead.channel.interested + +
+ + +
+
+
+
+
+
+ +
+ +
+

+ Once the lead is processed, it will be in your "Opportunities" menu. +

+
+
+
+
+
+
+ + Lead Feedback + crm.lead.channel.interested + form + form + + new + +
+
\ No newline at end of file