Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,342 changes: 1,342 additions & 0 deletions docsource/modules190-200.rst

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions openupgrade_scripts/scripts/bus/20.0.1.0/upgrade_analysis.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---Models in module 'bus'---
---Fields in module 'bus'---
---XML records in module 'bus'---
DEL ir.model.access: bus.access_bus_bus
13 changes: 13 additions & 0 deletions openupgrade_scripts/scripts/bus/20.0.1.0/upgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---Models in module 'bus'---
---Fields in module 'bus'---
---XML records in module 'bus'---
DEL ir.model.access: bus.access_bus_bus

# NOTHING TO DO. bus 20.0 has no model or column changes. The deleted ir.model.access
# row is the ir.model.access to ir.access merge done in base (OCA OpenUpgrade PR #6068);
# bus no longer ships a security CSV. im_status was checked and is not a bus field.
# res.users.im_status and mail.guest.im_status changed from a non-stored Char to a
# non-stored Selection, so there is no column to convert. Stored presence remains
# mail.presence.status with the same keys online, away and offline. manual_im_status is
# unchanged. The old partner value bot was a non-stored compute on res.partner and that
# field was removed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---Models in module 'hr_livechat'---
---Fields in module 'hr_livechat'---
---XML records in module 'hr_livechat'---
DEL ir.ui.view: hr_livechat.discuss_channel_looking_for_help_view_search
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---Models in module 'hr_livechat'---
---Fields in module 'hr_livechat'---
---XML records in module 'hr_livechat'---
DEL ir.ui.view: hr_livechat.discuss_channel_looking_for_help_view_search

# NOTHING TO DO: the only change is removal of a search view for the deleted
# looking-for-help action. No table or column changes.
142 changes: 142 additions & 0 deletions openupgrade_scripts/scripts/im_livechat/20.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Copyright 2026 Odoo Community Association (OCA)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import logging

from openupgradelib import openupgrade

_logger = logging.getLogger(__name__)


def _preserve_chatbot_script_source(env):
"""Preserve chatbot.script source_id for the crm_livechat migration.

Copied from adekock11/OpenUpgrade#2 (cursor/crm-190-200-91bd). im_livechat
is updated before crm_livechat and drops source_id (the model no longer
inherits utm.source.mixin). crm_livechat post-migration reads
``ou_crm_livechat_chatbot_source`` to set crm.lead.utm_reference.
"""
cr = env.cr
cr.execute("SELECT state FROM ir_module_module WHERE name = %s", ("crm_livechat",))
row = cr.fetchone()
if not row or row[0] not in ("installed", "to upgrade", "to install"):
return
if not openupgrade.column_exists(cr, "chatbot_script", "source_id"):
return
openupgrade.logged_query(
cr,
"""
CREATE TABLE IF NOT EXISTS ou_crm_livechat_chatbot_source (
chatbot_script_id integer PRIMARY KEY,
source_id integer NOT NULL
)
""",
)
openupgrade.logged_query(
cr,
"""
INSERT INTO ou_crm_livechat_chatbot_source (chatbot_script_id, source_id)
SELECT id, source_id
FROM chatbot_script
WHERE source_id IS NOT NULL
ON CONFLICT (chatbot_script_id) DO NOTHING
""",
)
_logger.info(
"Saved %s chatbot.script source links for crm_livechat.",
cr.rowcount,
)


def _migrate_livechat_ratings(cr):
"""Ratings moved off ``rating.mixin`` onto ``discuss.channel.livechat_rating``.

19.0 stored the last rating as a float (1, 3 or 5) in ``rating_last_value``.
20.0 stores the same scale as a selection. ``im_livechat.channel.member.history``
no longer points at ``rating.rating``; its stored ``rating`` is recomputed
from ``livechat_rating`` when the module initializes. ``rating.rating``
rows themselves are left in place.
"""
if not openupgrade.column_exists(cr, "discuss_channel", "rating_last_value"):
return
if not openupgrade.column_exists(cr, "discuss_channel", "livechat_rating"):
openupgrade.logged_query(
cr,
"ALTER TABLE discuss_channel ADD COLUMN livechat_rating varchar",
)
openupgrade.logged_query(
cr,
"""
UPDATE discuss_channel
SET livechat_rating = CASE round(rating_last_value)
WHEN 1 THEN '1'
WHEN 3 THEN '3'
WHEN 5 THEN '5'
END
WHERE channel_type = 'livechat'
AND rating_last_value IS NOT NULL
AND round(rating_last_value) IN (1, 3, 5)
AND livechat_rating IS NULL
""",
)


def _map_waiting_status(cr):
"""The ``waiting`` livechat status ("Waiting for customer") was removed.

An open session becomes ``in_progress``. A closed session must have an
empty status (``livechat_end_dt`` / ``livechat_status`` check).
"""
if not openupgrade.column_exists(cr, "discuss_channel", "livechat_status"):
return
openupgrade.logged_query(
cr,
"""
UPDATE discuss_channel
SET livechat_status = CASE
WHEN livechat_end_dt IS NOT NULL THEN NULL
ELSE 'in_progress'
END
WHERE livechat_status = 'waiting'
""",
)


def _prepare_looking_for_help_date(cr):
"""The new check requires a timestamp exactly when status is ``need_help``.

Fill it before the constraint is added. The stored compute overwrites the
value with "now" during init, which is the same information 19.0 kept
(the field did not exist, so the original request time is unknown).
"""
if not openupgrade.column_exists(cr, "discuss_channel", "livechat_status"):
return
if not openupgrade.column_exists(
cr, "discuss_channel", "livechat_looking_for_help_since_dt"
):
openupgrade.logged_query(
cr,
"""
ALTER TABLE discuss_channel
ADD COLUMN livechat_looking_for_help_since_dt timestamp
""",
)
openupgrade.logged_query(
cr,
"""
UPDATE discuss_channel
SET livechat_looking_for_help_since_dt = (now() AT TIME ZONE 'UTC')
WHERE livechat_status = 'need_help'
AND livechat_looking_for_help_since_dt IS NULL
""",
)


