diff --git a/asterisk_click2dial/wizard/open_calling_partner.py b/asterisk_click2dial/wizard/open_calling_partner.py
index b08d97d..89d304f 100644
--- a/asterisk_click2dial/wizard/open_calling_partner.py
+++ b/asterisk_click2dial/wizard/open_calling_partner.py
@@ -206,4 +206,13 @@ class wizard_open_calling_partner(osv.osv_memory):
res['value'].update({'current_phone': False, 'current_mobile': False})
return res
+ def create_incoming_phonecall(self, cr, uid, ids, crm_categ, context=None):
+ '''Started by button on 'open calling partner wizard'''
+ # HACK for OpenERP v5 : code moved from asterisk_click2dial_crm to
+ # asterisk_click2dial because we can't inherit a wizard
+ partner_address = self.browse(cr, uid, ids[0], context=context).partner_address_id
+ action = self.pool.get('wizard.create.crm.phonecall')._create_open_crm_phonecall(cr, uid, partner_address, crm_categ='Inbound', context=context)
+ return action
+
+
wizard_open_calling_partner()
diff --git a/asterisk_click2dial/wizard/open_calling_partner_view.xml b/asterisk_click2dial/wizard/open_calling_partner_view.xml
index e527750..e990467 100644
--- a/asterisk_click2dial/wizard/open_calling_partner_view.xml
+++ b/asterisk_click2dial/wizard/open_calling_partner_view.xml
@@ -25,7 +25,7 @@
-
+
diff --git a/asterisk_click2dial_crm/__terp__.py b/asterisk_click2dial_crm/__terp__.py
index 7a86d5f..7d68fb4 100644
--- a/asterisk_click2dial_crm/__terp__.py
+++ b/asterisk_click2dial_crm/__terp__.py
@@ -51,7 +51,7 @@
""",
"depends": [
'asterisk_click2dial',
- 'crm',
+ 'crm_configuration',
],
"init_xml": [],
"demo_xml": [],
@@ -59,6 +59,7 @@
'wizard/open_calling_partner_view.xml',
'wizard/create_crm_phonecall_view.xml',
'res_users_view.xml',
+ 'res_partner_view.xml',
],
"installable": True,
}
diff --git a/asterisk_click2dial_crm/asterisk_click2dial_crm.py b/asterisk_click2dial_crm/asterisk_click2dial_crm.py
index 02b785b..68ad6f5 100644
--- a/asterisk_click2dial_crm/asterisk_click2dial_crm.py
+++ b/asterisk_click2dial_crm/asterisk_click2dial_crm.py
@@ -26,37 +26,6 @@ from osv import osv, fields
# Lib to translate error messages
from tools.translate import _
-class res_partner_address(osv.osv):
- _inherit = "res.partner.address"
-
- def dial(self, cr, uid, ids, phone_field='phone', context=None):
- '''
- This method open the phone call history when the phone click2dial
- button of asterisk_click2dial module is pressed
- :return the phone call history view of the partner
- '''
- if context is None:
- context = {}
- super(res_partner_address, self).dial(cr, uid, ids, phone_field=phone_field, context=context)
- user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
- context['partner_address_id'] = ids[0]
- action_start_wizard = {
- 'name': 'Create phone call in CRM',
- 'type': 'ir.actions.act_window',
- 'res_model': 'wizard.create.crm.phonecall',
- 'view_type': 'form',
- 'view_mode': 'form',
- 'nodestroy': True,
- 'target': 'new',
- 'context': context,
- }
- if user.context_propose_creation_crm_call:
- return action_start_wizard
- else:
- return True
-
-res_partner_address()
-
class res_users(osv.osv):
_inherit = "res.users"
diff --git a/asterisk_click2dial_crm/res_partner_view.xml b/asterisk_click2dial_crm/res_partner_view.xml
new file mode 100644
index 0000000..9811226
--- /dev/null
+++ b/asterisk_click2dial_crm/res_partner_view.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+ dial_button_replace.res_partner_address1
+ res.partner.address
+
+
+
+
+
+
+
+
+
+
+
+
+ dial_button_replace.res_partner_address2
+ res.partner.address
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ dial_button_replace.res_partner
+ res.partner
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/asterisk_click2dial_crm/wizard/create_crm_phonecall.py b/asterisk_click2dial_crm/wizard/create_crm_phonecall.py
index f919c5c..0b145f8 100644
--- a/asterisk_click2dial_crm/wizard/create_crm_phonecall.py
+++ b/asterisk_click2dial_crm/wizard/create_crm_phonecall.py
@@ -30,33 +30,75 @@ from tools.translate import _
class wizard_create_crm_phonecall(osv.osv_memory):
_name = "wizard.create.crm.phonecall"
+ _columns = {
+ # Stupid useless field, just to be able to use default_get()
+ 'name': fields.char('Workaround', size=12),
+ }
+
+ def default_get(self, cr, uid, fields, context=None):
+ res = {}
+ self.pool.get('res.partner.address').dial(cr, uid, context.get('active_ids'), phone_field=context.get('phone_field'), context=context)
+ return res
+
def button_create_outgoing_phonecall(self, cr, uid, ids, context=None):
- partner_address = self.pool.get('res.partner.address').browse(cr, uid, context.get('partner_address_id'), context=context)
+ partner_address = self.pool.get('res.partner.address').browse(cr, uid, context.get('active_id'), context=context)
return self._create_open_crm_phonecall(cr, uid, partner_address, crm_categ='Outbound', context=context)
- def _create_open_crm_phonecall(self, cr, uid, partner_address, crm_categ, context=None):
+ def _create_open_crm_phonecall(self, cr, uid, partner_address, crm_categ='Outbound', context=None):
if context is None:
context = {}
- crm_phonecall_obj = self.pool.get('crm.phonecall')
- categ_ids = self.pool.get('crm.case.categ').search(cr, uid, [('name','=',crm_categ)], context={'lang': 'en_US'})
- case_section_ids = self.pool.get('crm.case.section').search(cr, uid, [('member_ids', 'in', uid)], context=context)
+ data_obj = self.pool.get('ir.model.data')
+ data_section_ids = data_obj.search(cr, uid, [
+ ('model', '=', 'crm.case.section'),
+ ('module', '=', 'crm_configuration'),
+ ('name', '=', 'section_support_phone')
+ ], context=context)
+ default_section_id = False
+ if data_section_ids:
+ default_section_id = data_obj.read(cr, uid, data_section_ids[0], ['res_id'], context=context)['res_id']
+
+ if crm_categ == 'Outbound':
+ crm_categ_xmlid = 'categ_phone2'
+ elif crm_categ == 'Inbound':
+ crm_categ_xmlid = 'categ_phone1'
+ else:
+ raise
+ data_categ_ids = data_obj.search(cr, uid, [
+ ('model', '=', 'crm.case.categ'),
+ ('module', '=', 'crm_configuration'),
+ ('name', '=', crm_categ_xmlid)
+ ], context=context)
+ default_categ_id = False
+ if data_categ_ids:
+ default_categ_id = data_obj.read(cr, uid, data_categ_ids[0], ['res_id'], context=context)['res_id']
+
+
context.update({
'default_partner_id': partner_address.partner_id and partner_address.partner_id.id or False,
'default_partner_address_id': partner_address.id,
- 'default_partner_contact': partner_address.name,
- 'default_partner_phone': partner_address.phone,
'default_partner_mobile': partner_address.mobile,
- 'default_categ_id': categ_ids and categ_ids[0] or False,
- 'default_section_id': case_section_ids and case_section_ids[0] or False,
+ 'default_partner_phone': partner_address.phone,
+ 'default_section_id': default_section_id,
+ 'default_categ_id': default_categ_id,
+ 'default_user_id': uid,
})
+ data_view_ids = data_obj.search(cr, uid, [
+ ('model', '=', 'ir.ui.view'),
+ ('name', '=', 'crm_case_phone_form_view'),
+ ('module', '=', 'crm_configuration')
+ ], context=context)
+ view_id = False
+ if data_view_ids:
+ view_id = data_obj.read(cr, uid, data_view_ids[0], ['res_id'], context=context)['res_id']
+
return {
'name': partner_address.name,
- 'domain': [('partner_id', '=', partner_address.partner_id.id)],
- 'res_model': 'crm.phonecall',
+ 'res_model': 'crm.case',
'view_type': 'form',
'view_mode': 'form,tree',
+ 'view_id': [view_id],
'type': 'ir.actions.act_window',
'nodestroy': False, # close the pop-up wizard after action
'target': 'current',
@@ -66,13 +108,14 @@ class wizard_create_crm_phonecall(osv.osv_memory):
wizard_create_crm_phonecall()
-class wizard_open_calling_partner(osv.osv_memory):
- _inherit = "wizard.open.calling.partner"
+# CODE MOVED to asterisk_click2dial, because we can't inherit a wizard in OpenERP v5
+#class wizard_open_calling_partner(osv.osv_memory):
+# _inherit = "wizard.open.calling.partner"
- def create_incoming_phonecall(self, cr, uid, ids, crm_categ, context=None):
- '''Started by button on 'open calling partner wizard'''
- partner_address = self.browse(cr, uid, ids[0], context=context).partner_address_id
- action = self.pool.get('wizard.create.crm.phonecall')._create_open_crm_phonecall(cr, uid, partner_address, crm_categ='Inbound', context=context)
- return action
+# def create_incoming_phonecall(self, cr, uid, ids, crm_categ, context=None):
+# '''Started by button on 'open calling partner wizard'''
+# partner_address = self.browse(cr, uid, ids[0], context=context).partner_address_id
+# action = self.pool.get('wizard.create.crm.phonecall')._create_open_crm_phonecall(cr, uid, partner_address, context=context)
+# return action
-wizard_open_calling_partner()
+#wizard_open_calling_partner()
diff --git a/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml b/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml
index 7467d79..0431c5f 100644
--- a/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml
+++ b/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml
@@ -15,6 +15,7 @@
form