[IMP, ADD]: Improved wizards code. Added opportunity2meeting wizard on business opportunity.

bzr revid: uco@tinyerp.co.in-20100113064110-z4q6041wr86gbv7w
This commit is contained in:
uco (OpenERP)
2010-01-13 12:11:10 +05:30
parent 9e7cd31f0e
commit 992d2138ac
6 changed files with 85 additions and 9 deletions
+4 -3
View File
@@ -60,9 +60,10 @@
</group>
<field name="categ_id" select="1" on_change="onchange_categ_id(categ_id)" string="Lead Source"/>
<field name="category2_id" string="Campaign Type" select="1"/>
<newline/>
<field name="opportunity_id" string="Opportunity Case"/>
<button string="Convert to Opportunity" name="%(wizard_crm_lead_opportunity_set)d" icon="gtk-index" type="action"/>
</group>
<group colspan="2" col="4">
<field name="opportunity_id" string="Opportunity Case"/>
<button string="Convert to Opportunity" name="%(wizard_crm_lead_opportunity_set)d" icon="gtk-index" type="action"/>
</group>
<notebook colspan="4">
<page string="Leads">
+1 -1
View File
@@ -55,7 +55,7 @@
<field name="section_id" colspan="1" widget="selection"/>
<field name="user_id" select="2" string="Responsible"/>
<button string="Schedule a Meeting"
name="%(wizard_crm_phonecall_meeting_set)d" icon="gtk-redo" type="action" />
name="%(wizard_crm_opportunity_meeting_set)d" icon="gtk-redo" type="action" />
<newline/>
<label string="Sales Stage: " align="1.0"/>
<group colspan="1" col="2">
+9 -3
View File
@@ -16,9 +16,15 @@
name="crm.case.opportunity.partner_opportunity"
menu="False"
string="Create Opportunity"/>
<wizard
id="wizard_crm_opportunity_meeting_set"
keyword="client_action_multi"
model="crm.opportunity"
name="crm.opportunity.meeting_set"
menu="False"
string="Schedule Meeting"/>
<wizard
id="wizard_partner_create_opportunity1"
keyword="client_action_relate"
+1 -1
View File
@@ -115,7 +115,7 @@ class lead2opportunity(wizard.interface):
lead_case_obj.write(cr, uid, [lead.id], vals)
lead_case_obj.case_cancel(cr, uid, [lead.id])
# opportunity_case_obj.case_open(cr, uid, [new_opportunity_id])
opportunity_case_obj.case_open(cr, uid, [new_opportunity_id])
value = {
'name': _('Opportunity'),
@@ -123,6 +123,75 @@ class opportunity2phonecall(wizard.interface):
opportunity2phonecall('crm.opportunity.reschedule_phone_call')
class opportunity2meeting(wizard.interface):
case_form = """<?xml version="1.0"?>
<form string="Plan Meeting">
<field name="date"/>
<field name="duration" widget="float_time"/>
<label string="Note that you can also use the calendar view to graphically schedule your next meeting." colspan="4"/>
</form>"""
case_fields = {
'date': {'string': 'Meeting date', 'type': 'datetime', 'required': 1},
'duration': {'string': 'Duration (Hours)', 'type': 'float', 'required': 1}
}
def _selectPartner(self, cr, uid, data, context):
case_obj = pooler.get_pool(cr.dbname).get('crm.opportunity')
case = case_obj.browse(cr, uid, data['id'])
return {'date': case.date, 'duration': 2.0}
def _makeMeeting(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
opportunity_case_obj = pool.get('crm.opportunity')
meeting_case_obj = pool.get('crm.meeting')
for opportunity in opportunity_case_obj.browse(cr, uid, data['ids']):
new_meeting_id = meeting_case_obj.create(cr, uid, {
'name': opportunity.name,
'date': data['form']['date'],
'duration': data['form']['duration'],
})
new_meeting = meeting_case_obj.browse(cr, uid, new_meeting_id)
vals = {}
opportunity_case_obj.write(cr, uid, [opportunity.id], vals)
opportunity_case_obj.case_cancel(cr, uid, [opportunity.id])
meeting_case_obj.case_open(cr, uid, [new_meeting_id])
data_obj = pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
id = data_obj.read(cr, uid, result, ['res_id'])
id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet')
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet')
if id1:
id1 = data_obj.browse(cr, uid, id1, context=context).res_id
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
return {
'name': _('Meetings'),
'view_type': 'form',
'view_mode': 'calendar,form,tree',
'res_model': 'crm.meeting',
'view_id': False,
'views': [(id1,'calendar'),(id2,'form'),(id3,'tree'),(False,'graph')],
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
states = {
'init': {
'actions': [_selectPartner],
'result': {'type': 'form', 'arch': case_form, 'fields': case_fields,
'state' : [('end', 'Cancel','gtk-cancel'),('order', 'Set Meeting','gtk-go-forward')]}
},
'order': {
'actions': [],
'result': {'type': 'action', 'action': _makeMeeting, 'state': 'end'}
}
}
opportunity2meeting('crm.opportunity.meeting_set')
class partner_opportunity(wizard.interface):
+1 -1
View File
@@ -113,7 +113,7 @@ class phonecall2opportunity(wizard.interface):
vals.update({'opportunity_id' : new_opportunity.id})
phonecall_case_obj.write(cr, uid, [phonecall.id], vals)
phonecall_case_obj.case_cancel(cr, uid, [phonecall.id])
# opportunity_case_obj.case_open(cr, uid, [new_opportunity_id])
opportunity_case_obj.case_open(cr, uid, [new_opportunity_id])
value = {
'name': _('Opportunity'),
'view_type': 'form',