Anto has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-addons5-merge-opportunity-aja into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons5-merge-opportunity-aja/+merge/126898

Hello, 
 Improve Merge existing opportunity (lead to existing opportunity)and 
notification message.  
Thank You
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons5-merge-opportunity-aja/+merge/126898
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-addons5-merge-opportunity-aja.
=== modified file 'crm/__openerp__.py'
--- crm/__openerp__.py	2012-09-26 12:16:27 +0000
+++ crm/__openerp__.py	2012-09-28 09:47:36 +0000
@@ -36,7 +36,7 @@
 
 OpenERP ensures that all cases are successfully tracked by users, customers and suppliers. It can automatically send reminders, escalate the request, trigger specific methods and many other actions based on your own enterprise rules.
 
-The greatest thing about this system is that users don't need to do anything special. The CRM module has an email gateway for the synchronization interface between mails and OpenERP. That way, users can just send emails to the request tracker. 
+The greatest thing about this system is that users don't need to do anything special. The CRM module has an email gateway for the synchronization interface between mails and OpenERP. That way, users can just send emails to the request tracker.
 
 OpenERP will take care of thanking them for their message, automatically routing it to the appropriate staff and make sure all future correspondence gets to the right place.
 
@@ -99,7 +99,7 @@
 
         'res_partner_view.xml',
         'board_crm_view.xml',
-        
+
         'res_config_view.xml',
 
     ],
@@ -115,9 +115,10 @@
         'test/process/cancel_lead.yml',
         'test/process/action_rule.yml',
         'test/process/segmentation.yml',
+        'test/process/phonecalls.yml',
         'test/ui/crm_demo.yml',
         'test/ui/duplicate_lead.yml',
-        'test/ui/delete_lead.yml'
+        'test/ui/delete_lead.yml',
     ],
     'installable': True,
     'application': True,

=== modified file 'crm/crm_demo.xml'
--- crm/crm_demo.xml	2012-08-14 08:20:29 +0000
+++ crm/crm_demo.xml	2012-09-28 09:47:36 +0000
@@ -1,46 +1,47 @@
 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
-    <data>
+    <data noupdate="1">
+
         <record id="base.user_demo" model="res.users">
-            <field name="groups_id" eval="[(4,ref('base.group_sale_salesman'))]"/> 
-        </record>
-
-    <record id="ir_ui_view_sc_calendar_demo" model="ir.ui.view_sc">
-        <field name="name">Meetings</field>
-        <field name="resource">ir.ui.menu</field>
-        <field name="user_id" ref="base.user_demo"/>
-        <field name="res_id" ref="base_calendar.menu_crm_meeting"/>
-    </record>
-
-    <record model="crm.case.section" id="crm_case_section_1">
+            <field name="groups_id" eval="[(4,ref('base.group_sale_salesman'))]"/>
+        </record>
+
+        <record id="ir_ui_view_sc_calendar_demo" model="ir.ui.view_sc">
+            <field name="name">Meetings</field>
+            <field name="resource">ir.ui.menu</field>
+            <field name="user_id" ref="base.user_demo"/>
+            <field name="res_id" ref="base_calendar.menu_crm_meeting"/>
+        </record>
+
+        <record model="crm.case.section" id="crm_case_section_1">
             <field name="name">Sales Marketing Department</field>
             <field name="code">SMD</field>
-            <field name="parent_id" ref="crm.section_sales_department"></field>
-    </record>
+            <field name="parent_id" ref="crm.section_sales_department"/>
+        </record>
 
-    <record model="crm.case.section" id="crm_case_section_2">
+        <record model="crm.case.section" id="crm_case_section_2">
             <field name="name">Support Department</field>
             <field name="code">SPD</field>
-            <field name="parent_id" ref="crm.section_sales_department"></field>
-    </record>
+            <field name="parent_id" ref="crm.section_sales_department"/>
+        </record>
 
-    <record model="crm.case.section" id="crm_case_section_3">
+        <record model="crm.case.section" id="crm_case_section_3">
             <field name="name">Direct Marketing</field>
             <field name="code">DM</field>
-            <field name="parent_id" ref="crm.section_sales_department"></field>
-    </record>
+            <field name="parent_id" ref="crm.section_sales_department"/>
+        </record>
 
-    <record model="crm.case.section" id="crm_case_section_4">
+        <record model="crm.case.section" id="crm_case_section_4">
             <field name="name">Online Support</field>
             <field name="code">OS</field>
-            <field name="parent_id" ref="crm.crm_case_section_2"></field>
-    </record>
+            <field name="parent_id" ref="crm.crm_case_section_2"/>
+        </record>
 
-    <record model="crm.segmentation" id="crm_segmentation0">
-        <field name="name">OpenERP partners</field>
-        <field name="exclusif">True</field>
-        <field name="categ_id" ref="base.res_partner_category_2"/>
-    </record>
+        <record model="crm.segmentation" id="crm_segmentation0">
+            <field name="name">OpenERP partners</field>
+            <field name="exclusif">True</field>
+            <field name="categ_id" ref="base.res_partner_category_2"/>
+        </record>
 
     </data>
 </openerp>

=== modified file 'crm/crm_lead.py'
--- crm/crm_lead.py	2012-09-27 19:10:59 +0000
+++ crm/crm_lead.py	2012-09-28 09:47:36 +0000
@@ -298,7 +298,7 @@
         if partner_id:
             partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
             values = {
-                'partner_name' : partner.name, 
+                'partner_name' : partner.name,
                 'street' : partner.street,
                 'street2' : partner.street2,
                 'city' : partner.city,
@@ -495,7 +495,8 @@
             title = "%s : %s" % (merge_message, opportunity.name)
             details.append(self._mail_body(cr, uid, opportunity, fields, title=title, context=context))
 
-        subject = subject[0] + ", ".join(subject[1:])
+        # Chatter message's subject
+        subject = subject[0] + ": " + ", ".join(subject[1:])
         details = "\n\n".join(details)
         return self.message_post(cr, uid, [opportunity_id], body=details, subject=subject, context=context)
 
@@ -564,19 +565,18 @@
 
         data = self._merge_data(cr, uid, ids, oldest, fields, context=context)
 
-        # merge data into first opportunity
-        self.write(cr, uid, [first_opportunity.id], data, context=context)
-
-        #copy message and attachements into the first opportunity
+        # Merge messages and attachements into the first opportunity
         self._merge_opportunity_history(cr, uid, first_opportunity.id, tail_opportunities, context=context)
         self._merge_opportunity_attachments(cr, uid, first_opportunity.id, tail_opportunities, context=context)
 
-        #Notification about loss of information
+        # Merge notifications about loss of information
         self._merge_notification(cr, uid, first_opportunity, opportunities, context=context)
-        #delete tail opportunities
+        # Write merged data into first opportunity
+        self.write(cr, uid, [first_opportunity.id], data, context=context)
+        # Delete tail opportunities
         self.unlink(cr, uid, [x.id for x in tail_opportunities], context=context)
 
-        #open first opportunity
+        # Open first opportunity
         self.case_open(cr, uid, [first_opportunity.id])
         return first_opportunity.id
 
@@ -585,13 +585,16 @@
         contact_id = False
         if customer:
             contact_id = self.pool.get('res.partner').address_get(cr, uid, [customer.id])['default']
+
         if not section_id:
             section_id = lead.section_id and lead.section_id.id or False
+
         if section_id:
             stage_ids = crm_stage.search(cr, uid, [('sequence','>=',1), ('section_ids','=', section_id)])
         else:
             stage_ids = crm_stage.search(cr, uid, [('sequence','>=',1)])
         stage_id = stage_ids and stage_ids[0] or False
+
         return {
                 'planned_revenue': lead.planned_revenue,
                 'probability': lead.probability,
@@ -608,7 +611,6 @@
 
     def convert_opportunity(self, cr, uid, ids, partner_id, user_ids=False, section_id=False, context=None):
         partner = self.pool.get('res.partner')
-        mail_message = self.pool.get('mail.message')
         customer = False
         if partner_id:
             customer = partner.browse(cr, uid, partner_id, context=context)

=== modified file 'crm/crm_lead_demo.xml'
--- crm/crm_lead_demo.xml	2012-09-05 07:31:34 +0000
+++ crm/crm_lead_demo.xml	2012-09-28 09:47:36 +0000
@@ -1,10 +1,8 @@
 <?xml version="1.0"?>
 <openerp>
     <data noupdate="1">
-        <!-- 
-            Demo Leads
-            -->
 
+        <!--  Demo Leads -->
         <record id="crm_case_1" model="crm.lead">
             <field name="type">lead</field>
             <field name="name">Plan to Attend a Training</field>
@@ -26,9 +24,9 @@
             <field name="user_id" ref="base.user_root"/>
             <field name="stage_id" ref="stage_lead1"/>
             <field name="description">Hello,
-I am Jason from Le Club SARL,
-I am intertested to attend Training organized in your company,
-Can you send details,</field>
+I am Jason from Le Club SARL.
+I am intertested to attend a training organized in your company.
+Can you send me the details ?</field>
             <field eval="1" name="active"/>
         </record>
 
@@ -110,7 +108,8 @@
             <field name="section_id" ref="section_sales_department"/>
             <field name="user_id" ref="base.user_root"/>
             <field name="stage_id" ref="stage_lead1"/>
-            <field name="description">Hi, Can you send a quotation for 20 Computers with speakers? 
+            <field name="description">Hi,
+Can you send me a quotation for 20 computers with speakers?
 Regards,
 Carrie Helle,
 Purchase Manager
@@ -215,8 +214,9 @@
             <field name="section_id" ref="crm_case_section_3"/>
             <field name="user_id" ref=""/>
             <field name="stage_id" ref="stage_lead1"/>
-            <field name="description">hi,
-I want to know specification and cost of laptops of your company.
+            <field name="description">Hi,
+I would like to know more about specification and cost of laptops of your company.
+
 Thanks,
 Andrew</field>
             <field eval="1" name="active"/>
@@ -260,25 +260,20 @@
             <field eval="1" name="active"/>
         </record>
 
-
-        <!--        Call Function to Cancel the leads (set as Dead) -->
+        <!-- Call Function to Cancel the leads (set as Dead) -->
         <function model="crm.lead" name="case_cancel"
             eval="[ ref('crm_case_12'), ref('crm_case_7'),
                     ref('crm_case_3'), ref('crm_case_8')],
                   {'install_mode': True}"
         />
-        <!--        Call Function to set the leads as Unread -->
+
+        <!-- Call Function to set the leads as Unread -->
         <function model="crm.lead" name="message_mark_as_unread"
             eval="[ ref('crm_case_1'), ref('crm_case_2'),
                     ref('crm_case_5'), ref('crm_case_11')], {}"
         />
 
-
-        <!-- 
-            Demo Opportunities
-            -->
-
-
+        <!-- Demo Opportunities -->
         <record id="crm_case_13" model="crm.lead">
             <field name="type">opportunity</field>
             <field name="name">Plan to buy 60 keyboards and mouses</field>
@@ -563,9 +558,9 @@
             <field name="body">Dear Customer,
 Thanks for showing interest in our products.
 We have attached the catalogue,
-We would like to know your interests, Let us know if we can call you for more details.
+We would like to know your interests, so let us know when we can call you for more details.
 
-Thanks</field>
+Regards</field>
             <field name="parent_id" ref="message_email0"/>
             <field name="author_id" ref="base.partner_root"/>
         </record>
@@ -600,9 +595,9 @@
             <field name="model">crm.lead</field>
             <field name="res_id" ref="crm_case_1"/>
             <field name="body">Hello,
-I am Jason from Le Club SARL,
-I am intertested to attend Training organized in your company,
-Can you send details,</field>
+I am Jason from Le Club SARL.
+I am intertested to attend a training organized in your company.
+Can you send me the details ?</field>
             <field name="type">email</field>
         </record>
         <record id="message_email_13" model="mail.message">
@@ -613,7 +608,7 @@
             <field name="type">comment</field>
         </record>
 
-        <!--        Call Function to set the opportunities as Unread -->
+        <!-- Call Function to set the opportunities as Unread -->
         <function model="crm.lead" name="message_mark_as_unread"
             eval="[ ref('crm_case_15'), ref('crm_case_16'),
                     ref('crm_case_23'), ref('crm_case_19')], {}"

=== modified file 'crm/crm_phonecall_demo.xml'
--- crm/crm_phonecall_demo.xml	2012-08-07 07:50:00 +0000
+++ crm/crm_phonecall_demo.xml	2012-09-28 09:47:36 +0000
@@ -1,9 +1,8 @@
 <?xml version="1.0"?>
 <openerp>
     <data noupdate="1">
-    <!-- 
-        ((((((((((( Demo Cases ))))))))))) 
-    -->
+
+        <!--  Demo Cases  -->
         <record id="crm_phonecall_1" model="crm.phonecall">
             <field eval="time.strftime('%Y-%m-04 10:45:36')" name="date"/>
             <field name="partner_id" ref="base.res_partner_11"/>
@@ -47,7 +46,7 @@
             <field eval="time.strftime('%Y-%m-21 14:10:23')" name="date"/>
             <field eval="'3'" name="priority"/>
             <field name="user_id" ref="base.user_root"/>
-            <field name="name">Wanted information about pricing of Laptops</field>
+            <field name="name">Wanted information about pricing of laptops</field>
             <field name="state">done</field>
             <field name="partner_phone">(077) 582-4035</field>
             <field name="partner_mobile">(077) 341-3591</field>
@@ -79,6 +78,7 @@
             <field eval="time.strftime('%Y-%m-28 14:15:30')" name="date"/>
             <field name="categ_id" ref="crm.categ_phone2"/>
             <field eval="8.56" name="duration"/>
-        </record>    
+        </record>
+
     </data>
 </openerp>

=== modified file 'crm/test/process/action_rule.yml'
--- crm/test/process/action_rule.yml	2012-07-09 06:57:57 +0000
+++ crm/test/process/action_rule.yml	2012-09-28 09:47:36 +0000
@@ -7,14 +7,14 @@
     new_id = self.create(cr, uid, {'name': 'New Rule', 'model_id': model_ids[0],  'trg_user_id': ref('base.user_root'), 'trg_partner_id': ref('base.res_partner_1'), 'act_user_id': ref('base.user_demo') })
     self._check(cr, uid)
 -
-  I create new lead to check record rule.
+  I create a new lead to check the record rule.
 -
   !record {model: crm.lead, id: crm_lead_test_rules_id}:
     name: 'Test lead rules'
     partner_id: base.res_partner_1
 -
-  I check record rule is apply and responsible is changed.
+  I check if the record rule is applied and the responsible is changed.
 -
   !python {model: crm.lead}: |
     lead_user = self.browse(cr, uid, ref('crm_lead_test_rules_id'))
-    assert lead_user.user_id.id == ref('base.user_demo'), "Responsible of lead is not changed." 
+    assert lead_user.user_id.id == ref('base.user_demo'), "Responsible of lead is not changed."

=== modified file 'crm/test/process/cancel_lead.yml'
--- crm/test/process/cancel_lead.yml	2012-08-06 13:28:04 +0000
+++ crm/test/process/cancel_lead.yml	2012-09-28 09:47:36 +0000
@@ -10,7 +10,7 @@
     lead = self.browse(cr, uid, ref('crm_case_1'))
     assert lead.stage_id.id == ref('crm.stage_lead7'), "Stage should be 'Dead' and is %s." % (lead.stage_id.name)
     assert lead.state == 'cancel', "Opportunity is not in 'cancel' state."
-    assert lead.probability == 0.0, 'Opportunity probability is wrong and should be 0.0.'
+    assert lead.probability == 0.0, 'Opportunity is probably wrong and should be 0.0.'
 -
   I reset cancelled lead into unqualified lead.
 -

=== modified file 'crm/test/process/communication_with_customer.yml'
--- crm/test/process/communication_with_customer.yml	2012-09-14 14:01:48 +0000
+++ crm/test/process/communication_with_customer.yml	2012-09-28 09:47:36 +0000
@@ -1,7 +1,7 @@
 -
-  Customer interested in our product. so he send request by email to get more details.
+  Customer interested in our product, so he sends request by email to get more details.
 -
-  Mail script will be fetched him request from mail server. so I process that mail after read EML file 
+  Mail script will fetch his request from mail server. Then I process that mail after read EML file.
 -
   !python {model: mail.thread}: |
     import addons
@@ -15,27 +15,27 @@
     lead_ids = self.search(cr, uid, [('email_from','=', 'Mr. John Right <[email protected]>')])
     assert lead_ids and len(lead_ids), "Lead is not created after getting request"
     lead = self.browse(cr, uid, lead_ids[0], context=context)
-    assert not lead.partner_id, "Customer should be a new"
+    assert not lead.partner_id, "Customer should be a new one"
     assert lead.name == "Fournir votre devis avec le meilleur prix.", "Subject does not match"
 -
-  I reply him request with welcome message. TODO revert mail.mail to mail.compose.message (conversion to customer should be automatic).
+  I reply his request with welcome message. TODO revert mail.mail to mail.compose.message (conversion to customer should be automatic).
 -
   !python {model: mail.mail}: |
     lead_ids = self.pool.get('crm.lead').search(cr, uid, [('email_from','=', 'Mr. John Right <[email protected]>')])
     context.update({'active_model': 'crm.lead','active_id': lead_ids[0]})
-    id = self.create(cr, uid, {'body': "Merci à l'intérêt pour notre produit.nous vous contacterons bientôt. Merci", 'email_from': '[email protected]'}, context=context)
+    id = self.create(cr, uid, {'body': "Merci de votre intérêt pour notre produit, nous vous contacterons bientôt. Bien à vous", 'email_from': '[email protected]'}, context=context)
     try:
         self.send_mail(cr, uid, [id], context=context)
     except:
         pass
 -
-  Now, I convert him into customer and put into regular customer list.
+  Now, I convert him into customer and put him into regular customer list.
 -
   !python {model: crm.lead}: |
     lead_ids = self.search(cr, uid, [('email_from','=', 'Mr. John Right <[email protected]>')])
     self.convert_partner(cr, uid, lead_ids, context=context)
 -
-  I convert one phonecall request as a customer and put into regular customer list. 
+  I convert one phonecall request to a customer and put him into regular customer list.
 -
   !python {model: crm.phonecall2partner}: |
     context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_phonecall_4")], 'active_id': ref("crm.crm_phonecall_4")})
@@ -48,5 +48,5 @@
     partner_id = self.search(cr, uid, [('phonecall_ids', '=', ref('crm.crm_phonecall_4'))])
     assert partner_id, "Customer is not found in regular customer list."
     data = self.browse(cr, uid, partner_id, context=context)[0]
-    assert data.user_id.id == ref("base.user_root"), "User not assign properly"
-    assert data.name == "Wanted information about pricing of Laptops", "Bad partner name"
+    assert data.user_id.id == ref("base.user_root"), "User not assigned properly"
+    assert data.name == "Wanted information about pricing of laptops", "Bad partner name"

=== modified file 'crm/test/process/lead2opportunity2win.yml'
--- crm/test/process/lead2opportunity2win.yml	2012-08-24 16:13:20 +0000
+++ crm/test/process/lead2opportunity2win.yml	2012-09-28 09:47:36 +0000
@@ -1,17 +1,17 @@
 -
-  In order to test convert customer lead into opportunity, 
+  In order to test convert customer lead into opportunity,
 -
   I open customer lead.
 -
    !python {model: crm.lead}: |
      self.case_open(cr, uid, [ref("crm_case_4")])
-- 
-  I check lead state is "Open". 
+-
+  I check lead state is "Open".
 -
   !assert {model: crm.lead, id: crm.crm_case_4, string: Lead in open state}:
      - state == "open"
 -
-  I create partner from lead. 
+  I create partner from lead.
 -
   !record {model: crm.lead2partner, id: crm_lead2partner_id1, context: '{"active_model": "crm.lead", "active_ids": [ref("crm_case_4")]}'}:
 -
@@ -24,7 +24,7 @@
   !python {model: crm.lead}: |
     self.convert_opportunity(cr, uid ,[ref("crm_case_4")], ref("base.res_partner_2"))
 -
-  I check details of converted opportunity. 
+  I check details of converted opportunity.
 -
   !python {model: crm.lead}: |
     lead = self.browse(cr, uid, ref('crm_case_4'))
@@ -37,15 +37,15 @@
   !python {model: crm.opportunity2phonecall}: |
     import time
     context.update({'active_model': 'crm.lead', 'active_ids': [ref('crm_case_4')]})
-    call_id = self.create(cr, uid, {'date': time.strftime('%Y-%m-%d %H:%M:%S'), 
-                'name': "Bonjour M. Jean, Comment êtes-vous? J'ai obtenu votre demande. peut-on parler au sujet de ce pour quelques minutes?"}, context=context)
+    call_id = self.create(cr, uid, {'date': time.strftime('%Y-%m-%d %H:%M:%S'),
+                'name': "Bonjour M. Jean, Comment allez-vous? J'ai bien reçu votre demande, pourrions-nous en parler quelques minutes?"}, context=context)
     self.action_schedule(cr, uid, [call_id], context=context)
 -
   I check that phonecall is scheduled for that opportunity.
 -
   !python {model: crm.phonecall}: |
     ids = self.search(cr, uid, [('opportunity_id', '=', ref('crm_case_4'))])
-    assert len(ids), 'phonecall is not scheduled'
+    assert len(ids), 'Phonecall is not scheduled'
 -
   Now I schedule meeting with customer.
 -
@@ -55,7 +55,7 @@
   After communicated  with customer, I put some notes with contract details.
 -
   !python {model: crm.lead}: |
-    self.message_post(cr, uid, [ref('crm_case_4')], subject='Test note', body='ces détails envoyés par le client sur ​​le FAX pour la qualité')
+    self.message_post(cr, uid, [ref('crm_case_4')], subject='Test note', body='Détails envoyés par le client sur ​​le FAX pour la qualité')
 -
   I win this opportunity
 -
@@ -73,7 +73,7 @@
   I convert mass lead into opportunity customer.
 -
   !python {model: crm.lead2opportunity.partner.mass}: |
-    context.update({'active_model': 'crm.lead', 'active_ids': [ref("crm_case_11"), ref("crm_case_2")], 'active_id': ref("crm_case_11")}) 
+    context.update({'active_model': 'crm.lead', 'active_ids': [ref("crm_case_11"), ref("crm_case_2")], 'active_id': ref("crm_case_11")})
     id = self.create(cr, uid, {'user_ids': [ref('base.user_root')], 'section_id': ref('crm.section_sales_department')}, context=context)
     self.mass_convert(cr, uid, [id], context=context)
 -
@@ -111,7 +111,7 @@
   I confirm review needs meeting.
 -
   !python {model: crm.meeting}: |
-    context.update({'active_model': 'crm.meeting'}) 
+    context.update({'active_model': 'crm.meeting'})
     self.case_open(cr, uid, [ref('base_calendar.crm_meeting_4')])
 -
   I invite a user for meeting.

=== modified file 'crm/test/process/merge_opportunity.yml'
--- crm/test/process/merge_opportunity.yml	2012-07-30 10:29:47 +0000
+++ crm/test/process/merge_opportunity.yml	2012-09-28 09:47:36 +0000
@@ -1,19 +1,19 @@
 -
-  I make direct opportunity for customer.
+  I make an opportunity from customer.
 -
   !python {model: crm.partner2opportunity}: |
     context.update({'active_model': 'res.partner', 'active_ids': [ref("base.res_partner_9")]})
-    res_id = self.create(cr, uid, {'name': "enquête pour l'achat de services"}, context=context)
+    res_id = self.create(cr, uid, {'name': "Enquête pour l'achat de services"}, context=context)
     self.make_opportunity(cr, uid, [res_id], context=context)
 -
-  I make another opportunity from phonecall for same customer.
+  I make another opportunity from a phone call with the same customer.
 -
   !python {model: crm.phonecall2opportunity}: |
     context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_phonecall_6")]})
-    res_id = self.create(cr, uid, {'name': "Quoi de prix de votre autre service?", 'partner_id': ref("base.res_partner_9")}, context=context)
+    res_id = self.create(cr, uid, {'name': "À propos du prix de votre autre service", 'partner_id': ref("base.res_partner_9")}, context=context)
     self.make_opportunity(cr, uid, [res_id], context=context)
 -
-  Now I merge all opportunities of customer.
+  Now I merge these opportunities.
 -
   !python {model: crm.lead}: |
     opportunity_ids = self.search(cr, uid, [('partner_id','=', ref("base.res_partner_9"))])
@@ -24,7 +24,7 @@
   !python {model: crm.merge.opportunity}: |
     self.action_merge(cr, uid, [ref("opportunity_merge_id")], context=context)
 -
-  I check for merged opportunities for customer. 
+  I check for merged opportunities for customer.
 -
   !python {model: crm.lead}: |
     merge_id = self.search(cr, uid, [('partner_id','=', ref("base.res_partner_9"))])
@@ -32,55 +32,3 @@
     merge_data = self.browse(cr, uid, merge_id)[0]
     assert merge_data.type == 'opportunity', 'Merged opportunity type not change!'
     assert merge_data.partner_id.id == ref("base.res_partner_9"), 'Partner missmatch!'
--
-  Now I schedule another phonecall to customer after merged.
--
-  !python {model: crm.phonecall2phonecall}: |
-    context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_phonecall_6")], 'active_id': ref("crm.crm_phonecall_6")})
-    res_id = self.create(cr, uid, {'name': "vos chances sont fusionnés en un seul"}, context=context)
-    self.action_schedule(cr, uid, [res_id], context=context)
-- 
-  I schedule meeting on this phonecall.
--
-  !python {model: crm.phonecall}: |
-    self.action_make_meeting(cr, uid, [ref("crm.crm_phonecall_6")])
--
-  I set phone call to not held.
--
-  !python {model: crm.phonecall}: |
-    self.case_pending(cr, uid, [ref("crm.crm_phonecall_6")])
--
-  I check that the phone call is in 'Not Held' state. 
--
-  !assert {model: crm.phonecall, id: crm.crm_phonecall_6, string: Phone call held.}:
-    - state == "pending"
--
-  I cancelled the phone call. 
--
-  !python {model: crm.phonecall}: |
-    self.case_cancel(cr, uid, [ref("crm.crm_phonecall_6")])
--
-  I check that the phone call is in 'Cancelled' state.
--
-  !assert {model: crm.phonecall, id: crm.crm_phonecall_6, string: Phone call is not cancelled.}:
-    - state == "cancel"
--
-  I reset the phone call. 
--
-  !python {model: crm.phonecall}: |
-    self.case_reset(cr, uid, [ref("crm.crm_phonecall_6")])
--
-  I check that the phone call is reset or not.
--
-  !assert {model: crm.phonecall, id: crm.crm_phonecall_6, string: Phone call is not reset.}:
-    - state == "open"
--
-  I set phone call to held (done).
--
-  !python {model: crm.phonecall}: |
-    self.case_close(cr, uid, [ref("crm.crm_phonecall_6")])
--
-  I check that the phone call is in 'Held' state.
--
-  !assert {model: crm.phonecall, id: crm.crm_phonecall_6, string: Phone call is not held.}:
-    - state == "done"

=== added file 'crm/test/process/phonecalls.yml'
--- crm/test/process/phonecalls.yml	1970-01-01 00:00:00 +0000
+++ crm/test/process/phonecalls.yml	2012-09-28 09:47:36 +0000
@@ -0,0 +1,52 @@
+-
+  I schedule a phone call with a customer.
+-
+  !python {model: crm.phonecall2phonecall}: |
+    context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_phonecall_6")], 'active_id': ref("crm.crm_phonecall_6")})
+    res_id = self.create(cr, uid, {'name': "Proposition de réduction"}, context=context)
+    self.action_schedule(cr, uid, [res_id], context=context)
+-
+  I schedule a meeting based on this phone call.
+-
+  !python {model: crm.phonecall}: |
+    self.action_make_meeting(cr, uid, [ref("crm.crm_phonecall_6")])
+-
+  I set the phone call to not held.
+-
+  !python {model: crm.phonecall}: |
+    self.case_pending(cr, uid, [ref("crm.crm_phonecall_6")])
+-
+  I check that the phone call is in 'Not Held' state.
+-
+  !assert {model: crm.phonecall, id: crm.crm_phonecall_6, string: Phone call held.}:
+    - state == "pending"
+-
+  I cancel the phone call.
+-
+  !python {model: crm.phonecall}: |
+    self.case_cancel(cr, uid, [ref("crm.crm_phonecall_6")])
+-
+  I check that the phone call is in 'Cancelled' state.
+-
+  !assert {model: crm.phonecall, id: crm.crm_phonecall_6, string: Phone call is not cancelled.}:
+    - state == "cancel"
+-
+  I reset the phone call.
+-
+  !python {model: crm.phonecall}: |
+    self.case_reset(cr, uid, [ref("crm.crm_phonecall_6")])
+-
+  I check that the phone call is reset.
+-
+  !assert {model: crm.phonecall, id: crm.crm_phonecall_6, string: Phone call is not reset.}:
+    - state == "open"
+-
+  I set phone call to held (done).
+-
+  !python {model: crm.phonecall}: |
+    self.case_close(cr, uid, [ref("crm.crm_phonecall_6")])
+-
+  I check that the phone call is in 'Held' state.
+-
+  !assert {model: crm.phonecall, id: crm.crm_phonecall_6, string: Phone call is not held.}:
+    - state == "done"

=== modified file 'crm/wizard/crm_lead_to_opportunity.py'
--- crm/wizard/crm_lead_to_opportunity.py	2012-09-12 17:55:27 +0000
+++ crm/wizard/crm_lead_to_opportunity.py	2012-09-28 09:47:36 +0000
@@ -34,15 +34,17 @@
                                     ('create', 'Create a new customer'), \
                                     ('nothing', 'Do not link to a customer')], \
                                     'Related Customer', required=True),
-        'name': fields.selection([('convert', 'Convert to Opportunities'), ('merge', 'Merge with existing Opportunities')], 'Conversion Action', required=True),
+        'name': fields.selection([('convert', 'Convert to opportunity'), \
+                                  ('merge', 'Merge with existing opportunities')], \
+                                  'Conversion Action', required=True),
         'opportunity_ids': fields.many2many('crm.lead', string='Opportunities', domain=[('type', '=', 'opportunity')]),
     }
 
     def default_get(self, cr, uid, fields, context=None):
         """
-            Default get for name, opportunity_ids
-            if there is an exisitng  partner link to the lead, find all existing opportunity link with this partnet to merge
-            all information together
+        Default get for name, opportunity_ids.
+        If there is an exisitng partner link to the lead, find all existing
+        opportunities links with this partner to merge all information together
         """
         lead_obj = self.pool.get('crm.lead')
 
@@ -62,12 +64,13 @@
 
         ids = []
         if partner_id:
+            # Search for opportunities that have the same partner and that arent done or cancelled
             ids = lead_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', '=', 'opportunity'), '!', ('state', 'in', ['done', 'cancel'])])
             if ids:
                 opportunities.append(ids[0])
         if not partner_id:
             if email:
-                # Find email of existing opportunity matches the email_from of the lead
+                # Find email of existing opportunity matching the email_from of the lead
                 cr.execute("""select id from crm_lead where type='opportunity' and
                                 substring(email_from from '([^ ,<@]+@[^> ,]+)') in (%s)""" % (','.join(email)))
                 ids = map(lambda x:x[0], cr.fetchall())
@@ -83,12 +86,11 @@
         if 'opportunity_ids' in fields:
             res.update({'opportunity_ids': opportunities})
 
-
         return res
 
     def view_init(self, cr, uid, fields, context=None):
         """
-        This function checks for precondition before wizard executes
+        Check some preconditions before the wizard executes.
         """
         if context is None:
             context = {}
@@ -110,7 +112,7 @@
             partner_id = partner_ids_map.get(lead_id, False)
             # FIXME: cannot pass user_ids as the salesman allocation only works in batch
             res = lead.convert_opportunity(cr, uid, [lead_id], partner_id, [], team_id, context=context)
-        # FIXME: must perform salesman allocation in batch separately here  
+        # FIXME: must perform salesman allocation in batch separately here
         user_ids = vals.get('user_ids', False)
         if user_ids:
             lead.allocate_salesman(cr, uid, lead_ids, user_ids, team_id=team_id, context=context)
@@ -136,9 +138,10 @@
 
     def action_apply(self, cr, uid, ids, context=None):
         """
-        This converts lead to opportunity and opens Opportunity view
+        Convert lead to opportunity or merge lead and opportunity and open
+        the freshly created opportunity view.
         """
-        if not context:
+        if context is None:
             context = {}
         lead = self.pool.get('crm.lead')
         lead_ids = context.get('active_ids', [])

=== modified file 'crm/wizard/crm_lead_to_opportunity_view.xml'
--- crm/wizard/crm_lead_to_opportunity_view.xml	2012-09-12 17:55:27 +0000
+++ crm/wizard/crm_lead_to_opportunity_view.xml	2012-09-28 09:47:36 +0000
@@ -8,14 +8,8 @@
             <field name="arch" type="xml">
                 <form string="Convert to Opportunity" version="7.0">
                     <group>
-                        <field name="action" class="oe_inline"/>
-                        <field name="partner_id" 
-                            attrs="{'required': [('action', '=', 'exist')], 'invisible':[('action','!=','exist')]}"
-                            class="oe_inline"/>
-                    </group>
-                    <group>
                         <field name="name" class="oe_inline"/>
-                        <field name="opportunity_ids" attrs="{'invisible': [('name', '=', 'convert')]}">
+                        <field name="opportunity_ids" attrs="{'invisible': [('name', '!=', 'merge')]}">
                             <tree>
                                 <field name="name"/>
                                 <field name="partner_id"/>
@@ -24,6 +18,12 @@
                             </tree>
                         </field>
                     </group>
+                    <group attrs="{'invisible': [('name', '!=', 'convert')]}">
+                        <field name="action" class="oe_inline"/>
+                        <field name="partner_id"
+                            attrs="{'required': [('action', '=', 'exist')], 'invisible':[('action','!=','exist')]}"
+                            class="oe_inline"/>
+                    </group>
                     <footer>
                         <button name="action_apply" string="Create Opportunity" type="object" class="oe_highlight"/>
                         or
@@ -38,23 +38,28 @@
             <field name="model">crm.lead2opportunity.partner.mass</field>
             <field name="arch" type="xml">
                 <form string="Convert to Opportunity" version="7.0">
-                    <group string="Conversion Options">
-                        <field name="action"/>
-                        <field name="partner_id" attrs="{'invisible':[('action','!=','exist')],'required': [('action', '=', 'exist')]}"/>
-                        <field name="name"/>
-                    </group>
-                    <group string="Select Opportunities" attrs="{'invisible': [('name', '=', 'convert')]}">
-                    <field name="opportunity_ids" colspan="4" nolabel="1" attrs="{'invisible': [('name', '=', 'convert')]}">
-                        <tree>
-                            <field name="name" />
-                            <field name="partner_id" />
-                            <field name="user_id" />
-                            <field name="section_id" />
-                        </tree>
-                    </field>
-                    </group>
-                    
-                    <group string="Assign opportunities to">
+                    <separator string="Conversion Options"/>
+                    <group>
+                        <field name="name" class="oe_inline"/>
+                    </group>
+                    <group attrs="{'invisible': [('name', '!=', 'convert')]}">
+                        <field name="action" class="oe_inline"/>
+                        <field name="partner_id"
+                            attrs="{'required': [('action', '=', 'exist')], 'invisible':[('action','!=','exist')]}"
+                            class="oe_inline"/>
+                    </group>
+                    <group string="Select Opportunities" attrs="{'invisible': [('name', '!=', 'merge')]}">
+                        <field name="opportunity_ids" colspan="4" nolabel="1" attrs="{'invisible': [('name', '=', 'convert')]}">
+                            <tree>
+                                <field name="name" />
+                                <field name="partner_id" />
+                                <field name="user_id" />
+                                <field name="section_id" />
+                            </tree>
+                        </field>
+                    </group>
+
+                    <group string="Assign opportunities to" attrs="{'invisible': [('name', '=', '')]}">
                         <field name="section_id" />
                         <field name="user_ids" colspan="4">
                             <tree>
@@ -62,14 +67,14 @@
                             </tree>
                         </field>
                     </group>
-                    
+
                     <footer>
                         <button name="mass_convert" string="Convert to Opportunities" type="object" class="oe_highlight"/>
                         or
                         <button string="Cancel" class="oe_link" special="cancel"/>
-                    </footer>                            
+                    </footer>
                 </form>
-              </field>
+            </field>
         </record>
 
         <record id="action_crm_lead2opportunity_partner" model="ir.actions.act_window">
@@ -83,10 +88,11 @@
 
         <act_window id="action_crm_send_mass_convert"
             multi="True"
-            key2="client_action_multi" name="Convert opportunities"
+            key2="client_action_multi" name="Convert to opportunities"
             res_model="crm.lead2opportunity.partner.mass" src_model="crm.lead"
             view_mode="form" target="new" view_type="form"
             context="{'mass_convert' : True}"
             view_id="view_crm_lead2opportunity_partner_mass"/>
+
     </data>
 </openerp>

=== modified file 'crm/wizard/crm_merge_opportunities.py'
--- crm/wizard/crm_merge_opportunities.py	2011-12-19 16:54:40 +0000
+++ crm/wizard/crm_merge_opportunities.py	2012-09-28 09:47:36 +0000
@@ -27,6 +27,8 @@
     _description = 'Merge two Opportunities'
 
     def action_merge(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
         lead = self.pool.get('crm.lead')
         record = self.browse(cr, uid, ids[0], context=context)
         opportunities = record.opportunity_ids
@@ -38,7 +40,7 @@
         return lead.redirect_opportunity_view(cr, uid, merge_id, context=context)
 
     _columns = {
-        'opportunity_ids' : fields.many2many('crm.lead',  'merge_opportunity_rel', 'merge_id', 'opportunity_id', 'Opportunities', domain=[('type', '=', 'opportunity')]),
+        'opportunity_ids': fields.many2many('crm.lead', rel='merge_opportunity_rel', id1='merge_id', id2='opportunity_id', string='Leads/Opportunities'),
     }
 
     def default_get(self, cr, uid, fields, context=None):

=== modified file 'crm/wizard/crm_merge_opportunities_view.xml'
--- crm/wizard/crm_merge_opportunities_view.xml	2012-08-13 16:06:57 +0000
+++ crm/wizard/crm_merge_opportunities_view.xml	2012-09-28 09:47:36 +0000
@@ -3,13 +3,12 @@
     <data>
 
         <!-- Merge Opportunities  -->
-
         <record model="ir.ui.view" id="merge_opportunity_form">
             <field name="name">crm.merge.opportunity.form</field>
             <field name="model">crm.merge.opportunity</field>
             <field name="arch" type="xml">
-                <form string="Merge Opportunities" version="7.0">
-                    <separator string="Select Opportunities"/>
+                <form string="Merge Leads/Opportunities" version="7.0">
+                    <separator string="Select Leads/Opportunities"/>
                     <field name="opportunity_ids">
                         <tree>
                             <field name="name"/>
@@ -19,7 +18,7 @@
                         </tree>
                     </field>
                     <footer>
-                        <button name="action_merge" type="object" string="_Merge" class="oe_highlight"/>
+                        <button name="action_merge" type="object" string="Merge" class="oe_highlight"/>
                         or
                         <button string="Cancel" class="oe_link" special="cancel"/>
                     </footer>
@@ -27,10 +26,9 @@
             </field>
         </record>
 
-        <!--  Merge Opportunities action -->
-
+        <!--  Merge leads/opportunities action -->
         <record model="ir.actions.act_window" id="merge_opportunity_act">
-            <field name="name">Merge Opportunities</field>
+            <field name="name">Merge leads/opportunities</field>
             <field name="res_model">crm.merge.opportunity</field>
             <field name="view_type">form</field>
             <field name="view_mode">form</field>
@@ -40,7 +38,7 @@
 
         <act_window id="action_merge_opportunities"
             multi="True"
-            key2="client_action_multi" name="Merge Opportunities"
+            key2="client_action_multi" name="Merge leads/opportunities"
             res_model="crm.merge.opportunity" src_model="crm.lead"
             view_mode="form" target="new" view_type="form"/>
 

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to