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/7/head
Alexis de Lattre 12 years ago
parent
commit
db5a428277
  1. 8
      asterisk_click2dial/wizard/open_calling_partner.py
  2. 23
      asterisk_click2dial_crm/wizard/create_crm_phonecall.py

8
asterisk_click2dial/wizard/open_calling_partner.py

@ -147,10 +147,8 @@ 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_id = self.pool.get('res.partner').create(cr, uid, {
'name': 'WRITE PARTNER NAME HERE',
phone_type: number_to_write,
}, context=context)
context['default_' + phone_type] = number_to_write
action = {
'name': 'Create new partner',
'view_type': 'form',
@ -159,7 +157,7 @@ class wizard_open_calling_partner(osv.osv_memory):
'type': 'ir.actions.act_window',
'nodestroy': False,
'target': 'current',
'res_id': new_partner_id,
'context': context,
}
return action

23
asterisk_click2dial_crm/wizard/create_crm_phonecall.py

@ -41,27 +41,18 @@ 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.name,
'partner_id': partner.id or False,
'partner_phone': partner.phone,
'partner_mobile': partner.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.id or False,
'default_partner_phone': partner.phone,
'default_partner_mobile': partner.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.name,
'domain': [('partner_id', '=', partner.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