diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index d7b67879a7a..fd9b7780cec 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -331,8 +331,6 @@ class crm_case(object):
if not case.user_id:
data['user_id'] = uid
self.write(cr, uid, case.id, data)
-
-
self._action(cr, uid, cases, 'open')
return True
@@ -423,11 +421,14 @@ class crm_case(object):
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
+ state = 'draft'
+ if 'crm.phonecall' in args:
+ state = 'open'
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
self._history(cr, uid, cases, _('Draft'))
- self.write(cr, uid, ids, {'state': 'draft', 'active': True})
- self._action(cr, uid, cases, 'draft')
+ self.write(cr, uid, ids, {'state': state, 'active': True})
+ self._action(cr, uid, cases, state)
return True
def remind_partner(self, cr, uid, ids, context=None, attach=False):
@@ -454,9 +455,9 @@ class crm_case(object):
"""
for case in self.browse(cr, uid, ids, context=context):
if not destination and not case.email_from:
- raise osv.except_osv(_('Error!'), ("Partner Email is not specified in Case"))
+ return False
if not case.user_id.user_email:
- raise osv.except_osv(_('Error!'), ("User Email is not specified in Case"))
+ return False
if destination and case.section_id.user_id:
case_email = case.section_id.user_id.user_email
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 864e4dfc0a4..090664570e5 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -143,7 +143,7 @@ class crm_lead(crm_case, osv.osv):
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.lead')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Campaign', \
domain="['|',('section_id','=',section_id),('section_id','=',False)]"),
- 'channel_id': fields.many2one('res.partner.canal', 'Channel'),
+ 'channel_id': fields.many2one('res.partner.canal', 'Lead Source'),
'contact_name': fields.char('Contact Name', size=64),
'partner_name': fields.char("Customer Name", size=64,help='The name of the future partner that will be created while converting the into opportunity'),
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index 45f14c3e2df..c98adb86bb9 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -334,7 +334,7 @@
domain="[('user_id','=', False)]"
help="Unassigned Leads" />
-
+
-
+
@@ -310,7 +310,7 @@
domain="[]"
help="Show Sales Team"/>
-
+
@@ -326,6 +326,7 @@
+
diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py
index 6a4e7bfd7c7..41af82ec8fc 100644
--- a/addons/crm/crm_phonecall.py
+++ b/addons/crm/crm_phonecall.py
@@ -53,10 +53,10 @@ class crm_phonecall(crm_case, osv.osv):
('draft', 'Draft'),
('open', 'Todo'),
('cancel', 'Cancelled'),
- ('done', 'Done'),
- ('pending', 'Pending'),
+ ('done', 'Held'),
+ ('pending', 'Not Held'),
], 'State', size=16, readonly=True,
- help='The state is set to \'Draft\', when a case is created.\
+ help='The state is set to \'Todo\', when a case is created.\
\nIf the case is in progress the state is set to \'Open\'.\
\nWhen the case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
@@ -79,14 +79,19 @@ class crm_phonecall(crm_case, osv.osv):
the canall which is this opportunity source."),
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
- 'opportunity_id': fields.many2one ('crm.lead', 'Opportunity'),
+ 'opportunity_id': fields.many2one ('crm.lead', 'Lead/Opportunity'),
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
}
+ def _get_default_state(self, cr, uid, context=None):
+ if context and context.get('default_state', False):
+ return context.get('default_state')
+ return 'open'
+
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'priority': crm.AVAILABLE_PRIORITIES[2][0],
- 'state': 'open',
+ 'state': _get_default_state,
'user_id': lambda self,cr,uid,ctx: uid,
'active': 1,
}
@@ -122,14 +127,14 @@ class crm_phonecall(crm_case, osv.osv):
return res
def case_reset(self, cr, uid, ids, *args):
- """Resets case as draft
+ """Resets case as Todo
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
- res = super(crm_phonecall, self).case_reset(cr, uid, ids, args)
+ res = super(crm_phonecall, self).case_reset(cr, uid, ids, args, 'crm.phonecall')
self.write(cr, uid, ids, {'duration': 0.0})
return res
diff --git a/addons/crm/crm_phonecall_demo.xml b/addons/crm/crm_phonecall_demo.xml
index 683cbd9735f..8f0661ab8be 100644
--- a/addons/crm/crm_phonecall_demo.xml
+++ b/addons/crm/crm_phonecall_demo.xml
@@ -18,6 +18,7 @@
+
@@ -33,6 +34,7 @@
+
@@ -49,6 +51,7 @@
+
diff --git a/addons/crm/crm_phonecall_menu.xml b/addons/crm/crm_phonecall_menu.xml
index 41975d9ced4..55e7657ec05 100644
--- a/addons/crm/crm_phonecall_menu.xml
+++ b/addons/crm/crm_phonecall_menu.xml
@@ -4,7 +4,7 @@
- Inbound
+ Logged Callscrm.phonecallformtree,calendar
-
-
-
+
+ [('state','=','done')]
+
- The Inbound Calls tool allows you to log your inbound calls on the fly. Each call you get will appear on the partner form to trace every contact you have with a partner. From the phone call form, you can trigger a request for another call, a meeting or an opportunity.
+ This tool allows you to log your inbound calls on the fly. Each call you get will appear on the partner form to trace every contact you have with a partner. From the phone call form, you can trigger a request for another call, a meeting or an opportunity.
@@ -90,24 +90,24 @@
form
-
+
-
- Outbound
+ Scheduled Callscrm.phonecallformtree,calendar
-
-
+ [('state','!=','done')]
+
- Outbound Calls list all the calls to be done by your sales team. A salesman can record the information about the call in the form view. This information will be stored in the partner form to trace every contact you have with a customer. You can also import a .CSV file with a list of calls to be done by your sales team.
+ Scheduled calls list all the calls to be done by your sales team. A salesman can record the information about the call in the form view. This information will be stored in the partner form to trace every contact you have with a customer. You can also import a .CSV file with a list of calls to be done by your sales team.
@@ -131,7 +131,7 @@
-
diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml
index 44487e2aef5..2490526bb0e 100644
--- a/addons/crm/crm_phonecall_view.xml
+++ b/addons/crm/crm_phonecall_view.xml
@@ -31,20 +31,20 @@
-
+
-
-
-
+
+
+
@@ -61,21 +61,21 @@
-
+
-
+
-
-
+
+
@@ -98,8 +98,7 @@
+ domain="[('object_id.model', '=', 'crm.phonecall')]"/>
@@ -109,94 +108,32 @@
-
-
-
-
-
- CRM - Inbound Phone Call Form
- crm.phonecall
- form
-
-
-
-
-
-
+
- CRM - Inbound Phone Calls Tree
+ CRM - Logged Phone Calls Treecrm.phonecalltree
-
+
+ domain="[('object_id.model', '=', 'crm.phonecall')]"/>
-
@@ -252,7 +183,7 @@
+ domain="[('state','in', ('open','pending'))]"/>
-
diff --git a/addons/crm/res_partner_view.xml b/addons/crm/res_partner_view.xml
index 9df185ae831..659ef075b7f 100644
--- a/addons/crm/res_partner_view.xml
+++ b/addons/crm/res_partner_view.xml
@@ -54,82 +54,14 @@
-
+
-
+
-
-
diff --git a/addons/crm/wizard/crm_merge_opportunities.py b/addons/crm/wizard/crm_merge_opportunities.py
index 248bff2e0e4..713640034e1 100644
--- a/addons/crm/wizard/crm_merge_opportunities.py
+++ b/addons/crm/wizard/crm_merge_opportunities.py
@@ -67,6 +67,8 @@ class crm_merge_opportunity(osv.osv_memory):
ids = list(set(ids) - set(context.get('lead_ids', False)) )
lead_obj = self.pool.get('crm.lead')
op_id = lead_obj.search(cr, uid, [('id', 'in', ids)], order='create_date' , context=context)
+ if not op_id:
+ return False
opps = lead_obj.browse(cr, uid, [op_id[0]], context=context)
return opps[0]
diff --git a/addons/crm/wizard/crm_opportunity_to_phonecall.py b/addons/crm/wizard/crm_opportunity_to_phonecall.py
index 8fc7ffb310d..af95dd5554b 100644
--- a/addons/crm/wizard/crm_opportunity_to_phonecall.py
+++ b/addons/crm/wizard/crm_opportunity_to_phonecall.py
@@ -22,6 +22,8 @@
from osv import osv, fields
from tools.translate import _
+import time
+
class crm_opportunity2phonecall(osv.osv_memory):
"""Converts Opportunity to Phonecall"""
@@ -31,11 +33,13 @@ class crm_opportunity2phonecall(osv.osv_memory):
_columns = {
'name' : fields.char('Call summary', size=64, required=True, select=1),
'user_id' : fields.many2one('res.users', "Assign To"),
- 'date': fields.datetime('Date' , required=True),
+ 'partner_id' : fields.many2one('res.partner', "Partner"),
+ 'date': fields.datetime('Date'),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
- 'categ_id': fields.many2one('crm.case.categ', 'Category', required=True, \
+ 'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="['|',('section_id','=',False),('section_id','=',section_id),\
- ('object_id.model', '=', 'crm.phonecall')]"),
+ ('object_id.model', '=', 'crm.phonecall')]"),
+ 'action': fields.selection([('schedule','Schedule a call'), ('log','Log a call')], 'Action', required=True),
}
def default_get(self, cr, uid, fields, context=None):
@@ -58,6 +62,7 @@ class crm_opportunity2phonecall(osv.osv_memory):
record_ids = context and context.get('active_ids', []) or []
res = super(crm_opportunity2phonecall, self).default_get(cr, uid, fields, context=context)
+ res.update({'action': 'schedule', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
for opp in opp_obj.browse(cr, uid, record_ids, context=context):
if 'name' in fields:
res.update({'name': opp.name})
@@ -67,6 +72,8 @@ class crm_opportunity2phonecall(osv.osv_memory):
res.update({'section_id': opp.section_id and opp.section_id.id or False})
if 'categ_id' in fields:
res.update({'categ_id': categ_id})
+ if 'partner_id' in fields:
+ res.update({'partner_id': opp.partner_id and opp.partner_id.id or False})
return res
def action_cancel(self, cr, uid, ids, context=None):
@@ -112,7 +119,7 @@ class crm_opportunity2phonecall(osv.osv_memory):
for this in self.browse(cr, uid, ids, context=context):
for opp in opp_obj.browse(cr, uid, record_ids, context=context):
- new_case = phonecall_obj.create(cr, uid, {
+ vals = {
'name' : opp.name,
'case_id' : opp.id ,
'user_id' : this.user_id and this.user_id.id or False,
@@ -126,9 +133,12 @@ class crm_opportunity2phonecall(osv.osv_memory):
'partner_mobile' : opp.partner_address_id and opp.partner_address_id.mobile or False,
'priority': opp.priority,
'opportunity_id': opp.id
- }, context=context)
-
- phonecall_obj.case_open(cr, uid, [new_case])
+ }
+ new_case = phonecall_obj.create(cr, uid, vals, context=context)
+ if this.action == 'schedule':
+ phonecall_obj.case_open(cr, uid, [new_case])
+ elif this.action == 'log':
+ phonecall_obj.case_close(cr, uid, [new_case])
value = {
'name': _('Phone Call'),
diff --git a/addons/crm/wizard/crm_opportunity_to_phonecall_view.xml b/addons/crm/wizard/crm_opportunity_to_phonecall_view.xml
index 9a623d2eaab..764648a877b 100644
--- a/addons/crm/wizard/crm_opportunity_to_phonecall_view.xml
+++ b/addons/crm/wizard/crm_opportunity_to_phonecall_view.xml
@@ -9,19 +9,22 @@
crm.opportunity2phonecallform
-
@@ -30,7 +33,7 @@
- Schedule Call
+ Schedule/Log Callcrm.opportunity2phonecallformform
diff --git a/addons/crm/wizard/crm_phonecall_to_opportunity.py b/addons/crm/wizard/crm_phonecall_to_opportunity.py
index 32810d2f15e..549afa0559b 100644
--- a/addons/crm/wizard/crm_phonecall_to_opportunity.py
+++ b/addons/crm/wizard/crm_phonecall_to_opportunity.py
@@ -31,43 +31,14 @@ class crm_phonecall2opportunity(osv.osv_memory):
def action_cancel(self, cr, uid, ids, context=None):
"""
Closes Phonecall to Opportunity form
- @param self: The object pointer
- @param cr: the current row, from the database cursor,
- @param uid: the current user’s ID for security checks,
- @param ids: List of Phonecall to Opportunity's IDs
- @param context: A standard dictionary for contextual values
"""
return {'type':'ir.actions.act_window_close'}
- def view_init(self, cr, uid, fields, context=None):
- """
- This function checks for precondition before wizard executes
- @param self: The object pointer
- @param cr: the current row, from the database cursor,
- @param uid: the current user’s ID for security checks,
- @param fields: List of fields for default value
- @param context: A standard dictionary for contextual values
-
- """
- phonecall_obj = self.pool.get('crm.phonecall')
- record_id = context and context.get('active_id', False) or False
- case = phonecall_obj.browse(cr, uid, record_id, context=context)
- if case.state in ['done', 'cancel']:
- raise osv.except_osv(_("Warning"), _("Closed/Cancelled Phone \
-Call can not be converted into Opportunity"))
-
def action_apply(self, cr, uid, ids, context=None):
"""
This converts Phonecall to Opportunity and opens Phonecall view
- @param self: The object pointer
- @param cr: the current row, from the database cursor,
- @param uid: the current user’s ID for security checks,
- @param ids: List of Phonecall to Opportunity IDs
- @param context: A standard dictionary for contextual values
-
- @return : Dictionary value for created Opportunity form
"""
record_id = context and context.get('active_id', False) or False
if record_id:
diff --git a/addons/crm/wizard/crm_phonecall_to_phonecall.py b/addons/crm/wizard/crm_phonecall_to_phonecall.py
index aaba8e082c5..2872acad4eb 100644
--- a/addons/crm/wizard/crm_phonecall_to_phonecall.py
+++ b/addons/crm/wizard/crm_phonecall_to_phonecall.py
@@ -22,6 +22,8 @@
from osv import osv, fields
from tools.translate import _
+import time
+
class crm_phonecall2phonecall(osv.osv_memory):
""" Converts Phonecall to Phonecall"""
@@ -84,6 +86,10 @@ class crm_phonecall2phonecall(osv.osv_memory):
'date': this.date
}
phonecall_id = phonecall_obj.create(cr, uid, values, context=context)
+ if this.action == 'schedule':
+ phonecall_obj.case_open(cr, uid, [phonecall_id])
+ elif this.action == 'log':
+ phonecall_obj.case_close(cr, uid, [phonecall_id])
res = {
'name': _('Phone Call'),
@@ -102,11 +108,13 @@ class crm_phonecall2phonecall(osv.osv_memory):
_columns = {
'name' : fields.char('Call summary', size=64, required=True, select=1),
'user_id' : fields.many2one('res.users',"Assign To"),
- 'categ_id': fields.many2one('crm.case.categ', 'Category', required=True, \
+ 'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="['|',('section_id','=',False),('section_id','=',section_id),\
('object_id.model', '=', 'crm.phonecall')]"),
- 'date': fields.datetime('Date', required=True),
+ 'date': fields.datetime('Date'),
'section_id':fields.many2one('crm.case.section','Sales Team'),
+ 'action': fields.selection([('schedule','Schedule a call'), ('log','Log a call')], 'Action', required=True),
+ 'partner_id' : fields.many2one('res.partner', "Partner"),
}
def default_get(self, cr, uid, fields, context=None):
@@ -122,7 +130,7 @@ class crm_phonecall2phonecall(osv.osv_memory):
"""
res = super(crm_phonecall2phonecall, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False
-
+ res.update({'action': 'schedule', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
if record_id:
phonecall = self.pool.get('crm.phonecall').browse(cr, uid, record_id, context=context)
@@ -142,6 +150,8 @@ class crm_phonecall2phonecall(osv.osv_memory):
res.update({'section_id': phonecall.section_id and phonecall.section_id.id or False})
if 'categ_id' in fields:
res.update({'categ_id': categ_id})
+ if 'partner_id' in fields:
+ res.update({'partner_id': phonecall.partner_id and phonecall.partner_id.id or False})
return res
crm_phonecall2phonecall()
diff --git a/addons/crm/wizard/crm_phonecall_to_phonecall_view.xml b/addons/crm/wizard/crm_phonecall_to_phonecall_view.xml
index 82c3191a17b..794634da4f1 100644
--- a/addons/crm/wizard/crm_phonecall_to_phonecall_view.xml
+++ b/addons/crm/wizard/crm_phonecall_to_phonecall_view.xml
@@ -9,18 +9,21 @@
crm.phonecall2phonecallform
-