[MERGE] [IMP] crm: improved call / meeting buttons and behavior on lead and partner...
authorAmit Vora <avo@tinyerp.com>
Thu, 17 Apr 2014 14:56:45 +0000 (16:56 +0200)
committerThibault Delavallée <tde@openerp.com>
Thu, 17 Apr 2014 14:56:45 +0000 (16:56 +0200)
- improved behavior of schedule a meeting, for both opportunities and partner, with correct
attendees and options;
- removed wizard to schedule a cal, jumping to the list view with correct default values
is sufficient;
- scheduled calls is now accessible using a group, accessible through sales configuration;

bzr revid: tde@openerp.com-20140417145645-cpohfrfpqnskpok6

1  2 
addons/crm/crm_lead.py
addons/crm/crm_lead_view.xml
addons/crm/res_config.py
addons/crm/res_partner.py
addons/crm/test/lead2opportunity2win.yml

@@@ -898,21 -899,21 +898,22 @@@ class crm_lead(format_address, osv.osv)
              'type': 'ir.actions.act_window',
          }
  
--    def action_makeMeeting(self, cr, uid, ids, context=None):
++    def action_schedule_meeting(self, cr, uid, ids, context=None):
          """
          Open meeting's calendar view to schedule meeting on current opportunity.
          :return dict: dictionary value for created Meeting view
          """
--        opportunity = self.browse(cr, uid, ids[0], context)
++        lead = self.browse(cr, uid, ids[0], context)
          res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid, 'calendar', 'action_calendar_event', context)
++        partner_ids = [self.pool['res.users'].browse(cr, uid, uid, context=context).partner_id.id]
++        if lead.partner_id:
++            partner_ids.append(lead.partner_id.id)
          res['context'] = {
--            'default_opportunity_id': opportunity.id,
--            'default_partner_id': opportunity.partner_id and opportunity.partner_id.id or False,
--            'default_partner_ids' : opportunity.partner_id and [opportunity.partner_id.id] or False,
--            'default_user_id': uid,
--            'default_section_id': opportunity.section_id and opportunity.section_id.id or False,
--            'default_email_from': opportunity.email_from,
--            'default_name': opportunity.name,
++            'default_opportunity_id': lead.type == 'opportunity' and lead.id or False,
++            'default_partner_id': lead.partner_id and lead.partner_id.id or False,
++            'default_partner_ids': partner_ids,
++            'default_section_id': lead.section_id and lead.section_id.id or False,
++            'default_name': lead.name,
          }
          return res
  
                                          <t t-if="widget.view.is_action_enabled('edit')"><li><a type="edit">Edit...</a></li></t>
                                          <t t-if="widget.view.is_action_enabled('delete')"><li><a type="delete">Delete</a></li></t>
                                          <li><a name="%(mail.action_email_compose_message_wizard)d" type="action">Send Email</a></li>
-                                         <li><a name="%(opportunity2phonecall_act)d" type="action">Schedule/Log Call</a></li>
-                                         <li><a name="action_makeMeeting" type="object">Schedule Meeting</a></li>
+                                         <li><a type="action" name="%(crm.crm_case_categ_phone_incoming0)d" >Calls</a></li>
 -                                        <li><a name="action_makeMeeting" type="object">Schedule Meeting</a></li>
++                                        <li><a name="action_schedule_meeting" type="object">Schedule Meeting</a></li>
                                          <li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
                                      </ul>
                                  </div>
                      </header>
                      <sheet>
                          <div class="oe_right oe_button_box">
-                             <button string="Schedule/Log Call" type="action"
-                                 name="%(opportunity2phonecall_act)d"/>
-                             <button string="Meeting" type="object"
-                                 name="action_makeMeeting"
-                                 context="{'search_default_attendee_id': active_id, 'default_attendee_id' : active_id}"/>
+                             <button class="oe_inline" type="action" string="Calls" 
+                                 name="%(crm.crm_case_categ_phone_incoming0)d" 
+                                 context="{'default_opportunity_id': active_id, 'search_default_opportunity_id': active_id, 'default_partner_id': partner_id, 'default_duration': 1.0}"/>
+                             <button class="oe_inline" string="Schedule a Meeting" type="object"
 -                                name="schedule_meeting" context="{'partner_id': partner_id}"/>
++                                name="action_schedule_meeting" context="{'partner_id': partner_id}"/>
                          </div>
                          <div class="oe_title">
                              <label for="name" class="oe_edit_only"/>
@@@ -69,6 -69,9 +69,9 @@@ class crm_configuration(osv.TransientMo
              help="""Allows you to use Sales Teams to manage your leads and opportunities."""),
          'alias_prefix': fields.char('Default Alias Name for Leads'),
          'alias_domain' : fields.char('Alias Domain'),
+         'group_scheduled_calls': fields.boolean("Schedule calls to manage call center",
+             implied_group='crm.group_scheduled_calls',
 -            help="""This adds menu 'Scheduled Calls' under 'Sales / Phone Calls'""")
++            help="""This adds the menu 'Scheduled Calls' under 'Sales / Phone Calls'""")
      }
  
      _defaults = {
@@@ -92,5 -106,5 +92,17 @@@ class res_partner(osv.osv)
              opportunity_ids[partner_id] = opportunity_id
          return opportunity_ids
  
++    def schedule_meeting(self, cr, uid, ids, context=None):
++        if context is None:
++            context = {}
++        partner_ids = list(ids)
++        partner_ids.append(self.pool.get('res.users').browse(cr, uid, uid).partner_id.id)
++        res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid, 'calendar', 'action_calendar_event', context)
++        res['context'] = {
++            'default_partner_id': ids and ids[0] or False,
++            'default_partner_ids': partner_ids,
++        }
++        return res
++
  
  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
    Now I schedule meeting with customer.
  -
    !python {model: crm.lead}: |
--    self.action_makeMeeting(cr, uid, [ref('crm_case_3')])
++    self.action_schedule_meeting(cr, uid, [ref('crm_case_3')])
  -
    After communicated  with customer, I put some notes with contract details.
  -