@openupgrade.migrate()
def migrate(env, version):
# Must run before the column is dropped, and before the rating/status
# updates. Same SQL as OpenUpgrade PR #2.
_preserve_chatbot_script_source(env)
_migrate_livechat_ratings(env.cr)
_map_waiting_status(env.cr)
_prepare_looking_for_help_date(env.cr)
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---Models in module 'im_livechat'---
obsolete model im_livechat.conversation.tag
---Fields in module 'im_livechat'---
im_livechat / chatbot.script / source_id (many2one) : DEL relation: utm.source, required
im_livechat / discuss.channel / livechat_conversation_tag_ids (many2many): DEL relation: im_livechat.conversation.tag
im_livechat / discuss.channel / livechat_looking_for_help_since_dt (datetime): NEW isfunction: function, stored
im_livechat / discuss.channel / livechat_operator_id (many2one): DEL relation: res.partner
im_livechat / discuss.channel / livechat_rating (selection) : NEW selection_keys: ['1', '3', '5']
im_livechat / discuss.channel / livechat_status (selection) : selection_keys removed: [waiting]
im_livechat / discuss.channel / rating_last_text (selection) : DEL selection_keys: function
im_livechat / discuss.channel / rating_last_value (float) : DEL
im_livechat / im_livechat.channel / rating_ids (one2many) : DEL relation: rating.rating
im_livechat / im_livechat.channel / rating_percentage_satisfaction (integer): type is now 'float' ('integer')
im_livechat / im_livechat.channel.member.history / rating (float) : is now stored
im_livechat / im_livechat.channel.member.history / rating (float) : not related anymore
im_livechat / im_livechat.channel.member.history / rating (float) : now a function
im_livechat / im_livechat.channel.member.history / rating (float) : selection_keys is now '['1', '3', '5']' ('False')
im_livechat / im_livechat.channel.member.history / rating (float) : type is now 'selection' ('float')
im_livechat / im_livechat.channel.member.history / rating_id (many2one) : DEL relation: rating.rating
im_livechat / im_livechat.conversation.tag / color (integer) : DEL
im_livechat / im_livechat.conversation.tag / conversation_ids (many2many) : DEL relation: discuss.channel
im_livechat / im_livechat.conversation.tag / name (char) : DEL required
im_livechat / im_livechat.expertise / color (integer) : NEW
im_livechat / mail.message / chatbot_message_ids (one2many): NEW relation: chatbot.message
---XML records in module 'im_livechat'---
NEW ir.access: im_livechat.access_chatbot_message_user
NEW ir.access: im_livechat.access_chatbot_script_answer_user
NEW ir.access: im_livechat.access_chatbot_script_step_user
NEW ir.access: im_livechat.access_chatbot_script_user
NEW ir.access: im_livechat.access_im_livechat_channel_member_history_user
NEW ir.access: im_livechat.access_livechat_channel_manager
NEW ir.access: im_livechat.access_livechat_channel_rule_manager
NEW ir.access: im_livechat.access_livechat_channel_rule_user
NEW ir.access: im_livechat.access_livechat_channel_user
NEW ir.access: im_livechat.access_livechat_expertise_internal_user
NEW ir.access: im_livechat.access_livechat_expertise_livechat_manager
NEW ir.access: im_livechat.access_livechat_support_report_channel
NEW ir.access: im_livechat.ir_rule_discuss_call_history_im_livechat_group_user
NEW ir.access: im_livechat.ir_rule_discuss_channel_im_livechat_group_user
NEW ir.access: im_livechat.ir_rule_discuss_channel_member_im_livechat_group_user
NEW ir.actions.act_window: im_livechat.im_livechat_channel_config_action
DEL ir.actions.act_window: im_livechat.discuss_channel_looking_for_help_action
DEL ir.actions.act_window: im_livechat.livechat_conversation_tag_action
NEW ir.actions.act_window.view: im_livechat.im_livechat_channel_config_action_kanban
NEW ir.actions.act_window.view: im_livechat.im_livechat_channel_config_action_list
DEL ir.actions.act_window.view: im_livechat.discuss_channel_looking_for_help_action_form
DEL ir.actions.act_window.view: im_livechat.discuss_channel_looking_for_help_action_kanban
DEL ir.actions.act_window.view: im_livechat.discuss_channel_looking_for_help_action_list
DEL ir.model.access: im_livechat.access_chatbot_message_user
DEL ir.model.access: im_livechat.access_chatbot_script_answer
DEL ir.model.access: im_livechat.access_chatbot_script_answer_user
DEL ir.model.access: im_livechat.access_chatbot_script_step_user
DEL ir.model.access: im_livechat.access_chatbot_script_user
DEL ir.model.access: im_livechat.access_im_livechat_channel_member_history_user
DEL ir.model.access: im_livechat.access_livechat_channel_manager
DEL ir.model.access: im_livechat.access_livechat_channel_rule_manager
DEL ir.model.access: im_livechat.access_livechat_channel_rule_user
DEL ir.model.access: im_livechat.access_livechat_channel_user
DEL ir.model.access: im_livechat.access_livechat_conversation_tag_livechat_manager
DEL ir.model.access: im_livechat.access_livechat_conversation_tag_livechat_user
DEL ir.model.access: im_livechat.access_livechat_expertise_internal_user
DEL ir.model.access: im_livechat.access_livechat_expertise_livechat_manager
DEL ir.model.access: im_livechat.access_livechat_support_report_channel
NEW ir.model.constraint: im_livechat.constraint_discuss_channel_livechat_looking_for_help_since_dt_constraint
NEW ir.model.constraint: im_livechat.constraint_discuss_channel_livechat_rating_constraint
DEL ir.model.constraint: im_livechat.constraint_discuss_channel_livechat_operator_id
DEL ir.model.constraint: im_livechat.constraint_im_livechat_conversation_tag_name_unique
DEL ir.rule: im_livechat.ir_rule_discuss_call_history_im_livechat_group_user (noupdate)
DEL ir.rule: im_livechat.ir_rule_discuss_channel_im_livechat_group_user (noupdate)
DEL ir.rule: im_livechat.ir_rule_discuss_channel_member_im_livechat_group_user (noupdate)
NEW ir.ui.menu: im_livechat.livechat_channels_config
DEL ir.ui.menu: im_livechat.menu_livechat_all_conversations
DEL ir.ui.menu: im_livechat.menu_livechat_conversation_tag
DEL ir.ui.menu: im_livechat.menu_livechat_looking_for_help
NEW ir.ui.view: im_livechat.im_livechat_channel_config_view_kanban
NEW ir.ui.view: im_livechat.im_livechat_channel_view_list
DEL ir.ui.view: im_livechat.discuss_channel_looking_for_help_view_kanban
DEL ir.ui.view: im_livechat.discuss_channel_looking_for_help_view_list
DEL ir.ui.view: im_livechat.discuss_channel_looking_for_help_view_search
DEL ir.ui.view: im_livechat.im_livechat_channel_conversation_tag_view_form
DEL ir.ui.view: im_livechat.im_livechat_channel_conversation_tag_view_list
NEW utm.source: im_livechat.utm_source_chatbot
Loading