Skip to content
Snippets Groups Projects
Commit 118a065e authored by Florent de Labarre's avatar Florent de Labarre
Browse files

[FIX] im_livechat: bad coping of chatschript


Before this commit when you copy a chatbot script, the triggering answer are mixing.

- Create a chatbot
- Create a line A - question ligne with one response 1
- Create a line B - type text
- Create a line C - type text
- Save
- Invert line B and C
- on ligne C add response 1 in triggering answer
- Save
- Copy the script
--> Issue the response 1 in triggering answer is now in line B

closes odoo/odoo#133924

Signed-off-by: default avatarAlexandre Kühn (aku) <aku@odoo.com>
parent 6bb68d9f
Branches
Tags
No related merge requests found
......@@ -10,7 +10,7 @@ class ChatbotScript(models.Model):
_description = 'Chatbot Script'
_inherit = ['image.mixin', 'utm.source.mixin']
_rec_name = 'title'
_order = 'title'
_order = 'title, id'
# we keep a separate field for UI since name is manipulated by 'utm.source.mixin'
title = fields.Char('Title', required=True, translate=True, default="Chatbot")
......@@ -68,13 +68,15 @@ class ChatbotScript(models.Model):
if 'question_ids' in default:
return clone_chatbot_script
answers_map = {
original_answer: clone_answer
for clone_answer, original_answer
in zip(clone_chatbot_script.script_step_ids.answer_ids, self.script_step_ids.answer_ids)
}
original_steps = self.script_step_ids.sorted()
clone_steps = clone_chatbot_script.script_step_ids.sorted()
answers_map = {}
for clone_step, original_step in zip(clone_steps, original_steps):
for clone_answer, original_answer in zip(clone_step.answer_ids.sorted(), original_step.answer_ids.sorted()):
answers_map[original_answer] = clone_answer
for clone_step, original_step in zip(clone_chatbot_script.script_step_ids, self.script_step_ids):
for clone_step, original_step in zip(clone_steps, original_steps):
clone_step.write({
'triggering_answer_ids': [
(4, answer.id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment