File: chatbot_common.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (66 lines) | stat: -rw-r--r-- 2,624 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.addons.im_livechat.tests.chatbot_common import ChatbotCase
from odoo.addons.mail.tests.common import mail_new_test_user


class CrmChatbotCase(ChatbotCase):

    @classmethod
    def setUpClass(cls):
        super(CrmChatbotCase, cls).setUpClass()

        cls.company_id = cls.env['res.company'].create({
            'name': 'Test Company',
            'country_id': cls.env.ref('base.be').id,
        })

        cls.user_public = mail_new_test_user(
            cls.env, login='user_public', groups='base.group_public', name='Public User')
        cls.user_portal = mail_new_test_user(
            cls.env, login='user_portal', groups='base.group_portal', name='Portal User',
            company_id=cls.company_id.id, email='portal@example.com')
        # update company_id on partner since the user's company is not propagated
        cls.user_portal.partner_id.write({'company_id': cls.company_id.id})

        cls.sale_team = cls.env['crm.team'].create({
            'name': 'Test Sale Team 1',
            'company_id': cls.company_id.id,
        })

        cls.sale_team_with_lead = cls.env['crm.team'].create({
            'name': 'Test Sale Team 2',
            'use_leads': True,
            'company_id': cls.company_id.id,
        })

        cls.step_dispatch_create_lead = cls.env['chatbot.script.answer'].sudo().create({
            'name': 'Create a lead',
            'script_step_id': cls.step_dispatch.id,
        })

        [
            cls.step_create_lead_email,
            cls.step_create_lead_phone,
            cls.step_create_lead,
        ] = cls.env['chatbot.script.step'].sudo().create([{
            'step_type': 'question_email',
            'message': 'Could you provide us your email please.',
            'sequence': 20,
            'triggering_answer_ids': [(4, cls.step_dispatch_create_lead.id)],
            'chatbot_script_id': cls.chatbot_script.id,
        }, {
            'step_type': 'question_phone',
            'message': 'Could you also provide your phone please.',
            'sequence': 21,
            'triggering_answer_ids': [(4, cls.step_dispatch_create_lead.id)],
            'chatbot_script_id': cls.chatbot_script.id,
        }, {
            'step_type': 'create_lead',
            'message': 'Thank you! A lead has been created.',
            'sequence': 22,
            'triggering_answer_ids': [(4, cls.step_dispatch_create_lead.id)],
            'crm_team_id': cls.sale_team.id,
            'chatbot_script_id': cls.chatbot_script.id,
        }])