crm: Add the wizard of phonecall2meeting and improve the view of phonecall2phonecall

bzr revid: sbh@tinyerp.com-20100309094939-2w4am787wuls7mj4
This commit is contained in:
sbh (Open ERP) 2010-03-09 15:19:39 +05:30
parent 31487c201e
commit 2feb455905
7 changed files with 138 additions and 40 deletions

View File

@ -63,6 +63,7 @@ between mails and Open ERP.""",
'update_xml': [
'wizard/crm_phonecall2phonecall.xml',
'wizard/lead_to_partner_view.xml',
'wizard/phonecall2meeting.xml',
# 'wizard/phonecall2partner_view.xml',
'wizard/phonecall2opportunity.xml',
'crm_wizard.xml',

View File

@ -54,7 +54,7 @@
type="action" attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<button string="Meeting"
states="draft,open,pending"
name="%(wizard_crm_phonecall_meeting_set)d" type="action" />
name="%(phonecall2meeting_act)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="%(wizard_crm_phonecall_meeting_set)d"
name="%(phonecall2meeting_act)d"
icon="gtk-redo"
type="action" />
<field name="partner_phone"/>

View File

@ -30,6 +30,7 @@ import crm_phonecall2phonecall
import lead_to_partner
import phonecall2partner
import phonecall2meeting
import phonecall_to_opportunity
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -40,37 +40,41 @@ class crm_phonecall2phonecall(osv.osv_memory):
def action_apply(self, cr, uid, ids, context=None):
this = self.browse(cr, uid, ids)[0]
record_id = context and context.get('record_id', False) or False
values={}
values['name']=this.name
values['user_id']=this.user_id and this.user_id.id
values['categ_id']=this.category_id and this.category_id.id
values['section_id']=this.section_id and this.section_id.id or False,
values['description']=this.notes or ''
values['partner_id']=this.partner_id.id
values['partner_address_id']=this.address_id.id
phonecall_proxy = self.pool.get('crm.phonecall')
phonecall_id = phonecall_proxy.create(cr, uid, values, context=context)
value = {
'name': _('Phone Call'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'crm.phonecall',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id': phonecall_id
}
record_id = context and context.get('record_id', False) or False
if record_id:
for case in self.pool.get('crm.phonecall').browse(cr, uid, [record_id], context=context):
values['name']=this.name
values['user_id']=this.user_id and this.user_id.id
values['categ_id']=case.categ_id and case.categ_id.id or False
values['section_id']=case.section_id and case.section_id.id or False,
values['description']=case.description or ''
values['partner_id']=case.partner_id.id
values['partner_address_id']=case.partner_address_id.id
values['partner_mobile']=case.partner_mobile or False
values['priority']=case.priority
values['partner_phone']=case.partner_phone or False
values['date']=this.date
phonecall_proxy = self.pool.get('crm.phonecall')
phonecall_id = phonecall_proxy.create(cr, uid, values, context=context)
value = {
'name': _('Phone Call'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'crm.phonecall',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id': phonecall_id
}
return value
_columns = {
'name' : fields.char('Name', size=64, required=True, select=1),
'name' : fields.char('Call summary', size=64, required=True, select=1),
'user_id' : fields.many2one('res.users',"Assign To"),
'deadline': fields.datetime('Deadline', readonly=True),
'category_id' : fields.many2one('crm.case.categ','Category',domain="[('object_id.model', '=', ''crm.phonecall')]"),
'date': fields.datetime('Date'),
'section_id':fields.many2one('crm.case.section','Sales Team'),
'partner_id': fields.many2one('res.partner', 'Partner'),
'address_id': fields.many2one('res.partner.address', 'Partner Contact', domain="[('partner_id','=',partner_id)]"),
'notes' : fields.text('Notes'),
}
def default_get(self, cr, uid, fields, context=None):
record_id = context and context.get('record_id', False) or False
@ -78,11 +82,8 @@ class crm_phonecall2phonecall(osv.osv_memory):
if record_id:
phonecall_id = self.pool.get('crm.phonecall').browse(cr, uid, record_id, context=context)
res['name']=phonecall_id.name
res['user_id']=phonecall_id.user_id and phonecall_id.user_id.id
res['section_id']=phonecall_id.section_id and phonecall_id.section_id.id
res['notes']=phonecall_id.description and phonecall_id.description or ''
res['category_id']=phonecall_id.categ_id and phonecall_id.categ_id.id
res['partner_id']=phonecall_id.partner_id and phonecall_id.partner_id.id
res['address_id']=phonecall_id.partner_address_id and phonecall_id.partner_address_id.id
res['user_id']=phonecall_id.user_id and phonecall_id.user_id.id or False
res['date']=phonecall_id.date
res['section_id']=phonecall_id.section_id and phonecall_id.section_id.id or False
return res
crm_phonecall2phonecall()

View File

@ -6,16 +6,11 @@
<field name="model">crm.phonecall2phonecall</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Schedule Other Call " col="2">
<form string="Schedule Other Call" col="2">
<field name="name"/>
<field name="user_id" />
<separator colspan="3" string="Contacts" />
<field name="partner_id"/>
<field name="address_id"/>
<separator colspan="3" string="" />
<field name="category_id" domain="[('object_id.model', '=', 'crm.phonecall')]" />
<field name="section_id"/>
<field name="notes"/>
<field name="date" string="Planned Date"/>
<group colspan="2" col="2" >
<button name="action_cancel" string="_Cancel" icon="gtk-cancel" special="cancel" />
<button name="action_apply" type="object" string="_Apply" icon="gtk-apply" />

View File

@ -0,0 +1,75 @@
# -*- encoding: utf-8 -*-
############################################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# Copyright (C) 2008-2009 AJM Technologies S.A. (<http://www.ajm.lu). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
############################################################################################
############################################################################################
from osv import osv, fields
import netsvc
import time
import tools
import mx.DateTime
from tools import config
from tools.translate import _
import tools
class crm_phonecall2meeting(osv.osv_memory):
_name = 'crm.phonecall2meeting'
_description = 'Phonecall To Meeting'
def action_cancel(self, cr, uid, ids, context=None):
return {'type':'ir.actions.act_window_close'}
def _makeMeeting(self, cr, uid, ids, context=None):
this = self.browse(cr, uid, ids[0], context=context)
record_id = context and context.get('record_id', False) or False
if record_id:
phonecall_case_obj = self.pool.get('crm.phonecall')
data_obj = self.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, record_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']
}
crm_phonecall2meeting()

View File

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="phonecall2phonecall2meeting_view">
<field name="name">crm.phonecall2meeting.form</field>
<field name="model">crm.phonecall2meeting</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Convert To Meeting ">
<button name="action_cancel" string="_Cancel" icon="gtk-cancel" special="cancel" />
<button name="_makeMeeting" type="object" string="_Apply" icon="gtk-apply" />
</form>
</field>
</record>
<record model="ir.actions.act_window" id="phonecall2meeting_act">
<field name="name">Convert To Meeting</field>
<field name="res_model">crm.phonecall2meeting</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="phonecall2phonecall2meeting_view"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
</data>
</openerp>