[MERGE] Merged with lp:addons
authorron@tinyerp.com <>
Mon, 21 Nov 2011 05:49:03 +0000 (11:19 +0530)
committerron@tinyerp.com <>
Mon, 21 Nov 2011 05:49:03 +0000 (11:19 +0530)
bzr revid: ron@tinyerp.com-20111121054903-kikfpfc4kg2n1b6w

1  2 
addons/crm/__openerp__.py
addons/crm/crm.py
addons/crm/crm_lead.py
addons/crm/crm_lead_demo.xml
addons/crm/crm_lead_view.xml
addons/crm/crm_phonecall.py
addons/crm/wizard/crm_opportunity_to_phonecall.py
addons/crm/wizard/crm_opportunity_to_phonecall_view.xml

Simple merge
Simple merge
Simple merge
@@@ -9,13 -9,13 +9,13 @@@
              <field name="user_id" ref="base.user_root"/>
              <field eval="'The Oil Company'" name="partner_name"/>
              <field eval="'draft'" name="state"/>
 -            <field name="section_id" ref="crm.section_sales_department"/>
 -        <field eval="'Luc Latour'" name="contact_name"/>
 +            <field name="section_id" ref="crm.section_sales_marketing_department"/>
-           <field eval="'Luc Latour'" name="contact_name"/>
++            <field eval="'Luc Latour'" name="contact_name"/>
              <field name="title" ref="base.res_partner_title_sir"/>
-           <field eval="'Training Manager'" name="function"/>
-           <field eval="'Paris'" name="city"/>
-           <field name="country_id" ref="base.fr"/>
-           <field eval="'luc.latour@oilcompany.fr'" name="email_from"/>
+         <field eval="'Training Manager'" name="function"/>
+         <field eval="'Paris'" name="city"/>
+         <field name="country_id" ref="base.fr"/>
+         <field eval="'luc.latour@oilcompany.fr'" name="email_from"/>
              <field eval="'0033 621 782-0636'" name="mobile"/>
              <field eval="1" name="active"/>
              <field name="stage_id" ref="crm.stage_lead1"/>
              <field name="type">lead</field>
              <field name="user_id" ref="base.user_root"/>
              <field eval="'Stonage IT'" name="partner_name"/>
-           <field eval="'Carrie Helle'" name="contact_name"/>
-           <field eval="'Purchase Manager'" name="function"/>
-           <field eval="'Bruxelles'" name="city"/>
-           <field name="country_id" ref="base.be"/>
+         <field eval="'Carrie Helle'" name="contact_name"/>
+         <field eval="'Purchase Manager'" name="function"/>
+         <field eval="'Bruxelles'" name="city"/>
+         <field name="country_id" ref="base.be"/>
              <field eval="'draft'" name="state"/>
 -            <field name="section_id" ref="crm.section_sales_department"/>
 +            <field name="section_id" ref="crm.section_sales_marketing_department"/>
              <field eval="'(333) 715-1450'" name="mobile"/>
              <field eval="1" name="active"/>
              <field name="categ_id" ref="crm.categ_oppor1"/>
Simple merge
Simple merge
@@@ -54,22 -79,92 +54,28 @@@ class crm_opportunity2phonecall(osv.osv
                  res.update({'categ_id': categ_id})
              if 'partner_id' in fields:
                  res.update({'partner_id': opp.partner_id and opp.partner_id.id or False})
+             if 'note' in fields:
+                 res.update({'note': opp.description})
+             if 'contact_name' in fields:
+                 res.update({'contact_name': opp.partner_address_id and opp.partner_address_id.name or False})
+             if 'phone' in fields:
+                 res.update({'phone': opp.phone or (opp.partner_address_id and opp.partner_address_id.phone or False)})
          return res
  
 -    def action_cancel(self, cr, uid, ids, context=None):
 -        """
 -        Closes Opportunity to Phonecall form
 -        @param self: The object pointer
 -        @param cr: the current row, from the database cursor,
 -        @param uid: the current user’s ID for security checks,
 -        @param ids: List of Opportunity to Phonecall's IDs
 -        @param context: A standard dictionary for contextual values
 -        """
 -        return {'type': 'ir.actions.act_window_close'}
 -
 -    def action_apply(self, cr, uid, ids, context=None):
 -        """
 -        This converts Opportunity to Phonecall and opens Phonecall view
 -        @param self: The object pointer
 -        @param cr: the current row, from the database cursor,
 -        @param uid: the current user's ID for security checks,
 -        @param ids: List of Opportunity to Phonecall IDs
 -        @param context: A standard dictionary for contextual values
 -
 -        @return : Dictionary value for created Opportunity form
 -        """
 +    def action_schedule(self, cr, uid, ids, context=None):
          value = {}
 -        record_ids = context and context.get('active_ids', []) or []
 -
 -        phonecall_obj = self.pool.get('crm.phonecall')
 -        opp_obj = self.pool.get('crm.lead')
 -        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'])
 -
 -        data_obj = self.pool.get('ir.model.data')
 -
 -        # Select the view
 -        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
 -
 -        for this in self.browse(cr, uid, ids, context=context):
 -            for opp in opp_obj.browse(cr, uid, record_ids, context=context):
 -                vals = {
 -                        'name' : opp.name,
 -                        'case_id' : opp.id,
 -                        'user_id' : this.user_id and this.user_id.id or False,
 -                        'categ_id' : this.categ_id.id,
 -                        'description' : opp.description or False,
 -                        'date' : this.date,
 -                        'section_id' : this.section_id.id or False,
 -                        'partner_id': opp.partner_id and opp.partner_id.id or False,
 -                        'partner_address_id': opp.partner_address_id and opp.partner_address_id.id or False,
 -                        'partner_phone' : opp.phone or (opp.partner_address_id and opp.partner_address_id.phone or False),
 -                        'partner_mobile' : opp.partner_address_id and opp.partner_address_id.mobile or False,
 -                        'priority': opp.priority,
 -                        'opportunity_id': opp.id,
 -                        'date_open': time.strftime('%Y-%m-%d %H:%M:%S')
 -                }
 -                
 -                new_case = phonecall_obj.create(cr, uid, vals, context=context)
 -               
 -                if this.action == 'log':
 -                    phonecall_obj.case_close(cr, uid, [new_case])
 -                    return {'type': 'ir.actions.act_window_close'}
 -
 -            value = {
 -                'name': _('Phone Call'),
 -                'domain': "[('user_id','=',%s),('opportunity_id','=',%s)]" % (uid,opp.id),
 -                'view_type': 'form',
 -                'view_mode': 'tree,form',
 -                'res_model': 'crm.phonecall',
 -                'res_id' : new_case,
 -                'views': [(id3, 'form'), (id2, 'tree'), (False, 'calendar')],
 -                'type': 'ir.actions.act_window',
 -                'search_view_id': res['res_id'],
 -            }
 -        return value
 +        if context is None:
 +            context = {}
 +        phonecall = self.pool.get('crm.phonecall')
 +        opportunity_ids = context and context.get('active_ids') or []
 +        opportunity = self.pool.get('crm.lead')
 +        data = self.browse(cr, uid, ids, context=context)[0]
 +        call_ids = opportunity.schedule_phonecall(cr, uid, opportunity_ids, data.date, data.name, \
 +                data.user_id and data.user_id.id or False, \
 +                data.section_id and data.section_id.id or False, \
 +                data.categ_id and data.categ_id.id or False, \
 +                action=data.action, context=context)
 +        return phonecall.redirect_phonecall_view(cr, uid, call_ids[opportunity_ids[0]], context=context)
  
  crm_opportunity2phonecall()