PURPOSE This commits adds a special step_type on the chatbot.script.steps that allows creating a crm.lead when reaching it. SPECS In addition, we let the end user configure in which crm.team that lead will land upon being created, making it possible to sort your leads based on previous questions. e.g: "In which country do you live" And based on the answer, you assign to a different sales.team. This commit comes with the necessary business code to make this feature work as well as some extra testing methods that ensure it is correctly implemented. Task-2030386 Part-of: odoo/odoo#84000 Co-authored-by: Patrick Hoste <pko@odoo.com> Co-authored-by: Aurélien Warnon <awa@odoo.com>
17 lines
608 B
Python
17 lines
608 B
Python
|
|
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import _, models
|
|
|
|
|
|
class ChatbotScriptStep(models.Model):
|
|
_inherit = 'chatbot.script.step'
|
|
|
|
def _chatbot_crm_prepare_lead_values(self, mail_channel, description):
|
|
values = super()._chatbot_crm_prepare_lead_values(mail_channel, description)
|
|
if mail_channel.livechat_visitor_id:
|
|
values['name'] = _("%s's New Lead", mail_channel.livechat_visitor_id.display_name)
|
|
values['visitor_ids'] = [(4, mail_channel.livechat_visitor_id.id)]
|
|
return values
|