[FIX] crm: correct open lead or opportunity view from calls

When opening a lead/opportunity from the phonecalls view, we did not open the correct view (always the lead).
This will use the type of the crm.lead to determine which view should be used, opw 608493.
This commit is contained in:
Ravi Gohil 2014-06-09 14:58:30 +05:30 committed by Martin Trigaux
parent 933d098e7d
commit 126ba0a9a8
2 changed files with 6 additions and 1 deletions

View File

@ -165,6 +165,11 @@ class crm_lead(base_stage, format_address, osv.osv):
return result, fold
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
if view_type == 'form' and context and context.get('opportunity_id'):
# TODO: replace by get_formview_action call
lead_type = self.browse(cr, user, context['opportunity_id'], context=context).type
view_lead_xml_id = 'crm_case_form_view_oppor' if lead_type == 'opportunity' else 'crm_case_form_view_leads'
_, view_id = self.pool['ir.model.data'].get_object_reference(cr, user, 'crm', view_lead_xml_id)
res = super(crm_lead,self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
if view_type == 'form':
res['arch'] = self.fields_view_get_address(cr, user, res['arch'], context=context)

View File

@ -110,7 +110,7 @@
domain="[('object_id.model', '=', 'crm.phonecall')]"/>
<field name="partner_mobile"/>
<field name="priority"/>
<field name="opportunity_id" on_change="on_change_opportunity(opportunity_id)"/>
<field name="opportunity_id" on_change="on_change_opportunity(opportunity_id)" context="{'opportunity_id': opportunity_id}"/>
</group>
<field name="description" placeholder="Description..."/>
</sheet>