[FIX] crm_partner_assign: replace the stage assigned/recycle from lead
Stage has been removed for lead in saas-9. So we replace the stage by a tag temporary. It could be replaced by a new field selection in master
This commit is contained in:
@@ -40,3 +40,10 @@ class crm_lead(osv.osv):
|
||||
for salesman_id, lead_ids in salesmans_leads.items():
|
||||
salesteam_id = self.on_change_user(cr, uid, lead_ids, salesman_id, context=None)['value'].get('team_id')
|
||||
self.write(cr, uid, lead_ids, {'user_id': salesman_id, 'team_id': salesteam_id}, context=context)
|
||||
|
||||
def set_tag_assign(self, cr, uid, ids, assign, context=None):
|
||||
ASSIGNED = 'tag_portal_lead_assigned'
|
||||
RECYCLE = 'tag_portal_lead_recycle'
|
||||
tag_to_add = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_partner_assign', assign and ASSIGNED or RECYCLE)[1]
|
||||
tag_to_rem = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_partner_assign', assign and RECYCLE or ASSIGNED)[1]
|
||||
self.write(cr, uid, ids, {'tag_ids': [(3, tag_to_rem, False), (4, tag_to_add, False)]}, context=context)
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
<?xml version="1.0" ?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record model="crm.stage" id="stage_portal_lead_assigned">
|
||||
<record model="crm.lead.tag" id="tag_portal_lead_assigned">
|
||||
<field name="name">Assigned</field>
|
||||
<field eval="10" name="probability"/>
|
||||
<field eval="12" name="sequence"/>
|
||||
<field name="color">3</field>
|
||||
</record>
|
||||
<record model="crm.stage" id="stage_portal_lead_recycle">
|
||||
<record model="crm.lead.tag" id="tag_portal_lead_recycle">
|
||||
<field name="name">To Recycle</field>
|
||||
<field eval="5" name="probability"/>
|
||||
<field eval="11" name="sequence"/>
|
||||
<field name="color">3</field>
|
||||
</record>
|
||||
<record id="email_template_lead_forward_mail" model="mail.template">
|
||||
<field name="name">Lead Mass Mail</field>
|
||||
|
||||
@@ -27,7 +27,7 @@ class crm_lead_report_assign(osv.osv):
|
||||
'probability_max': fields.float('Max Probability',digits=(16,2),readonly=True, group_operator="max"),
|
||||
'planned_revenue': fields.float('Planned Revenue',digits=(16,2),readonly=True),
|
||||
'probable_revenue': fields.float('Probable Revenue', digits=(16,2),readonly=True),
|
||||
'stage_id': fields.many2one ('crm.stage', 'Stage', domain="[('team_ids', '=', team_id)]"),
|
||||
'tag_ids': fields.many2many('crm.lead.tag', 'crm_lead_tag_rel', 'lead_id', 'tag_id', 'Tags'),
|
||||
'partner_id': fields.many2one('res.partner', 'Customer' , readonly=True),
|
||||
'opening_date': fields.datetime('Opening Date', readonly=True),
|
||||
'date_closed': fields.datetime('Close Date', readonly=True),
|
||||
@@ -56,7 +56,6 @@ class crm_lead_report_assign(osv.osv):
|
||||
c.user_id,
|
||||
c.probability,
|
||||
c.probability as probability_max,
|
||||
c.stage_id,
|
||||
c.type,
|
||||
c.company_id,
|
||||
c.priority,
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
<group expand="0" string="Extended Filters...">
|
||||
<field name="partner_id"/>
|
||||
<separator/>
|
||||
<field name="stage_id" widget="selection" domain="[('team_ids', '=', 'team_id')]"/>
|
||||
<separator />
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
<field name="opening_date"/>
|
||||
<field name="date_closed"/>
|
||||
@@ -26,7 +24,6 @@
|
||||
context="{'group_by':'user_id'}" />
|
||||
<filter string="Sales Team" context="{'group_by':'team_id'}"/>
|
||||
<filter string="Country" context="{'group_by':'country_id'}" />
|
||||
<filter string="Stage" context="{'group_by':'stage_id'}"/>
|
||||
<filter string="Company" context="{'group_by':'company_id'}" />
|
||||
<separator/>
|
||||
<filter string="Assign Month" context="{'group_by':'date_assign:month'}"/>
|
||||
@@ -42,7 +39,6 @@
|
||||
<field name="model">crm.lead.report.assign</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Lead Assign" disable_linking="True">
|
||||
<field name="stage_id" type="row"/>
|
||||
<field name="date_assign" interval="month" type="col"/>
|
||||
<field name="delay_open" type="measure"/>
|
||||
<field name="probability" type="measure"/>
|
||||
@@ -58,7 +54,6 @@
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Lead Assign">
|
||||
<field name="date_assign"/>
|
||||
<field name="stage_id"/>
|
||||
<field name="delay_open" type="measure"/>
|
||||
</graph>
|
||||
</field>
|
||||
|
||||
@@ -30,7 +30,6 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
||||
message = _('<p>I am interested by this lead.</p>')
|
||||
values = {}
|
||||
else:
|
||||
stage = 'stage_portal_lead_recycle'
|
||||
if wizard.contacted:
|
||||
message = _('<p>I am not interested by this lead. I contacted the lead.</p>')
|
||||
else:
|
||||
@@ -39,18 +38,13 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
partner_ids = self.pool.get('res.partner').search(cr, SUPERUSER_ID, [('id', 'child_of', user.partner_id.commercial_partner_id.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_partner_assign', stage)[1]
|
||||
except ValueError:
|
||||
stage_id = False
|
||||
if stage_id:
|
||||
values.update({'stage_id': stage_id})
|
||||
if wizard.comment:
|
||||
message += '<p>%s</p>' % wizard.comment
|
||||
for active_id in context.get('active_ids', []):
|
||||
lead_obj.message_post(cr, uid, active_id, body=message, subtype="mail.mt_comment", context=context)
|
||||
if values:
|
||||
lead_obj.write(cr, SUPERUSER_ID, context.get('active_ids', []), values)
|
||||
lead_obj.set_tag_assign(cr, SUPERUSER_ID, context.get('active_ids', []), False)
|
||||
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)
|
||||
|
||||
@@ -96,12 +96,6 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
||||
partner_leads['leads'].append(lead_details)
|
||||
else:
|
||||
partners_leads[partner.id] = {'partner': partner, 'leads': [lead_details]}
|
||||
stage_id = False
|
||||
if record.assignation_lines and record.assignation_lines[0].lead_id.type == 'lead':
|
||||
try:
|
||||
stage_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_partner_assign', 'stage_portal_lead_assigned')[1]
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
for partner_id, partner_leads in partners_leads.items():
|
||||
in_portal = False
|
||||
@@ -115,9 +109,9 @@ class crm_lead_forward_to_partner(osv.TransientModel):
|
||||
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']]
|
||||
values = {'partner_assigned_id': partner_id, 'user_id': partner_leads['partner'].user_id.id}
|
||||
if stage_id:
|
||||
values['stage_id'] = stage_id
|
||||
lead_obj.write(cr, uid, lead_ids, values)
|
||||
lead_obj.set_tag_assign(cr, uid, lead_ids, True)
|
||||
|
||||
self.pool.get('crm.lead').message_subscribe(cr, uid, lead_ids, [partner_id], context=context)
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user