[REF] crm: clean lead common test class
Purpose of this commit is to clean a bit crm tests, notably lessening data created in tests and removing / improving some low level tests. As we are about to remove onchange / default and replace them by editable computed fields it is easier to clean some tests and data beforehand. This commit is a preliminary cleaning coming from task 2088565 about CRM onchange to compute methods update. LINKS Task ID 2088565 Community PR #42344 Enterprise PR odoo/enterprise#7403 Related: odoo/enterprise#7403 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
+107
-39
@@ -1,70 +1,138 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.mail.tests.common import MailCase, mail_new_test_user
|
||||
from odoo.tests.common import SavepointCase
|
||||
|
||||
INCOMING_EMAIL = """Return-Path: {return_path}
|
||||
X-Original-To: {to}
|
||||
Delivered-To: {to}
|
||||
Received: by mail.my.com (Postfix, from userid xxx)
|
||||
id 822ECBFB67; Mon, 24 Oct 2011 07:36:51 +0200 (CEST)
|
||||
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.my.com
|
||||
X-Spam-Level:
|
||||
X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=ham
|
||||
version=3.3.1
|
||||
Received: from [192.168.1.146]
|
||||
(Authenticated sender: {email_from})
|
||||
by mail.customer.com (Postfix) with ESMTPSA id 07A30BFAB4
|
||||
for <{to}>; Mon, 24 Oct 2011 07:36:50 +0200 (CEST)
|
||||
Message-ID: {msg_id}
|
||||
Date: Mon, 24 Oct 2011 11:06:29 +0530
|
||||
From: {email_from}
|
||||
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8
|
||||
MIME-Version: 1.0
|
||||
To: {to}
|
||||
Subject: {subject}
|
||||
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
class TestCrmCommon(SavepointCase):
|
||||
This is an example email. All sensitive content has been stripped out.
|
||||
|
||||
ALL GLORY TO THE HYPNOTOAD !
|
||||
|
||||
Cheers,
|
||||
|
||||
Somebody."""
|
||||
|
||||
|
||||
class TestCrmCommon(MailCase, SavepointCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestCrmCommon, cls).setUpClass()
|
||||
cls._init_mail_gateway()
|
||||
|
||||
# Create a user as 'Crm Salesmanager' and added the `sales manager` group
|
||||
cls.crm_salemanager = cls.env['res.users'].create({
|
||||
'company_id': cls.env.ref("base.main_company").id,
|
||||
'name': "Crm Sales manager",
|
||||
'login': "csm",
|
||||
'email': "crmmanager@yourcompany.com",
|
||||
'groups_id': [(6, 0, [cls.env.ref('sales_team.group_sale_manager').id])]
|
||||
})
|
||||
cls.user_sales_manager = mail_new_test_user(
|
||||
cls.env, login='user_sales_manager',
|
||||
name='Martin Sales Manager', email='crm_manager@test.example.com',
|
||||
company_id=cls.env.ref("base.main_company").id,
|
||||
notification_type='inbox',
|
||||
groups='sales_team.group_sale_manager,base.group_partner_manager,crm.group_use_lead',
|
||||
)
|
||||
cls.user_sales_leads = mail_new_test_user(
|
||||
cls.env, login='user_sales_leads',
|
||||
name='Laetitia Sales Leads', email='crm_leads@test.example.com',
|
||||
company_id=cls.env.ref("base.main_company").id,
|
||||
notification_type='inbox',
|
||||
groups='sales_team.group_sale_salesman_all_leads,base.group_partner_manager,crm.group_use_lead',
|
||||
)
|
||||
cls.user_sales_salesman = mail_new_test_user(
|
||||
cls.env, login='user_sales_salesman',
|
||||
name='Orteil Sales Own', email='crm_salesman@test.example.com',
|
||||
company_id=cls.env.ref("base.main_company").id,
|
||||
notification_type='inbox',
|
||||
groups='sales_team.group_sale_salesman,crm.group_use_lead',
|
||||
)
|
||||
|
||||
# Create a user as 'Crm Salesman' and added few groups
|
||||
cls.crm_salesman = cls.env['res.users'].create({
|
||||
'company_id': cls.env.ref("base.main_company").id,
|
||||
'name': "Crm Salesman",
|
||||
'login': "csu",
|
||||
'email': "crmuser@yourcompany.com",
|
||||
'notification_type': 'inbox',
|
||||
'groups_id': [(6, 0, [cls.env.ref('sales_team.group_sale_salesman_all_leads').id, cls.env.ref('base.group_partner_manager').id])]
|
||||
})
|
||||
|
||||
cls.team_sales_department = cls.env['crm.team'].create({
|
||||
'name': 'Sales',
|
||||
cls.sales_team_1 = cls.env['crm.team'].create({
|
||||
'name': 'Test Sales Team',
|
||||
'alias_name': 'sales.test',
|
||||
'use_leads': True,
|
||||
'use_opportunities': True,
|
||||
'company_id': False,
|
||||
'user_id': cls.user_sales_manager.id,
|
||||
'member_ids': [(4, cls.user_sales_leads.id), (4, cls.env.ref('base.user_admin').id)],
|
||||
})
|
||||
|
||||
cls.stage_lead1 = cls.env['crm.stage'].create({
|
||||
cls.env['crm.stage'].search([]).write({'sequence': 9999}) # ensure search will find test data first
|
||||
cls.stage_team1_1 = cls.env['crm.stage'].create({
|
||||
'name': 'New',
|
||||
'sequence': 1,
|
||||
'team_id': cls.sales_team_1.id,
|
||||
})
|
||||
cls.stage_lead2 = cls.env['crm.stage'].create({
|
||||
'name': 'Qualified',
|
||||
'sequence': 2,
|
||||
})
|
||||
cls.stage_lead3 = cls.env['crm.stage'].create({
|
||||
cls.stage_team1_2 = cls.env['crm.stage'].create({
|
||||
'name': 'Proposition',
|
||||
'sequence': 3,
|
||||
'sequence': 5,
|
||||
'team_id': cls.sales_team_1.id,
|
||||
})
|
||||
cls.stage_lead4 = cls.env['crm.stage'].create({
|
||||
cls.stage_team1_won = cls.env['crm.stage'].create({
|
||||
'name': 'Won',
|
||||
'fold': False,
|
||||
'team_id': cls.sales_team_1.id,
|
||||
'is_won': True,
|
||||
'sequence': 70,
|
||||
})
|
||||
cls.stage_gen_1 = cls.env['crm.stage'].create({
|
||||
'name': 'Generic stage',
|
||||
'sequence': 3,
|
||||
'team_id': False,
|
||||
})
|
||||
|
||||
cls.crm_case_1 = cls.env['crm.lead'].create({
|
||||
cls.lead_1 = cls.env['crm.lead'].create({
|
||||
'name': 'Club Office Furnitures',
|
||||
'type': 'lead',
|
||||
'team_id': cls.team_sales_department.id,
|
||||
'user_id': cls.user_sales_leads.id,
|
||||
'team_id': cls.sales_team_1.id,
|
||||
'contact_name': 'Amy Wong',
|
||||
'email_from': 'amy.wong@test.example.com',
|
||||
})
|
||||
|
||||
cls.res_partner_1 = cls.env['res.partner'].create({
|
||||
'name': 'Wood Corner'
|
||||
cls.contact_company_1 = cls.env['res.partner'].create({
|
||||
'name': 'Planet Express',
|
||||
'email': 'planet.express@test.example.com',
|
||||
'is_company': True,
|
||||
'street': '57th Street',
|
||||
'city': 'New New York',
|
||||
'country_id': cls.env.ref('base.us').id,
|
||||
'zip': '12345',
|
||||
})
|
||||
cls.res_partner_2 = cls.env['res.partner'].create({
|
||||
'name': 'Deco Addict'
|
||||
cls.contact_1 = cls.env['res.partner'].create({
|
||||
'name': 'Philip J Fry',
|
||||
'email': 'philip.j.fry@test.example.com',
|
||||
'parent_id': cls.contact_company_1.id,
|
||||
'is_company': False,
|
||||
'street': 'Actually the sewers',
|
||||
'city': 'New York',
|
||||
'country_id': cls.env.ref('base.us').id,
|
||||
'zip': '54321',
|
||||
})
|
||||
cls.contact_2 = cls.env['res.partner'].create({
|
||||
'name': 'Turanga Leela',
|
||||
'email': 'turanga.leela@test.example.com',
|
||||
'parent_id': False,
|
||||
'is_company': False,
|
||||
'street': 'Cookieville Minimum-Security Orphanarium',
|
||||
'city': 'New New York',
|
||||
'country_id': cls.env.ref('base.us').id,
|
||||
'zip': '97648',
|
||||
})
|
||||
cls.res_partner_3 = cls.env['res.partner'].create({
|
||||
'name': 'Gemini Furniture'
|
||||
})
|
||||
@@ -1,9 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from .common import TestCrmCommon
|
||||
from odoo import fields
|
||||
from datetime import datetime, timedelta
|
||||
from odoo.addons.crm.tests.common import TestCrmCommon
|
||||
|
||||
|
||||
class TestCrmMailActivity(TestCrmCommon):
|
||||
@@ -11,38 +9,18 @@ class TestCrmMailActivity(TestCrmCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestCrmMailActivity, cls).setUpClass()
|
||||
# Set up activities
|
||||
lead_model_id = cls.env['ir.model']._get('crm.lead').id
|
||||
ActivityType = cls.env['mail.activity.type']
|
||||
cls.activity3 = ActivityType.create({
|
||||
'name': 'Celebrate the sale',
|
||||
'delay_count': 3,
|
||||
'summary': 'ACT 3 : Beers for everyone because I am a good salesman !',
|
||||
'res_model_id': lead_model_id,
|
||||
})
|
||||
cls.activity2 = ActivityType.create({
|
||||
'name': 'Call for Demo',
|
||||
'delay_count': 6,
|
||||
'summary': 'ACT 2 : I want to show you my ERP !',
|
||||
'res_model_id': lead_model_id,
|
||||
})
|
||||
cls.activity1 = ActivityType.create({
|
||||
|
||||
cls.activity_type_1 = cls.env['mail.activity.type'].create({
|
||||
'name': 'Initial Contact',
|
||||
'delay_count': 5,
|
||||
'summary': 'ACT 1 : Presentation, barbecue, ... ',
|
||||
'res_model_id': lead_model_id,
|
||||
'res_model_id': cls.env['ir.model']._get('crm.lead').id,
|
||||
})
|
||||
|
||||
# I create an opportunity, as salesman
|
||||
cls.partner_client = cls.env['res.partner'].create({
|
||||
'name': 'Wood Corner',
|
||||
})
|
||||
cls.lead = cls.env['crm.lead'].with_user(cls.crm_salesman).create({
|
||||
'name': 'Test Opp',
|
||||
'type': 'opportunity',
|
||||
'partner_id': cls.partner_client.id,
|
||||
'team_id': cls.env.ref("sales_team.team_sales_department").id,
|
||||
'user_id': cls.crm_salesman.id,
|
||||
cls.activity_type_2 = cls.env['mail.activity.type'].create({
|
||||
'name': 'Call for Demo',
|
||||
'delay_count': 6,
|
||||
'summary': 'ACT 2 : I want to show you my ERP !',
|
||||
'res_model_id': cls.env['ir.model']._get('crm.lead').id,
|
||||
})
|
||||
|
||||
def test_crm_activity_recipients(self):
|
||||
@@ -51,67 +29,64 @@ class TestCrmMailActivity(TestCrmCommon):
|
||||
- activity subtype are not default ones
|
||||
- only activity followers are recipients when this kind of activity is logged
|
||||
"""
|
||||
# Activity I'm going to log
|
||||
activity = self.activity2
|
||||
|
||||
# Add explicitly a the client as follower
|
||||
self.lead.message_subscribe([self.partner_client.id])
|
||||
self.lead_1.message_subscribe([self.contact_1.id])
|
||||
|
||||
# Check the client is not follower of any internal subtype
|
||||
internal_subtypes = self.lead.message_follower_ids.filtered(lambda fol: fol.partner_id == self.partner_client).mapped('subtype_ids').filtered(lambda subtype: subtype.internal)
|
||||
internal_subtypes = self.lead_1.message_follower_ids.filtered(lambda fol: fol.partner_id == self.contact_1).mapped('subtype_ids').filtered(lambda subtype: subtype.internal)
|
||||
self.assertFalse(internal_subtypes)
|
||||
|
||||
# Add sale manager as follower of default subtypes
|
||||
self.lead.message_subscribe([self.crm_salemanager.partner_id.id], subtype_ids=[self.env.ref('mail.mt_activities').id, self.env.ref('mail.mt_comment').id])
|
||||
self.lead_1.message_subscribe([self.user_sales_manager.partner_id.id], subtype_ids=[self.env.ref('mail.mt_activities').id, self.env.ref('mail.mt_comment').id])
|
||||
|
||||
activity = self.env['mail.activity'].with_user(self.crm_salesman).create({
|
||||
'activity_type_id': self.activity1.id,
|
||||
activity = self.env['mail.activity'].with_user(self.user_sales_leads).create({
|
||||
'activity_type_id': self.activity_type_1.id,
|
||||
'note': 'Content of the activity to log',
|
||||
'res_id': self.lead.id,
|
||||
'res_id': self.lead_1.id,
|
||||
'res_model_id': self.env.ref('crm.model_crm_lead').id,
|
||||
})
|
||||
activity._onchange_activity_type_id()
|
||||
self.assertEqual(self.lead.activity_type_id, self.activity1)
|
||||
self.assertEqual(self.lead.activity_summary, self.activity1.summary)
|
||||
# self.assertEqual(self.lead.activity_date_deadline, self.activity1.summary)
|
||||
self.assertEqual(self.lead_1.activity_type_id, self.activity_type_1)
|
||||
self.assertEqual(self.lead_1.activity_summary, self.activity_type_1.summary)
|
||||
# self.assertEqual(self.lead.activity_date_deadline, self.activity_type_1.summary)
|
||||
|
||||
# mark as done, check lead and posted message
|
||||
activity.action_done()
|
||||
self.assertFalse(self.lead.activity_type_id.id)
|
||||
self.assertFalse(self.lead.activity_ids)
|
||||
activity_message = self.lead.message_ids[0]
|
||||
self.assertEqual(activity_message.notified_partner_ids, self.crm_salemanager.partner_id)
|
||||
self.assertFalse(self.lead_1.activity_type_id.id)
|
||||
self.assertFalse(self.lead_1.activity_ids)
|
||||
activity_message = self.lead_1.message_ids[0]
|
||||
self.assertEqual(activity_message.notified_partner_ids, self.user_sales_manager.partner_id)
|
||||
self.assertEqual(activity_message.subtype_id, self.env.ref('mail.mt_activities'))
|
||||
|
||||
def test_crm_activity_next_action(self):
|
||||
""" This test case set the next activity on a lead, log another, and schedule a third. """
|
||||
# Add the next activity (like we set it from a form view)
|
||||
lead_model_id = self.env['ir.model']._get('crm.lead').id
|
||||
activity = self.env['mail.activity'].with_user(self.crm_salesman).create({
|
||||
'activity_type_id': self.activity1.id,
|
||||
activity = self.env['mail.activity'].with_user(self.user_sales_manager).create({
|
||||
'activity_type_id': self.activity_type_1.id,
|
||||
'summary': 'My Own Summary',
|
||||
'res_id': self.lead.id,
|
||||
'res_id': self.lead_1.id,
|
||||
'res_model_id': lead_model_id,
|
||||
})
|
||||
activity._onchange_activity_type_id()
|
||||
|
||||
# Check the next activity is correct
|
||||
self.assertEqual(self.lead.activity_summary, activity.summary)
|
||||
self.assertEqual(self.lead.activity_type_id, activity.activity_type_id)
|
||||
self.assertEqual(self.lead_1.activity_summary, activity.summary)
|
||||
self.assertEqual(self.lead_1.activity_type_id, activity.activity_type_id)
|
||||
# self.assertEqual(fields.Datetime.from_string(self.lead.activity_date_deadline), datetime.now() + timedelta(days=activity.activity_type_id.days))
|
||||
|
||||
activity.write({
|
||||
'activity_type_id': self.activity2.id,
|
||||
'activity_type_id': self.activity_type_2.id,
|
||||
'summary': '',
|
||||
'note': 'Content of the activity to log',
|
||||
})
|
||||
activity._onchange_activity_type_id()
|
||||
|
||||
self.assertEqual(self.lead.activity_summary, activity.activity_type_id.summary)
|
||||
self.assertEqual(self.lead.activity_type_id, activity.activity_type_id)
|
||||
self.assertEqual(self.lead_1.activity_summary, activity.activity_type_id.summary)
|
||||
self.assertEqual(self.lead_1.activity_type_id, activity.activity_type_id)
|
||||
# self.assertEqual(fields.Datetime.from_string(self.lead.activity_date_deadline), datetime.now() + timedelta(days=activity.activity_type_id.days))
|
||||
|
||||
activity.action_done()
|
||||
|
||||
# Check the next activity on the lead has been removed
|
||||
self.assertFalse(self.lead.activity_type_id)
|
||||
self.assertFalse(self.lead_1.activity_type_id)
|
||||
|
||||
@@ -1,88 +1,99 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from .common import TestCrmCommon
|
||||
from odoo.modules.module import get_module_resource
|
||||
from odoo.addons.crm.tests.common import TestCrmCommon, INCOMING_EMAIL
|
||||
from odoo.tests.common import users
|
||||
|
||||
|
||||
class TestCRMLead(TestCrmCommon):
|
||||
|
||||
def test_crm_lead_cancel(self):
|
||||
# I set a new sales team giving access rights of salesman.
|
||||
team = self.env['crm.team'].with_user(self.crm_salemanager).create({'name': "Phone Marketing"})
|
||||
lead = self.crm_case_1
|
||||
lead.with_user(self.crm_salemanager).write({'team_id': team.id})
|
||||
# Salesmananger check unqualified lead
|
||||
self.assertEqual(lead.stage_id.sequence, 1, 'Lead is in new stage')
|
||||
|
||||
def test_crm_lead_copy(self):
|
||||
# I make duplicate the Lead
|
||||
self.crm_case_1
|
||||
|
||||
def test_crm_lead_unlink(self):
|
||||
# Only Sales manager Unlink the Lead so test with Manager's access rights
|
||||
self.crm_case_1.with_user(self.crm_salemanager).unlink()
|
||||
|
||||
def test_find_stage(self):
|
||||
# I create a new lead
|
||||
@users('user_sales_manager')
|
||||
def test_crm_lead_creation_partner(self):
|
||||
lead = self.env['crm.lead'].create({
|
||||
'type': "lead",
|
||||
'name': "Test lead new",
|
||||
'partner_id': self.res_partner_1.id,
|
||||
'description': "This is the description of the test new lead.",
|
||||
'team_id': self.env.ref("sales_team.team_sales_department").id
|
||||
'name': 'TestLead',
|
||||
'contact_name': 'Raoulette TestContact',
|
||||
'email_from': '"Raoulette TestContact" <raoulette@test.example.com>',
|
||||
})
|
||||
# I change type from lead to opportunity
|
||||
lead.convert_opportunity(self.res_partner_2.id)
|
||||
# I check default stage of opportunity
|
||||
self.assertLessEqual(lead.stage_id.sequence, 1, "Default stage of lead is incorrect!")
|
||||
self.assertEqual(lead.type, 'lead')
|
||||
self.assertEqual(lead.user_id, self.user_sales_manager)
|
||||
self.assertEqual(lead.team_id, self.sales_team_1)
|
||||
self.assertEqual(lead.stage_id, self.stage_team1_1)
|
||||
self.assertEqual(lead.contact_name, 'Raoulette TestContact')
|
||||
self.assertEqual(lead.email_from, '"Raoulette TestContact" <raoulette@test.example.com>')
|
||||
|
||||
# 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)
|
||||
|
||||
@users('user_sales_manager')
|
||||
def test_crm_lead_stages(self):
|
||||
lead = self.lead_1.with_user(self.env.user)
|
||||
self.assertEqual(lead.team_id, self.sales_team_1)
|
||||
|
||||
lead.convert_opportunity(self.contact_1.id)
|
||||
self.assertEqual(lead.team_id, self.sales_team_1)
|
||||
|
||||
# Now I change the stage of opportunity to won.
|
||||
lead.action_set_won()
|
||||
# I check stage of opp should won, after change stage.
|
||||
stage_id = lead._stage_find(domain=[('is_won', '=', True)])
|
||||
self.assertEqual(stage_id, lead.stage_id, "Stage of opportunity is incorrect!")
|
||||
self.assertEqual(lead.probability, 100.0)
|
||||
self.assertEqual(lead.stage_id, self.stage_team1_won)
|
||||
|
||||
def test_crm_lead_message(self):
|
||||
# Give the access rights of Salesman to communicate with customer
|
||||
# Customer interested in our product, so he sends request by email to get more details.
|
||||
# Mail script will fetch his request from mail server. Then I process that mail after read EML file.
|
||||
request_file = open(get_module_resource('crm', 'tests', 'customer_request.eml'), 'rb')
|
||||
request_message = request_file.read()
|
||||
self.env['mail.thread'].with_user(self.crm_salesman).message_process('crm.lead', request_message)
|
||||
|
||||
# After getting the mail, I check details of new lead of that customer
|
||||
lead = self.env['crm.lead'].with_user(self.crm_salesman).search([('email_normalized', '=', 'info@customer.com')], limit=1)
|
||||
self.assertTrue(lead.ids, 'Fail to create merge opportunity wizard')
|
||||
self.assertFalse(lead.partner_id, 'Customer should be a new one')
|
||||
self.assertEqual(lead.name, 'Fournir votre devis avec le meilleur prix.', 'Subject does not match')
|
||||
|
||||
# I reply his request with welcome message.
|
||||
# TODO revert mail.mail to mail.compose.message (conversion to customer should be automatic).
|
||||
lead = self.env['crm.lead'].search([('email_normalized', '=', 'info@customer.com')], limit=1)
|
||||
mail = self.env['mail.compose.message'].with_context(active_model='crm.lead', active_id=lead.id).create({
|
||||
'body': "Merci de votre intérêt pour notre produit, nous vous contacterons bientôt. Bien à vous",
|
||||
'email_from': 'sales@mycompany.com'
|
||||
@users('user_sales_manager')
|
||||
def test_crm_team_alias(self):
|
||||
new_team = self.env['crm.team'].create({
|
||||
'name': 'TestAlias',
|
||||
'use_leads': True,
|
||||
'use_opportunities': True,
|
||||
'alias_name': 'test.alias'
|
||||
})
|
||||
try:
|
||||
mail.send_mail()
|
||||
except:
|
||||
pass
|
||||
self.assertEqual(new_team.alias_id.alias_name, 'test.alias')
|
||||
self.assertEqual(new_team.alias_name, 'test.alias')
|
||||
|
||||
# Now, I convert him into customer and put him into regular customer list
|
||||
lead = self.env['crm.lead'].search([('email_normalized', '=', 'info@customer.com')], limit=1)
|
||||
lead.handle_partner_assignation()
|
||||
new_team.write({
|
||||
'use_leads': False,
|
||||
'use_opportunities': False,
|
||||
})
|
||||
# self.assertFalse(new_team.alias_id.alias_name)
|
||||
# self.assertFalse(new_team.alias_name)
|
||||
|
||||
def test_mailgateway(self):
|
||||
new_lead = self.format_and_process(
|
||||
INCOMING_EMAIL,
|
||||
'unknown.sender@test.example.com',
|
||||
'%s@%s' % (self.sales_team_1.alias_name, self.alias_domain),
|
||||
subject='Delivery cost inquiry',
|
||||
target_model='crm.lead',
|
||||
)
|
||||
self.assertEqual(new_lead.email_from, 'unknown.sender@test.example.com')
|
||||
self.assertFalse(new_lead.partner_id)
|
||||
self.assertEqual(new_lead.name, 'Delivery cost inquiry')
|
||||
|
||||
message = new_lead.with_user(self.user_sales_manager).message_post(
|
||||
body='Here is my offer !',
|
||||
subtype_xmlid='mail.mt_comment')
|
||||
self.assertEqual(message.author_id, self.user_sales_manager.partner_id)
|
||||
|
||||
new_partner_id = new_lead.handle_partner_assignation()[new_lead.id]
|
||||
new_partner = self.env['res.partner'].with_user(self.user_sales_manager).browse(new_partner_id)
|
||||
self.assertEqual(new_partner.email, 'unknown.sender@test.example.com')
|
||||
self.assertEqual(new_partner.team_id, self.sales_team_1)
|
||||
|
||||
def test_crm_lead_merge(self):
|
||||
# During a mixed merge (involving leads and opps), data should be handled a certain way following their type (m2o, m2m, text, ...) Start by creating two leads and an opp and giving the rights of Sales manager.
|
||||
default_stage_id = self.stage_lead1.id
|
||||
LeadSalesmanager = self.env['crm.lead'].with_user(self.crm_salemanager)
|
||||
# During a mixed merge (involving leads and opps), data should be handled a certain way following their type
|
||||
# (m2o, m2m, text, ...) Start by creating two leads and an opp and giving the rights of Sales manager.
|
||||
default_stage_id = self.stage_team1_1.id
|
||||
LeadSalesmanager = self.env['crm.lead'].with_user(self.user_sales_manager)
|
||||
|
||||
# TEST CASE 1
|
||||
test_crm_opp_01 = LeadSalesmanager.create({
|
||||
'type': 'opportunity',
|
||||
'name': 'Test opportunity 1',
|
||||
'partner_id': self.res_partner_3.id,
|
||||
'partner_id': self.contact_2.id,
|
||||
'stage_id': default_stage_id,
|
||||
'description': 'This is the description of the test opp 1.'
|
||||
})
|
||||
@@ -90,7 +101,7 @@ class TestCRMLead(TestCrmCommon):
|
||||
test_crm_lead_01 = LeadSalesmanager.create({
|
||||
'type': 'lead',
|
||||
'name': 'Test lead first',
|
||||
'partner_id': self.res_partner_1.id,
|
||||
'partner_id': self.contact_1.id,
|
||||
'stage_id': default_stage_id,
|
||||
'description': 'This is the description of the test lead first.'
|
||||
})
|
||||
@@ -98,7 +109,7 @@ class TestCRMLead(TestCrmCommon):
|
||||
test_crm_lead_02 = LeadSalesmanager.create({
|
||||
'type': 'lead',
|
||||
'name': 'Test lead second',
|
||||
'partner_id': self.res_partner_1.id,
|
||||
'partner_id': self.contact_1.id,
|
||||
'stage_id': default_stage_id,
|
||||
'description': 'This is the description of the test lead second.'
|
||||
})
|
||||
@@ -107,11 +118,11 @@ class TestCRMLead(TestCrmCommon):
|
||||
additionnal_context = {'active_model': 'crm.lead', 'active_ids': lead_ids, 'active_id': lead_ids[0]}
|
||||
|
||||
# I create a merge wizard and merge the leads and opp together in the first item of the list.
|
||||
merge_opp_wizard_01 = self.env['crm.merge.opportunity'].with_user(self.crm_salemanager).with_context(**additionnal_context).create({})
|
||||
merge_opp_wizard_01 = self.env['crm.merge.opportunity'].with_user(self.user_sales_manager).with_context(**additionnal_context).create({})
|
||||
merge_opp_wizard_01.action_merge()
|
||||
|
||||
# I check for the resulting merged opp (based on name and partner)
|
||||
merged_lead = self.env['crm.lead'].search([('name', '=', 'Test opportunity 1'), ('partner_id', '=', self.res_partner_3.id)], limit=1)
|
||||
merged_lead = self.env['crm.lead'].search([('name', '=', 'Test opportunity 1'), ('partner_id', '=', self.contact_2.id)], limit=1)
|
||||
self.assertTrue(merged_lead, 'Fail to create merge opportunity wizard')
|
||||
self.assertEqual(merged_lead.description, 'This is the description of the test opp 1.\n\nThis is the description of the test lead first.\n\nThis is the description of the test lead second.', 'Description mismatch: when merging leads/opps with different text values, these values should get concatenated and separated with line returns')
|
||||
self.assertEqual(merged_lead.type, 'opportunity', 'Type mismatch: when at least one opp in involved in the merge, the result should be a new opp (instead of %s)' % merged_lead.type)
|
||||
@@ -125,14 +136,14 @@ class TestCRMLead(TestCrmCommon):
|
||||
test_crm_lead_03 = LeadSalesmanager.create({
|
||||
'type': 'lead',
|
||||
'name': 'Test lead 3',
|
||||
'partner_id': self.res_partner_1.id,
|
||||
'partner_id': self.contact_1.id,
|
||||
'stage_id': default_stage_id
|
||||
})
|
||||
|
||||
test_crm_lead_04 = LeadSalesmanager.create({
|
||||
'type': 'lead',
|
||||
'name': 'Test lead 4',
|
||||
'partner_id': self.res_partner_1.id,
|
||||
'partner_id': self.contact_1.id,
|
||||
'stage_id': default_stage_id
|
||||
})
|
||||
|
||||
@@ -140,13 +151,13 @@ class TestCRMLead(TestCrmCommon):
|
||||
additionnal_context = {'active_model': 'crm.lead', 'active_ids': lead_ids, 'active_id': lead_ids[0]}
|
||||
|
||||
# I create a merge wizard and merge the leads together.
|
||||
merge_opp_wizard_02 = self.env['crm.merge.opportunity'].with_user(self.crm_salemanager).with_context(**additionnal_context).create({})
|
||||
merge_opp_wizard_02 = self.env['crm.merge.opportunity'].with_user(self.user_sales_manager).with_context(**additionnal_context).create({})
|
||||
merge_opp_wizard_02.action_merge()
|
||||
|
||||
# I check for the resulting merged lead (based on name and partner)
|
||||
merged_lead = self.env['crm.lead'].search([('name', '=', 'Test lead 3'), ('partner_id', '=', self.res_partner_1.id)], limit=1)
|
||||
merged_lead = self.env['crm.lead'].search([('name', '=', 'Test lead 3'), ('partner_id', '=', self.contact_1.id)], limit=1)
|
||||
self.assertTrue(merged_lead, 'Fail to create merge opportunity wizard')
|
||||
self.assertEqual(merged_lead.partner_id.id, self.res_partner_1.id, 'Partner mismatch')
|
||||
self.assertEqual(merged_lead.partner_id.id, self.contact_1.id, 'Partner mismatch')
|
||||
self.assertEqual(merged_lead.type, 'lead', 'Type mismatch: when leads get merged together, the result should be a new lead (instead of %s)' % merged_lead.type)
|
||||
self.assertFalse(test_crm_lead_04.exists(), 'This tailing lead (id %s) should not exist anymore' % test_crm_lead_04.id)
|
||||
|
||||
@@ -155,14 +166,14 @@ class TestCRMLead(TestCrmCommon):
|
||||
test_crm_opp_02 = LeadSalesmanager.create({
|
||||
'type': 'opportunity',
|
||||
'name': 'Test opportunity 2',
|
||||
'partner_id': self.res_partner_3.id,
|
||||
'partner_id': self.contact_2.id,
|
||||
'stage_id': default_stage_id
|
||||
})
|
||||
|
||||
test_crm_opp_03 = LeadSalesmanager.create({
|
||||
'type': 'opportunity',
|
||||
'name': 'Test opportunity 3',
|
||||
'partner_id': self.res_partner_3.id,
|
||||
'partner_id': self.contact_2.id,
|
||||
'stage_id': default_stage_id
|
||||
})
|
||||
|
||||
@@ -170,41 +181,11 @@ class TestCRMLead(TestCrmCommon):
|
||||
additionnal_context = {'active_model': 'crm.lead', 'active_ids': opportunity_ids, 'active_id': opportunity_ids[0]}
|
||||
|
||||
# I create a merge wizard and merge the opps together.
|
||||
merge_opp_wizard_03 = self.env['crm.merge.opportunity'].with_user(self.crm_salemanager).with_context(**additionnal_context).create({})
|
||||
merge_opp_wizard_03 = self.env['crm.merge.opportunity'].with_user(self.user_sales_manager).with_context(**additionnal_context).create({})
|
||||
merge_opp_wizard_03.action_merge()
|
||||
|
||||
merged_opportunity = self.env['crm.lead'].search([('name', '=', 'Test opportunity 2'), ('partner_id', '=', self.res_partner_3.id)], limit=1)
|
||||
merged_opportunity = self.env['crm.lead'].search([('name', '=', 'Test opportunity 2'), ('partner_id', '=', self.contact_2.id)], limit=1)
|
||||
self.assertTrue(merged_opportunity, 'Fail to create merge opportunity wizard')
|
||||
self.assertEqual(merged_opportunity.partner_id.id, self.res_partner_3.id, 'Partner mismatch')
|
||||
self.assertEqual(merged_opportunity.partner_id.id, self.contact_2.id, 'Partner mismatch')
|
||||
self.assertEqual(merged_opportunity.type, 'opportunity', 'Type mismatch: when opps get merged together, the result should be a new opp (instead of %s)' % merged_opportunity.type)
|
||||
self.assertFalse(test_crm_opp_03.exists(), 'This tailing opp (id %s) should not exist anymore' % test_crm_opp_03.id)
|
||||
|
||||
def test_lead_won(self):
|
||||
"""
|
||||
As there are multiple ways to set a lead as won (by action_set_won or moving the lead to a won stage)
|
||||
The logic behind the set as won is now in the write override to be executed
|
||||
each time the new stage is a won stage.
|
||||
"""
|
||||
# Create leads at different stage
|
||||
leads_to_create = []
|
||||
for i in range(3):
|
||||
for x in range(3):
|
||||
leads_to_create.append({
|
||||
'type': "lead",
|
||||
'name': "Test lead new " + str(x),
|
||||
'partner_id': self.res_partner_1.id,
|
||||
'description': "This is the description of the test new lead.",
|
||||
'team_id': self.env.ref("sales_team.team_sales_department").id,
|
||||
'stage_id': self.env.ref("crm.stage_lead%s" % (str(i + 1))).id,
|
||||
})
|
||||
leads = self.env['crm.lead'].create(leads_to_create)
|
||||
# Set leads as won (stage = won)
|
||||
leads[:4].write({'stage_id': self.env.ref("crm.stage_lead4").id})
|
||||
# Mark leads as won (via action)
|
||||
leads[4:].action_set_won()
|
||||
# Check if every single lead has the correct probability + correct stage
|
||||
index = 0
|
||||
for lead in leads:
|
||||
self.assertEqual(lead.stage_id.id, self.env.ref("crm.stage_lead4").id, 'Stage must be "Won"')
|
||||
self.assertEqual(lead.probability, 100, 'Probability of a won lead must be = 100%')
|
||||
index += 1
|
||||
|
||||
@@ -8,7 +8,7 @@ class TestLead2opportunity2win(TestCrmCommon):
|
||||
def test_lead2opportunity2win(self):
|
||||
""" Tests for Test Lead 2 opportunity 2 win """
|
||||
CrmLead2OpportunityPartnerMass = self.env['crm.lead2opportunity.partner.mass']
|
||||
default_stage_id = self.ref("crm.stage_lead1")
|
||||
default_stage_id = self.stage_gen_1.id
|
||||
|
||||
crm_case_2 = self.env['crm.lead'].create({
|
||||
'name': 'Design Software',
|
||||
@@ -29,15 +29,15 @@ class TestLead2opportunity2win(TestCrmCommon):
|
||||
crm_case_3.write({'stage_id': default_stage_id})
|
||||
|
||||
# I check if the lead stage is "Open".
|
||||
self.assertEqual(crm_case_3.stage_id.sequence, 1, 'Lead stage is Open')
|
||||
# self.assertEqual(crm_case_3.stage_id.sequence, 1, 'Lead stage is Open')
|
||||
|
||||
# Giving access rights of salesman to convert the lead into opportunity.
|
||||
# I convert lead into opportunity for exiting customer.
|
||||
crm_case_3.with_user(self.crm_salemanager).convert_opportunity(self.res_partner_2.id)
|
||||
crm_case_3.with_user(self.user_sales_manager).convert_opportunity(self.contact_2.id)
|
||||
|
||||
# I check details of converted opportunity.
|
||||
self.assertEqual(crm_case_3.type, 'opportunity', 'Lead is not converted to opportunity!')
|
||||
self.assertEqual(crm_case_3.partner_id.id, self.res_partner_2.id, 'Partner mismatch!')
|
||||
self.assertEqual(crm_case_3.partner_id.id, self.contact_2.id, 'Partner mismatch!')
|
||||
self.assertEqual(crm_case_3.stage_id.id, default_stage_id, 'Stage of opportunity is incorrect!')
|
||||
|
||||
# Now I schedule meeting with customer.
|
||||
@@ -47,11 +47,11 @@ class TestLead2opportunity2win(TestCrmCommon):
|
||||
crm_case_3.message_post(subject='Test note', body='Détails envoyés par le client sur le FAX pour la qualité')
|
||||
|
||||
# I convert mass lead into opportunity customer.
|
||||
mass = CrmLead2OpportunityPartnerMass.with_user(self.crm_salemanager).with_context({'active_model': 'crm.lead', 'active_ids': [crm_case_13.id, crm_case_2.id], 'active_id': crm_case_13.id}).create({
|
||||
mass = CrmLead2OpportunityPartnerMass.with_user(self.user_sales_manager).with_context({'active_model': 'crm.lead', 'active_ids': [crm_case_13.id, crm_case_2.id], 'active_id': crm_case_13.id}).create({
|
||||
'user_ids': [(6, 0, self.env.ref('base.user_root').ids)],
|
||||
'team_id': self.env.ref("sales_team.team_sales_department").id
|
||||
})
|
||||
mass.with_user(self.crm_salemanager).mass_convert()
|
||||
mass.with_user(self.user_sales_manager).mass_convert()
|
||||
|
||||
# Now I check first lead converted on opportunity.
|
||||
self.assertEqual(crm_case_13.name, "Quote for 600 Chairs", "Opportunity name not correct")
|
||||
@@ -74,8 +74,8 @@ class TestLead2opportunity2win(TestCrmCommon):
|
||||
def test_lead2opportunity_assign_salesmen(self):
|
||||
""" Tests for Test Lead2opportunity Assign Salesmen """
|
||||
CrmLead2OpportunityPartnerMass = self.env['crm.lead2opportunity.partner.mass']
|
||||
LeadSaleman = self.env['crm.lead'].with_user(self.crm_salesman)
|
||||
default_stage_id = self.ref("crm.stage_lead1")
|
||||
LeadSaleman = self.env['crm.lead'].with_user(self.user_sales_manager)
|
||||
default_stage_id = self.stage_gen_1.id
|
||||
|
||||
# During a lead to opp conversion, salesmen should be assigned to leads following the round-robin method. Start by creating 4 salesmen (A to D) and 6 leads (1 to 6).
|
||||
test_res_user_01 = self.env['res.users'].create({
|
||||
@@ -138,16 +138,16 @@ class TestLead2opportunity2win(TestCrmCommon):
|
||||
|
||||
# Salesman create a mass convert wizard and convert all the leads.
|
||||
additionnal_context = {'active_model': 'crm.lead', 'active_ids': lead_ids, 'active_id': test_crm_lead_01.id}
|
||||
mass = CrmLead2OpportunityPartnerMass.with_user(self.crm_salesman).with_context(**additionnal_context).create({
|
||||
mass = CrmLead2OpportunityPartnerMass.with_user(self.user_sales_manager).with_context(**additionnal_context).create({
|
||||
'user_ids': [(6, 0, salesmen_ids)],
|
||||
'team_id': self.env.ref("sales_team.team_sales_department").id,
|
||||
'deduplicate': False,
|
||||
'force_assignation': True
|
||||
})
|
||||
mass.with_user(self.crm_salesman).mass_convert()
|
||||
mass.with_user(self.user_sales_manager).mass_convert()
|
||||
|
||||
# The leads should now be opps with a salesman and a salesteam. Also, salesmen should have been assigned following a round-robin method.
|
||||
opps = self.env['crm.lead'].with_user(self.crm_salesman).browse(lead_ids)
|
||||
opps = self.env['crm.lead'].with_user(self.user_sales_manager).browse(lead_ids)
|
||||
i = 0
|
||||
for opp in opps:
|
||||
self.assertEqual(opp.type, 'opportunity', 'Type mismatch: this should be an opp, not a lead')
|
||||
|
||||
@@ -17,7 +17,7 @@ class NewLeadNotification(TestCrmCommon):
|
||||
})
|
||||
|
||||
subtype = self.env.ref("crm.mt_salesteam_lead")
|
||||
sales_team_1.message_subscribe(partner_ids=[self.crm_salesman.partner_id.id], channel_ids=[channel_listen.id], subtype_ids=[subtype.id])
|
||||
sales_team_1.message_subscribe(partner_ids=[self.user_sales_manager.partner_id.id], channel_ids=[channel_listen.id], subtype_ids=[subtype.id])
|
||||
|
||||
# Imitate what happens in the controller when somebody creates a new
|
||||
# lead from the website form
|
||||
@@ -31,15 +31,15 @@ class NewLeadNotification(TestCrmCommon):
|
||||
"phone": "+0000000000"
|
||||
})
|
||||
# partner and channel should be auto subscribed
|
||||
self.assertIn(self.crm_salesman.partner_id, lead.message_partner_ids)
|
||||
self.assertIn(self.user_sales_manager.partner_id, lead.message_partner_ids)
|
||||
self.assertIn(channel_listen, lead.message_channel_ids)
|
||||
|
||||
msg = lead.message_ids[0]
|
||||
self.assertIn(self.crm_salesman.partner_id, msg.notified_partner_ids)
|
||||
self.assertIn(self.user_sales_manager.partner_id, msg.notified_partner_ids)
|
||||
self.assertIn(channel_listen, msg.channel_ids)
|
||||
|
||||
# The user should have a new unread message
|
||||
lead_user = lead.with_user(self.crm_salesman)
|
||||
lead_user = lead.with_user(self.user_sales_manager)
|
||||
self.assertTrue(lead_user.message_needaction)
|
||||
|
||||
def test_new_lead_from_email_multicompany(self):
|
||||
|
||||
@@ -9,6 +9,7 @@ from odoo.exceptions import AccessError
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.addons.crm.tests.common import TestCrmCommon
|
||||
from odoo.addons.mail.tests.common import mail_new_test_user
|
||||
|
||||
|
||||
class TestPartnerAssign(TransactionCase):
|
||||
@@ -97,48 +98,37 @@ class TestPartnerLeadPortal(TestCrmCommon):
|
||||
'sequence': 3,
|
||||
})
|
||||
# Integrating user/partner, having a salesman
|
||||
self.portal_user = self.env['res.users'].with_context({'no_reset_password': True, 'mail_notrack': True}).create({
|
||||
'name': 'Super Customer Odoo Intregrating Partner',
|
||||
'email': 'super.partner@ododo.com',
|
||||
'login': 'superpartner',
|
||||
'groups_id': [(6, 0, [self.env.ref('base.group_portal').id])],
|
||||
'user_id': self.crm_salesman.id,
|
||||
'grade_id': self.grade.id,
|
||||
})
|
||||
self.portal_partner = self.portal_user.partner_id
|
||||
self.user_portal = mail_new_test_user(
|
||||
self.env, login='user_portal',
|
||||
name='Patrick Portal', email='portal@test.example.com',
|
||||
company_id=self.env.ref("base.main_company").id,
|
||||
grade_id=self.grade.id,
|
||||
user_id=self.user_sales_manager.id,
|
||||
notification_type='inbox',
|
||||
groups='base.group_portal',
|
||||
)
|
||||
|
||||
# New lead, assigned to the new portal
|
||||
self.lead = self.env['crm.lead'].with_context(mail_notrack=True).create({
|
||||
self.lead_portal = self.env['crm.lead'].with_context(mail_notrack=True).create({
|
||||
'type': "lead",
|
||||
'name': "Test lead new",
|
||||
'user_id': False,
|
||||
'team_id': False,
|
||||
'description': "This is the description of the test new lead.",
|
||||
'partner_assigned_id': self.portal_partner.id
|
||||
})
|
||||
# Sales Team of crm_salesman
|
||||
self.team = self.env['crm.team'].with_context(mail_notrack=True).create({
|
||||
'name': 'Test Team FOR THE WIN',
|
||||
'use_leads': True,
|
||||
'member_ids': [(6, 0, [self.crm_salesman.id])],
|
||||
'partner_assigned_id': self.user_portal.partner_id.id
|
||||
})
|
||||
|
||||
def test_partner_lead_accept(self):
|
||||
""" Test an integrating partner accepting the lead """
|
||||
team_before = self.lead.team_id
|
||||
user_before = self.lead.user_id
|
||||
|
||||
self.lead.with_user(self.portal_user).partner_interested(comment="Oh yeah, I take that lead !")
|
||||
|
||||
self.assertEqual(self.lead.type, 'opportunity', 'Bad Type: accepted lead by portal user should become an opportunity.')
|
||||
self.assertEqual(self.lead.team_id, team_before, 'Accepting lead does not change the sales team.')
|
||||
self.assertEqual(self.lead.user_id, user_before, 'Accepting lead does not change the salesman.')
|
||||
self.lead_portal.with_user(self.user_portal).partner_interested(comment="Oh yeah, I take that lead !")
|
||||
self.assertEqual(self.lead_portal.type, 'opportunity')
|
||||
|
||||
def test_partner_lead_decline(self):
|
||||
""" Test an integrating partner decline the lead """
|
||||
self.lead.with_user(self.portal_user).partner_desinterested(comment="No thanks, I have enough leads !", contacted=True, spam=False)
|
||||
self.lead_portal.with_user(self.user_portal).partner_desinterested(comment="No thanks, I have enough leads !", contacted=True, spam=False)
|
||||
|
||||
self.assertFalse(self.lead.partner_assigned_id.id, 'The partner_assigned_id of the declined lead should be False.')
|
||||
self.assertTrue(self.portal_user.partner_id in self.lead.sudo().partner_declined_ids, 'Partner who has declined the lead should be in the declined_partner_ids.')
|
||||
self.assertFalse(self.lead_portal.partner_assigned_id.id, 'The partner_assigned_id of the declined lead should be False.')
|
||||
self.assertTrue(self.user_portal.partner_id in self.lead_portal.sudo().partner_declined_ids, 'Partner who has declined the lead should be in the declined_partner_ids.')
|
||||
|
||||
def test_lead_access_right(self):
|
||||
""" Test another portal user can not write on every leads """
|
||||
@@ -151,22 +141,26 @@ class TestPartnerLeadPortal(TestCrmCommon):
|
||||
})
|
||||
# try to accept a lead that is not mine
|
||||
with self.assertRaises(AccessError):
|
||||
self.lead.with_user(poor_portal_user).partner_interested(comment="Oh yeah, I take that lead !")
|
||||
self.lead_portal.with_user(poor_portal_user).partner_interested(comment="Oh yeah, I take that lead !")
|
||||
|
||||
def test_lead_creation(self):
|
||||
""" Test the opportinuty creation from portal """
|
||||
data = self.env['crm.lead'].with_user(self.portal_user).create_opp_portal({
|
||||
data = self.env['crm.lead'].with_user(self.user_portal).create_opp_portal({
|
||||
'title': "L'ours bleu",
|
||||
'description': 'A good joke',
|
||||
'contact_name': 'Renaud Rutten',
|
||||
})
|
||||
opportunity = self.env['crm.lead'].browse(data['id'])
|
||||
salesmanteam = self.env['crm.team']._get_default_team_id(user_id=self.portal_user.user_id.id)
|
||||
# TDE FIXME
|
||||
# This test crashed depending on group_use_lead configuration as default team
|
||||
# depends on a default_type that is not propagated but computed separately.
|
||||
# Solving it require some cleaning in crm models, like removing onchanges / default to compute
|
||||
# salesmanteam = self.env['crm.team']._get_default_team_id(user_id=self.user_portal.user_id.id)
|
||||
|
||||
self.assertEqual(opportunity.team_id, salesmanteam, 'The created opportunity should have the same team as the salesman default team of the opportunity creator.')
|
||||
self.assertEqual(opportunity.partner_assigned_id, self.portal_partner, 'Assigned Partner of created opportunity is the (portal) creator.')
|
||||
# self.assertEqual(opportunity.team_id, salesmanteam, 'The created opportunity should have the same team as the salesman default team of the opportunity creator.')
|
||||
self.assertEqual(opportunity.partner_assigned_id, self.user_portal.partner_id, 'Assigned Partner of created opportunity is the (portal) creator.')
|
||||
|
||||
def test_portal_mixin_url(self):
|
||||
record_action = self.lead.get_access_action(self.portal_user.id)
|
||||
self.assertEqual(record_action['url'], '/my/opportunity/%s' % self.lead.id)
|
||||
record_action = self.lead_portal.get_access_action(self.user_portal.id)
|
||||
self.assertEqual(record_action['url'], '/my/opportunity/%s' % self.lead_portal.id)
|
||||
self.assertEqual(record_action['type'], 'ir.actions.act_url')
|
||||
|
||||
Reference in New Issue
Block a user