diff --git a/addons/crm/__terp__.py b/addons/crm/__terp__.py
index 3143972509a..3bcfabd6aa9 100644
--- a/addons/crm/__terp__.py
+++ b/addons/crm/__terp__.py
@@ -68,6 +68,7 @@ between mails and Open ERP.""",
'wizard/phonecall2opportunity.xml',
'wizard/opportunity2partner_view.xml',
'wizard/opportunity2meeting.xml',
+ 'wizard/opportunity2phonecall.xml',
'crm_wizard.xml',
'crm_view.xml',
diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py
index 017ffe5b744..fac5ce98a26 100644
--- a/addons/crm/wizard/__init__.py
+++ b/addons/crm/wizard/__init__.py
@@ -34,6 +34,7 @@ import phonecall2meeting
import phonecall_to_opportunity
import opportunity2partner
import opportunity2meeting
+import opportunity2phonecall
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/wizard/crm_phonecall2phonecall.xml b/addons/crm/wizard/crm_phonecall2phonecall.xml
new file mode 100644
index 00000000000..b4911e48b15
--- /dev/null
+++ b/addons/crm/wizard/crm_phonecall2phonecall.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ crm.phonecall2phonecall.form
+ crm.phonecall2phonecall
+ form
+
+
+
+
+
+ Schedule Other Call
+ crm.phonecall2phonecall
+ form
+ form
+
+ new
+ {'record_id' : active_id}
+
+
+
\ No newline at end of file
diff --git a/addons/crm/wizard/lead_to_partner.py b/addons/crm/wizard/lead_to_partner.py
new file mode 100644
index 00000000000..4d1a3d5468e
--- /dev/null
+++ b/addons/crm/wizard/lead_to_partner.py
@@ -0,0 +1,143 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from mx.DateTime import now
+
+from osv import osv, fields
+import netsvc
+import ir
+import pooler
+from tools.translate import _
+
+class crm_lead2partner(osv.osv_memory):
+ _name = 'crm.lead2partner'
+ _description = 'Lead to Partner'
+
+ _columns = {
+ 'action': fields.selection([('exist','Link to an existing partner'),('create','Create a new partner')],'Action',required=True),
+ 'partner_id': fields.many2one('res.partner','Partner'),
+ }
+ _defaults = {
+ 'action': lambda *a:'exist',
+ }
+
+ def create_partner(self, cr, uid, ids, context):
+ view_obj = self.pool.get('ir.ui.view')
+ view_id = view_obj.search(cr,uid,[('model','=','crm.lead2partner'),('name','=','crm.lead2partner.view')])
+ return {
+ 'view_mode': 'form',
+ 'view_type': 'form',
+ 'view_id': view_id or False,
+ 'res_model': 'crm.lead2partner',
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
+
+ def selectPartner(self, cr, uid, ids, context):
+ case_obj = self.pool.get('crm.lead')
+ partner_obj = self.pool.get('res.partner')
+ contact_obj = self.pool.get('res.partner.address')
+ rec_ids = context and context.get('record_ids',False)
+ value={}
+ for case in case_obj.browse(cr, uid, rec_ids):
+ if case.partner_id:
+ raise osv.except_osv(_('Warning !'),
+ _('A partner is already defined on this lead.'))
+
+ partner_ids = partner_obj.search(cr, uid, [('name', '=', case.partner_name or case.name)])
+ if not partner_ids and case.email_from:
+ address_ids = contact_obj.search(cr, uid, [('email', '=', case.email_from)])
+ if address_ids:
+ addresses = contact_obj.browse(cr, uid, address_ids)
+ partner_ids = addresses and [addresses[0].partner_id.id] or False
+
+ partner_id = partner_ids and partner_ids[0] or False
+ if not partner_id:
+ value = self._make_partner(cr, uid, ids, context)
+ return value
+
+ def _create_partner(self, cr, uid, ids, context):
+ case_obj = self.pool.get('crm.lead')
+ partner_obj = self.pool.get('res.partner')
+ contact_obj = self.pool.get('res.partner.address')
+ datas = self.browse(cr, uid, ids)[0]
+ partner_ids = []
+ partner_id = False
+ contact_id = False
+ rec_ids = context and context.get('record_ids',False)
+ for case in case_obj.browse(cr, uid, rec_ids):
+ if datas.action == 'create':
+ partner_id = partner_obj.create(cr, uid, {
+ 'name': case.partner_name or case.name,
+ 'user_id': case.user_id.id,
+ 'comment': case.description,
+ })
+ contact_id = contact_obj.create(cr, uid, {
+ 'partner_id': partner_id,
+ 'name': case.name,
+ 'phone': case.phone,
+ 'mobile': case.mobile,
+ 'email': case.email_from,
+ 'fax': case.fax,
+ 'title': case.title,
+ 'function': case.function and case.function.id or False,
+ 'street': case.street,
+ 'street2': case.street2,
+ 'zip': case.zip,
+ 'city': case.city,
+ 'country_id': case.country_id and case.country_id.id or False,
+ 'state_id': case.state_id and case.state_id.id or False,
+ })
+
+ else:
+ if datas.partner_id:
+ partner = partner_obj.browse(cr,uid,datas.partner_id.id)
+ partner_id = partner.id
+ contact_id = partner.address and partner.address[0].id
+
+ partner_ids.append(partner_id)
+ vals = {}
+ if partner_id:
+ vals.update({'partner_id': partner_id})
+ if contact_id:
+ vals.update({'partner_address_id': contact_id})
+ case_obj.write(cr, uid, [case.id], vals)
+ return partner_ids
+
+ def _make_partner(self, cr, uid, ids, context):
+ partner_ids = self._create_partner(cr, uid, ids, context)
+ mod_obj = self.pool.get('ir.model.data')
+ result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
+ res = mod_obj.read(cr, uid, result, ['res_id'])
+ value = {
+ 'domain': "[]",
+ 'view_type': 'form',
+ 'view_mode': 'form,tree',
+ 'res_model': 'res.partner',
+ 'res_id': partner_ids and int(partner_ids[0]) or False,
+ 'view_id': False,
+ 'type': 'ir.actions.act_window',
+ 'search_view_id': res['res_id']
+ }
+ return value
+
+crm_lead2partner()
+
diff --git a/addons/crm/wizard/lead_to_partner_view.xml b/addons/crm/wizard/lead_to_partner_view.xml
new file mode 100644
index 00000000000..b11b90bb534
--- /dev/null
+++ b/addons/crm/wizard/lead_to_partner_view.xml
@@ -0,0 +1,67 @@
+
+
+
+ crm.lead2partner.view.create
+ crm.lead2partner
+ form
+
+
+
+
+
+ Create a Partner
+ ir.actions.act_window
+ crm.lead2partner
+
+ form
+ form
+ new
+ {'record_ids' : active_ids}
+
+
+
+
+
+ Create Partner
+ client_action_multi
+
+ action
+ crm.lead
+
+
+
+ crm.lead2partner.view
+ crm.lead2partner
+ form
+
+
+
+
+
+ Create a Partner
+ ir.actions.act_window
+ crm.lead2partner
+
+ form
+ form
+ new
+ {'record_ids' : active_ids}
+
+
+
diff --git a/addons/crm/wizard/opportunity2meeting.py b/addons/crm/wizard/opportunity2meeting.py
index 52aee7bd331..9c0628429df 100644
--- a/addons/crm/wizard/opportunity2meeting.py
+++ b/addons/crm/wizard/opportunity2meeting.py
@@ -38,7 +38,7 @@ class crm_opportunity2meeting(osv.osv_memory):
def action_cancel(self, cr, uid, ids, context=None):
return {'type':'ir.actions.act_window_close'}
- def _makeMeeting(self, cr, uid, ids, context=None):
+ def action_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:
diff --git a/addons/crm/wizard/opportunity2meeting.xml b/addons/crm/wizard/opportunity2meeting.xml
index 39a36df4896..a8851c53d2c 100644
--- a/addons/crm/wizard/opportunity2meeting.xml
+++ b/addons/crm/wizard/opportunity2meeting.xml
@@ -8,7 +8,7 @@
diff --git a/addons/crm/wizard/opportunity2phonecall.py b/addons/crm/wizard/opportunity2phonecall.py
new file mode 100644
index 00000000000..6bebf5da6be
--- /dev/null
+++ b/addons/crm/wizard/opportunity2phonecall.py
@@ -0,0 +1,105 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from mx.DateTime import now
+
+from osv import osv, fields
+import netsvc
+import ir
+import pooler
+from tools.translate import _
+
+class crm_opportunity2phonecall(osv.osv_memory):
+ _name = 'crm.opportunity2phonecall'
+ _description = 'Opportunity to Phonecall'
+ _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),
+ 'section_id':fields.many2one('crm.case.section','Sales Team'),
+
+ }
+ def default_get(self, cr, uid, fields, context=None):
+ record_id = context and context.get('record_id', False) or False
+ res = super(crm_opportunity2phonecall, self).default_get(cr, uid, fields, context=context)
+ if record_id:
+ opportunity = self.pool.get('crm.opportunity').browse(cr, uid, record_id, context=context)
+ res['name']=opportunity.name
+ res['user_id']=opportunity.user_id and opportunity.user_id.id or False
+ res['section_id']=opportunity.section_id and opportunity.section_id.id or False
+ return res
+
+ def action_cancel(self, cr, uid, ids, context=None):
+ return {'type':'ir.actions.act_window_close'}
+
+ def action_apply(self, cr, uid, ids, context=None):
+ this = self.browse(cr, uid, ids[0], context=context)
+ mod_obj =self.pool.get('ir.model.data')
+ result = mod_obj._get_id(cr, uid, 'crm', 'view_crm_case_phonecalls_filter')
+ res = mod_obj.read(cr, uid, result, ['res_id'])
+ phonecall_case_obj = self.pool.get('crm.phonecall')
+ opportunity_case_obj = self.pool.get('crm.opportunity')
+ # Select the view
+ record_id = context and context.get('record_id', False) or False
+ data_obj = self.pool.get('ir.model.data')
+ id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_tree_view')
+ id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_form_view')
+ 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
+
+ opportunites = opportunity_case_obj.browse(cr, uid, [record_id])
+ for opportunity in opportunites:
+ new_case = phonecall_case_obj.create(cr, uid, {
+ 'name' : opportunity.name,
+ 'case_id' : opportunity.id,
+ 'user_id' : this.user_id,
+ 'categ_id' : opportunity.categ_id,
+ 'description' : opportunity.description,
+ 'date' : this.date,
+ 'section_id' : opportunity.section_id and opportunity.section_id.id or False,
+ 'partner_id': opportunity.partner_id and opportunity.partner_id.id or False,
+ 'partner_address_id':opportunity.partner_address_id and opportunity.partner_address_id.id or False,
+ 'description': opportunity.description or '',
+ 'partner_phone' : opportunity.phone or (opportunity.partner_address_id and opportunity.partner_address_id.phone or False),
+ 'partner_mobile' : opportunity.partner_address_id and opportunity.partner_address_id.mobile or False,
+ 'priority': opportunity.priority,
+ 'opportunity_id':opportunity.id
+ }, context=context)
+ vals = {}
+
+ phonecall_case_obj.case_open(cr, uid, [new_case])
+
+ value = {
+ 'name': _('Phone Call'),
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'crm.phonecall',
+ 'res_id' : new_case,
+ 'views': [(id3,'form'),(id2,'tree'),(False,'calendar'),(False,'graph')],
+ 'type': 'ir.actions.act_window',
+ 'search_view_id': res['res_id']
+ }
+ return value
+
+
+crm_opportunity2phonecall()
\ No newline at end of file
diff --git a/addons/crm/wizard/opportunity2phonecall.xml b/addons/crm/wizard/opportunity2phonecall.xml
new file mode 100644
index 00000000000..9f24e5e37be
--- /dev/null
+++ b/addons/crm/wizard/opportunity2phonecall.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ crm.opportunity2phonecall.form
+ crm.opportunity2phonecall
+ form
+
+
+
+
+
+ Schedule Other Call
+ crm.opportunity2phonecall
+ form
+ form
+
+ new
+ {'record_id' : active_id}
+
+
+
\ No newline at end of file