[ADD&FIX]crm_channel: add wizard for buttons interested & not, fix portal url
bzr revid: dle@openerp.com-20130620151907-qeu1c2wkk5vs72l7
This commit is contained in:
parent
f650c896e2
commit
21dd35ede5
|
@ -43,6 +43,7 @@ You can also use the geolocalization without using the GPS coordinates.
|
|||
'security/ir.model.access.csv',
|
||||
'res_partner_view.xml',
|
||||
'wizard/crm_forward_to_partner_view.xml',
|
||||
'wizard/crm_channel_interested_view.xml',
|
||||
'crm_lead_view.xml',
|
||||
'crm_channel_data.xml',
|
||||
'crm_data.xml',
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
<data noupdate="1">
|
||||
|
||||
<!-- Crm stages -->
|
||||
<record model="crm.case.stage" id="stage_portal_lead_assigned">
|
||||
<field name="name">Assigned</field>
|
||||
<field eval="1" name="case_default"/>
|
||||
<field eval="0" name="probability"/>
|
||||
<field eval="4" name="sequence"/>
|
||||
</record>
|
||||
<record model="crm.case.stage" id="stage_portal_lead_recycle">
|
||||
<field name="name">To Recycle</field>
|
||||
<field eval="1" name="case_default"/>
|
||||
|
|
|
@ -20,38 +20,25 @@
|
|||
##############################################################################
|
||||
|
||||
from openerp.osv import osv
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class crm_lead(osv.osv):
|
||||
_inherit = 'crm.lead'
|
||||
|
||||
def case_interested(self, cr, uid, ids, context=None):
|
||||
self.check_access_rights(cr, uid, 'write')
|
||||
def get_interested_action(self, cr, uid, interested, context=None):
|
||||
try:
|
||||
stage_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_channel', 'stage_portal_lead_interested')[1]
|
||||
model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_channel', 'crm_lead_channel_interested_act')
|
||||
except ValueError:
|
||||
stage_id = False
|
||||
if stage_id:
|
||||
self.write(cr, SUPERUSER_ID, ids, {'stage_id': stage_id})
|
||||
self.message_post(cr, uid, ids, body=_('I am interested by this lead'), context=context)
|
||||
raise osv.except_osv(_('Error!'), _("The CRM Channel Interested Action is missing"))
|
||||
action = self.pool[model].read(cr, uid, action_id, context=context)
|
||||
action_context = eval(action['context'])
|
||||
action_context['interested'] = interested
|
||||
action['context'] = str(action_context)
|
||||
return action
|
||||
|
||||
def case_interested(self, cr, uid, ids, context=None):
|
||||
return self.get_interested_action(cr, uid, True, context=context)
|
||||
|
||||
def case_disinterested(self, cr, uid, ids, context=None):
|
||||
self.check_access_rights(cr, uid, 'write')
|
||||
try:
|
||||
stage_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_channel', 'stage_portal_lead_recycle')[1]
|
||||
except ValueError:
|
||||
stage_id = False
|
||||
values = {}
|
||||
values = {'partner_assigned_id': False}
|
||||
if stage_id:
|
||||
values['stage_id'] = stage_id
|
||||
self.message_post(cr, uid, ids, body=_('I am not interested by this lead'), context=context)
|
||||
self.write(cr, SUPERUSER_ID, ids, values, context=context)
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'next_or_list',
|
||||
'params': {
|
||||
},
|
||||
}
|
||||
return self.get_interested_action(cr, uid, False, context=context)
|
||||
|
|
|
@ -7,6 +7,7 @@ openerp.crm_channel = function (instance) {
|
|||
if (!form.dataset.ids.length){
|
||||
parent.inner_widget.switch_mode('list');
|
||||
}
|
||||
parent.do_action({ type: 'ir.actions.act_window_close' });
|
||||
};
|
||||
instance.web.client_actions.add("next_or_list", "instance.crm_channel.next_or_list");
|
||||
}
|
|
@ -20,3 +20,4 @@
|
|||
##############################################################################
|
||||
|
||||
import crm_forward_to_partner
|
||||
import crm_channel_interested
|
|
@ -28,8 +28,7 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
|||
""" Forward info history to partners. """
|
||||
_name = 'crm.lead.forward.to.partner'
|
||||
|
||||
def _convert_to_assignation_line(self, cr, uid, lead, partner):
|
||||
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
||||
def _convert_to_assignation_line(self, cr, uid, lead, partner, context=None):
|
||||
lead_location = []
|
||||
partner_location = []
|
||||
if lead.country_id:
|
||||
|
@ -45,7 +44,7 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
|||
'lead_location': ", ".join(lead_location),
|
||||
'partner_assigned_id': partner and partner.id or False,
|
||||
'partner_location': ", ".join(partner_location),
|
||||
'lead_link': "%s/?db=%s#id=%s&model=crm.lead" % (base_url, cr.dbname, lead.id)
|
||||
'lead_link': self.get_portal_url(cr, uid, lead.id, context=context),
|
||||
}
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
|
@ -89,10 +88,10 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
|||
_('The Forward Email Template is not in the database'))
|
||||
local_context = context.copy()
|
||||
if not (record.forward_type == 'single'):
|
||||
no_email = []
|
||||
no_email = set()
|
||||
for lead in record.assignation_lines:
|
||||
if lead.partner_assigned_id and not lead.partner_assigned_id.email:
|
||||
no_email.append(lead.partner_assigned_id.name)
|
||||
no_email.add(lead.partner_assigned_id.name)
|
||||
if no_email:
|
||||
raise osv.except_osv(_('Email Error'),
|
||||
('Set an email address for the partner(s): %s' % ", ".join(no_email)))
|
||||
|
@ -113,29 +112,25 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
|||
partner_leads['leads'].append(lead_details)
|
||||
else:
|
||||
partners_leads[partner.id] = {'partner': partner, 'leads': [lead_details]}
|
||||
try:
|
||||
stage_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_channel', 'stage_portal_lead_assigned')[1]
|
||||
except ValueError:
|
||||
stage_id = False
|
||||
for partner_id, partner_leads in partners_leads.items():
|
||||
local_context['partner_id'] = partner_leads['partner']
|
||||
local_context['partner_leads'] = partner_leads['leads']
|
||||
email_template_obj.send_mail(cr, uid, template_id, ids[0], context=local_context)
|
||||
lead_ids = [lead['lead_id'].id for lead in partner_leads['leads']]
|
||||
lead_obj.write(cr, uid, lead_ids, {'partner_assigned_id': partner_id, 'user_id': partner_leads['partner'].user_id.id})
|
||||
lead_obj.write(cr, uid, lead_ids, {'partner_assigned_id': partner_id, 'user_id': partner_leads['partner'].user_id.id, 'stage_id': stage_id})
|
||||
self.pool.get('crm.lead').message_subscribe(cr, uid, lead_ids, [partner_id], context=context)
|
||||
return True
|
||||
|
||||
# def action_clean_lines(self, cr, uid, ids, context=None):
|
||||
# record = self.browse(cr, uid, ids[0], context=context)
|
||||
# invalid_lines = []
|
||||
# for line in record.assignation_lines:
|
||||
# if not line.partner_assigned_id:
|
||||
# invalid_lines.append((2, line.id))
|
||||
# self.write(cr, uid, ids[0], {'assignation_lines': invalid_lines}, context=context)
|
||||
# model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_channel', 'action_crm_send_mass_forward')
|
||||
# action = self.pool[model].read(cr, uid, action_id, context=context)
|
||||
# action['res_id'] = ids[0]
|
||||
# return action
|
||||
|
||||
def get_portal_url(self, cr, uid, ids, context=None):
|
||||
portal_link = "%s/?db=%s" % (self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'), cr.dbname)
|
||||
def get_portal_url(self, cr, uid, lead_id, context=None):
|
||||
try:
|
||||
action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_channel', 'action_portal_leads')[1]
|
||||
except ValueError:
|
||||
action_id = False
|
||||
portal_link = "%s/?db=%s#id=%s&action=%s&view_type=form" % (self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'), cr.dbname, lead_id, action_id)
|
||||
return portal_link
|
||||
|
||||
_columns = {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
<group>
|
||||
</group>
|
||||
</group>
|
||||
<!-- <button name="action_clean_lines" string="Clean Unassigned" type="object" attrs="{'invisible': [('forward_type', 'in', ['single',False])]}"/> -->
|
||||
<field name="assignation_lines" attrs="{'invisible': [('forward_type', 'in', ['single',False])]}">
|
||||
<tree create="false" editable="bottom">
|
||||
<field name="lead_id" readonly="1" on_change="on_change_lead_id(lead_id)"/>
|
||||
|
|
Loading…
Reference in New Issue