summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstw@openerp.com <>2011-02-22 17:24:03 +0100
committerThibault Francois <tfr@openerp.com>2011-02-22 17:24:03 +0100
commita966a3a593e4c3abf56d2faaec1258a72ca00efd (patch)
tree1fe48f7d5c771d441aaee2ab6f4d619f1525ebfc
parent0811ebc7820fc89a1aac6d2f18cf96ade3d1018f (diff)
[FIX] partner and adress creation (by stw) + add send email button
bzr revid: tfr@openerp.com-20110222162403-1y8jaec31mp05d50
-rw-r--r--addons/crm/crm_lead_view.xml9
-rw-r--r--addons/crm/crm_opportunity_view.xml25
-rw-r--r--addons/crm/wizard/crm_lead_to_opportunity.py9
3 files changed, 30 insertions, 13 deletions
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index 776cb970321..564c9e35fce 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -13,8 +13,8 @@
<field name="context">{'type':'lead'}</field>
<field name="help">Add specific stages to leads and opportunities allowing your sales to better organise their sales pipeline. Stages will allow them to easily track how a specific lead or opportunity is positioned in the sales cycle.</field>
</record>
-
-
+
+
<menuitem action="crm_lead_stage_act" id="menu_crm_lead_stage_act" name="Lead stages"
groups="base.group_extended" sequence="0"
@@ -90,7 +90,10 @@
</group>
<group colspan="2" col="3">
<separator string="Communication" colspan="4" col="3"/>
- <field name="email_from" widget="email"/>
+ <field name="email_from" widget="email"/><button string="Send Email"
+ name="%(crm.action_crm_send_mail)d"
+ context="{'mail':'new', 'model': 'crm.lead'}"
+ icon="terp-mail-message-new" type="action" colspan="1"/>
<newline/>
<field name="phone"/>
<newline/>
diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml
index 61a5f3917d4..977998ce6c0 100644
--- a/addons/crm/crm_opportunity_view.xml
+++ b/addons/crm/crm_opportunity_view.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<openerp>
<data>
-
+
<record id="crm_opportunity_stage_act" model="ir.actions.act_window">
<field name="name">Stages</field>
<field name="res_model">crm.case.stage</field>
@@ -11,13 +11,13 @@
<field name="context">{'type':'opportunity'}</field>
<field name="help">Create specific stages that will help your sales better organise their sales pipeline by maintaining them to their sales opportunities. It will allow them to easily track how is positioned a specific opportunity in the sales cycle.</field>
</record>
-
+
<menuitem action="crm_opportunity_stage_act" id="menu_crm_opportunity_stage_act" name="Opportunity stages"
groups="base.group_extended" sequence="0"
parent="base.menu_crm_config_lead" />
-
+
<!-- Opportunities Form View -->
<record model="ir.ui.view" id="crm_case_form_view_oppor">
<field name="name">Opportunities</field>
@@ -74,8 +74,15 @@
string="Contact"
on_change="onchange_partner_address_id(partner_address_id, email_from)"
colspan="1" />
- <field name="email_from" string="Email" />
- <field name="phone"/>
+ <group col="3" colspan="2">
+ <field name="email_from" string="Email" />
+ <button string="Send Email"
+ name="%(crm.action_crm_send_mail)d"
+ context="{'mail':'new', 'model': 'crm.lead'}"
+ icon="terp-mail-message-new" type="action" />
+ </group>
+ <field name="phone"/>
+
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Categorization"/>
@@ -172,7 +179,7 @@
</group>
<notebook colspan="4">
<page string="Details">
-
+
<field name="description" colspan="4" nolabel="1"/>
<group attrs="{'invisible': [('history', '!=', True)]}">
<button colspan="4"
@@ -181,7 +188,7 @@
context="{'mail':'reply', 'model': 'crm.lead', 'include_original' : True}"
icon="terp-mail-replied" type="action" />
</group>
-
+
</page>
<page string="Attachments">
<field name="attachment_ids" colspan="4" readonly="1" nolabel="1"/>
@@ -380,8 +387,8 @@
</graph>
</field>
</record>
-
-
+
+
</data>
</openerp>
diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py
index 2ecadedf344..ead591d39c6 100644
--- a/addons/crm/wizard/crm_lead_to_opportunity.py
+++ b/addons/crm/wizard/crm_lead_to_opportunity.py
@@ -96,6 +96,10 @@ Leads Could not convert into Opportunity"))
def _convert(self, cr, uid, ids, lead, partner_id, stage_ids, context=None):
leads = self.pool.get('crm.lead')
+ address_id = self.pool.get('res.partner.address').search(cr, uid,
+ [('partner_id', '=', partner_id)],
+ order='create_date desc',
+ limit=1)
vals = {
'planned_revenue': lead.planned_revenue,
'probability': lead.probability,
@@ -104,8 +108,11 @@ Leads Could not convert into Opportunity"))
'user_id': (lead.user_id and lead.user_id.id),
'type': 'opportunity',
'stage_id': stage_ids and stage_ids[0] or False,
- 'date_action': time.strftime('%Y-%m-%d %H:%M:%S')
+ 'date_action': time.strftime('%Y-%m-%d %H:%M:%S'),
}
+ if address_id:
+ vals['partner_address_id'] = address_id[0]
+
lead.write(vals, context=context)
leads.history(cr, uid, [lead], _('Converted to opportunity'), details='Converted to Opportunity', context=context)
if lead.partner_id: