summaryrefslogtreecommitdiff
path: root/addons/crm/tests
diff options
context:
space:
mode:
authorThibault Francois <tfr@openerp.com>2020-07-16 13:43:07 +0000
committerThibault Delavallée <tde@odoo.com>2020-08-04 15:08:56 +0000
commite6cb48b7e41693066f5d9ad55c4535793977aea2 (patch)
tree8ba4dc8d7adf1f4dbf43726d7402de975df2484b /addons/crm/tests
parent62355b6ad3e2af16efabe1c3ca2fb053a6084bc1 (diff)
[FIX] crm_lead: do not erase computed field based on partner
Issue: When you write partner_id = False on a lead it erase all the values computed based on the res.partner this lead to data loss during the conversion to opportunies by the lead assignation process Solution: Revert to v13.0 behavior, don't erase the value of the address, phone, email when the partner is set to False + Fix typo in method name X-original-commit: 21db6cf93fea7d07ec4a8655fc6030a177abc36f
Diffstat (limited to 'addons/crm/tests')
-rw-r--r--addons/crm/tests/test_crm_lead.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/addons/crm/tests/test_crm_lead.py b/addons/crm/tests/test_crm_lead.py
index 8473ed4a555..d55e42c2748 100644
--- a/addons/crm/tests/test_crm_lead.py
+++ b/addons/crm/tests/test_crm_lead.py
@@ -23,13 +23,31 @@ class TestCRMLead(TestCrmCommon):
# update to a partner, should udpate address
lead.write({'partner_id': self.contact_1.id})
- # self.assertEqual(lead.partner_name, self.contact_company_1.name)
- # self.assertEqual(lead.contact_name, self.contact_1.name)
- # self.assertEqual(lead.email_from, self.contact_1.email)
- # self.assertEqual(lead.street, self.contact_1.street)
- # self.assertEqual(lead.city, self.contact_1.city)
- # self.assertEqual(lead.zip, self.contact_1.zip)
- # self.assertEqual(lead.country_id, self.contact_1.country_id)
+ self.assertEqual(lead.partner_name, self.contact_company_1.name)
+ self.assertEqual(lead.contact_name, self.contact_1.name)
+ self.assertEqual(lead.email_from, self.contact_1.email)
+ self.assertEqual(lead.street, self.contact_1.street)
+ self.assertEqual(lead.city, self.contact_1.city)
+ self.assertEqual(lead.zip, self.contact_1.zip)
+ self.assertEqual(lead.country_id, self.contact_1.country_id)
+
+ def test_crm_lead_creation_no_partner(self):
+ belgium = self.env.ref('base.be')
+ lead_data = {
+ 'name': 'Test',
+ 'country_id': belgium.id,
+ 'email_from': 'test@odoo.com',
+ 'phone': '04584579646',
+ }
+ lead = self.env['crm.lead'].new(lead_data)
+ # get the street should not trigger cache miss
+ lead.street
+ # Create the lead and the write partner_id = False
+ # Country should remain
+ lead = self.env['crm.lead'].create(lead_data)
+ self.assertEqual(lead.country_id, belgium, "Country should be set on the lead")
+ lead.partner_id = False
+ self.assertEqual(lead.country_id, belgium, "Country should still be set on the lead")
@users('user_sales_manager')
def test_crm_lead_partner_sync(self):