[ADD]: crm: Added old wizard for phonecall and opportunity to meeting because of action in init of wizard is not possible in osv_memory wizard

bzr revid: rpa@tinyerp.com-20100319125250-6m68rs678puy31ta
This commit is contained in:
rpa (Open ERP) 2010-03-19 18:22:50 +05:30
parent 7a7d44d5a5
commit b901634015
6 changed files with 135 additions and 3 deletions

View File

@ -64,7 +64,7 @@
</group>
<field name="user_id"/>
<button string="Schedule Meeting"
name="%(opportunity2meeting_act)d" icon="gtk-redo" type="action" />
name="%(wizard_crm_opportunity_meeting_set)d" icon="gtk-redo" type="action" />
<field name="planned_revenue"/>
<field name="probability"/>
<field name="date_deadline" string="Expected Closing"/>

View File

@ -54,7 +54,7 @@
type="action" attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<button string="Meeting"
states="draft,open,pending"
name="%(phonecall2meeting_act)d" type="action" />
name="%(wizard_crm_phonecall_meeting_set)d" type="action" />
<field name="state"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_close" string="Held" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
@ -75,7 +75,7 @@
<field name="date" string="Planned Date"/>
<field name="user_id"/>
<button string="Schedule a Meeting"
name="%(phonecall2meeting_act)d"
name="%(wizard_crm_phonecall_meeting_set)d"
icon="gtk-redo"
type="action" />
<field name="partner_phone"/>

View File

@ -21,6 +21,64 @@
from osv import osv
from tools.translate import _
import wizard
import pooler
#===============================================================================
# Put original wizard because of action in init
# Remove it after solution foraction in init
#===============================================================================
class opportunity2meeting(wizard.interface):
def _makeMeeting(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
opportunity_case_obj = pool.get('crm.opportunity')
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
opportunity = opportunity_case_obj.browse(cr, uid, data['id'], context=context)
partner_id = opportunity.partner_id and opportunity.partner_id.id or False
name = opportunity.name
email = opportunity.email_from
section_id = opportunity.section_id and opportunity.section_id.id or False
return {
'name': _('Meetings'),
'domain' : "[('user_id','=',%s), ('opportunity_id', '=', %s)]"%(uid, data['id']),
'context': {'default_partner_id': partner_id,
'default_opportunity_id': data['id'],
'default_section_id': section_id,
'default_email_from': email,
'default_state':'open', 'default_name':name},
'view_type': 'form',
'view_mode': 'tree,form,calendar',
'res_model': 'crm.meeting',
'view_id': False,
'views': [(id1, 'calendar'), (id3, 'tree'), (id2, 'form')],
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
states = {
'init': {
'actions': [],
'result': {'type': 'action', 'action': _makeMeeting, 'state': 'order'}
},
'order': {
'actions': [],
'result': {'type': 'state', 'state': 'end'}
}
}
opportunity2meeting('crm.opportunity.meeting_set')
class crm_opportunity2meeting(osv.osv_memory):
_name = 'crm.opportunity2meeting'

View File

@ -1,6 +1,16 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Old wizard -->
<wizard
id="wizard_crm_opportunity_meeting_set"
keyword="client_action_multi"
model="crm.opportunity"
name="crm.opportunity.meeting_set"
menu="False"
string="Schedule Meeting"/>
<!-- Opportunity to meeting view -->

View File

@ -21,6 +21,60 @@
from osv import osv
from tools.translate import _
import wizard
import pooler
#===============================================================================
# Put original wizard because of action in init
# Remove it after solution foraction in init
#===============================================================================
class phonecall2meeting(wizard.interface):
def _makeMeeting(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
phonecall_case_obj = pool.get('crm.phonecall')
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
phonecall = phonecall_case_obj.browse(cr, uid, data['id'], context=context)
partner_id = phonecall.partner_id and phonecall.partner_id.id or False
name = phonecall.name
email = phonecall.email_from
section_id = phonecall.section_id and phonecall.section_id.id or False
return {
'name': _('Meetings'),
'domain' : "[('user_id','=',%s)]"%(uid),
'context': {'default_partner_id': partner_id, 'default_section_id': section_id, 'default_email_from': email, 'default_state':'open', 'default_name':name},
'view_type': 'form',
'view_mode': 'calendar,form,tree',
'res_model': 'crm.meeting',
'view_id': False,
'views': [(id1,'calendar'),(id2,'form'),(id3,'tree')],
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
states = {
'init': {
'actions': [],
'result': {'type': 'action', 'action': _makeMeeting, 'state': 'order'}
},
'order': {
'actions': [],
'result': {'type': 'state', 'state': 'end'}
}
}
phonecall2meeting('crm.phonecall.meeting_set')
class crm_phonecall2meeting(osv.osv_memory):
""" Phonecall to Meeting """

View File

@ -2,6 +2,16 @@
<openerp>
<data>
<!-- Old wizard -->
<wizard
id="wizard_crm_phonecall_meeting_set"
keyword="client_action_multi"
model="crm.phonecall"
name="crm.phonecall.meeting_set"
multi="True"
string="Schedule Meeting"/>
<!-- Phonecall to meeting view -->
<record model="ir.ui.view" id="phonecall2phonecall2meeting_view">