Browse Source

In the wizards, Instead of creating a new record and opening it, I open a new form with the values. It's better when using the Web interface, because it avoids a click on "Edit".

pull/26/head
Alexis de Lattre 12 years ago
parent
commit
6465a0f345
  1. 4
      asterisk_click2dial/wizard/open_calling_partner.py
  2. 27
      asterisk_click2dial_crm/wizard/create_crm_phonecall.py

4
asterisk_click2dial/wizard/open_calling_partner.py

@ -152,7 +152,7 @@ class wizard_open_calling_partner(osv.osv_memory):
# Convert the number to the international format
number_to_write = self.pool.get('asterisk.server')._convert_number_to_international_format(cr, uid, calling_number, ast_server, context=context)
new_partner_address_id = self.pool.get('res.partner.address').create(cr, uid, {phone_type: number_to_write}, context=context)
context['default_' + phone_type] = number_to_write
action = {
'name': 'Create new contact',
'view_type': 'form',
@ -161,7 +161,7 @@ class wizard_open_calling_partner(osv.osv_memory):
'type': 'ir.actions.act_window',
'nodestroy': False,
'target': 'current',
'res_id': new_partner_address_id,
'context': context,
}
return action

27
asterisk_click2dial_crm/wizard/create_crm_phonecall.py

@ -41,29 +41,20 @@ class wizard_create_crm_phonecall(osv.osv_memory):
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)
values = {
'name': _('Call with') + ' ' + partner_address.name,
'partner_id': partner_address.partner_id and partner_address.partner_id.id or False,
'partner_address_id': partner_address.id,
'partner_phone': partner_address.phone,
'partner_contact': partner_address.name,
'partner_mobile': partner_address.mobile,
'user_id': uid,
'categ_id': categ_ids and categ_ids[0] or False,
'section_id': case_section_ids and case_section_ids[0] or False,
# As we now ask the user if he wants to create a phone call in CRM,
# we suppose that he will decide to create one only if the call
# has succeeded, so we create it directly in 'Held' (done) state.
# Otherwise, it would have been created in 'Todo' (open) state.
'state': 'done',
}
crm_phonecall_id = crm_phonecall_obj.create(cr, uid, values, context=context)
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,
})
return {
'name': partner_address.name,
'domain': [('partner_id', '=', partner_address.partner_id.id)],
'res_model': 'crm.phonecall',
'res_id': crm_phonecall_id,
'view_type': 'form',
'view_mode': 'form,tree',
'type': 'ir.actions.act_window',

Loading…
Cancel
Save