Skip to content

[19.0][MIG] im_livechat: chatbot_only_if_no_operator -> chatbot_enabled_condition#5642

Open
dnplkndll wants to merge 2 commits into
OCA:19.0from
ledoent:19.0-mig-im-livechat-chatbot-condition
Open

[19.0][MIG] im_livechat: chatbot_only_if_no_operator -> chatbot_enabled_condition#5642
dnplkndll wants to merge 2 commits into
OCA:19.0from
ledoent:19.0-mig-im-livechat-chatbot-condition

Conversation

@dnplkndll
Copy link
Copy Markdown

Summary

19.0 replaces the boolean im_livechat.channel.rule.chatbot_only_if_no_operator with a selection field chatbot_enabled_condition (always / only_if_no_operator / only_if_operator).

Migration

  • pre-migration.pyopenupgrade.rename_columns to preserve the legacy boolean column past ORM init.
  • post-migration.pyUPDATE im_livechat_channel_rule SET chatbot_enabled_condition = 'only_if_no_operator' WHERE <legacy column> IS TRUE. FALSE rows keep the ORM-set default of always.
  • Legacy column preserved for database_cleanup to pick up post-migration (per pedrobaeza policy on OpenUpgrade preserving information).

Test coverage

openupgrade_scripts/scripts/im_livechat/19.0.1.0/tests/test_im_livechat_migration.py:

  1. asserts at least one channel.rule has chatbot_enabled_condition='only_if_no_operator' after migration
  2. asserts the legacy column still exists in the schema (so database_cleanup can clear it)

openupgrade_scripts/scripts/im_livechat/tests/data_im_livechat_migration.py — 18.0 demo seed: sets chatbot_only_if_no_operator=True on at least one channel.rule so the post-migration UPDATE has rows to fire on.

What this PR does NOT touch

Per pedrobaeza policy ("OpenUpgrade preserves information; database_cleanup handles residuals"), these 19.0 changes in im_livechat are intentionally left alone:

  • Additive new tracking fields on discuss.channel (auto-populate at ORM init)
  • New models: im_livechat.channel.member.history, conversation.tag, expertise (additive)
  • DEL fields anonymous_name, livechat_active, image_128, input_placeholder — left for database_cleanup

Fork CI

Validated on fork's `Test OpenUpgrade migration` workflow (both base + enriched seeds passed): 2026-05-16T01:58Z.

docsource

docsource/modules180-190.rst updated — `im_livechat` marked Done so OCA CI's `Test OpenUpgrade migration` job includes the module in `$MODULES_NEW`.

@OCA-git-bot OCA-git-bot added mod:openupgrade_scripts Module openupgrade_scripts series:19.0 labels May 18, 2026
dnplkndll added 2 commits May 18, 2026 21:16
…ed_condition

19.0 replaces the boolean chatbot_only_if_no_operator on
im_livechat.channel.rule with a selection chatbot_enabled_condition
(values: always / only_if_no_operator / only_if_operator). Pre-migration
preserves the legacy boolean via rename_columns; post-migration maps
TRUE -> 'only_if_no_operator'. FALSE rows keep the default 'always'
set by ORM init.

Per-module tests/data_im_livechat_migration.py seeds 18.0 demo by
setting the boolean TRUE on at least one rule so the migration
UPDATEs fire on the OCA seed.

Test asserts: at least one rule has condition='only_if_no_operator'
after migration + legacy column survives for database_cleanup.

Other 19.0 changes in this module are additive (new tracking fields
on discuss.channel, new models im_livechat.channel.member.history /
conversation.tag / expertise) or DEL leftovers (anonymous_name,
livechat_active, image_128, input_placeholder) — all left to
database_cleanup per pedrobaeza policy.
Self-review fixes before OCA review:

- post-migration: defensive UPDATE on chatbot_enabled_condition IS NULL
  before the TRUE->only_if_no_operator mapping. Cheap insurance against
  rows that pre-date the ORM-init backfill (e.g. created via partial
  schema). Trim verbose docstring.
- data seed: replace UPDATE-by-MIN(id) with ORM create() on the demo
  im_livechat.channel.rule. The original silently no-ops if no rules
  exist in the seed DB; explicit create() guarantees the post-migration
  UPDATE has rows to fire on. Drops the AI-style preamble comment.
@dnplkndll dnplkndll force-pushed the 19.0-mig-im-livechat-chatbot-condition branch from 080fc41 to cf341e0 Compare May 19, 2026 01:16
@dnplkndll dnplkndll marked this pull request as ready for review May 19, 2026 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:openupgrade_scripts Module openupgrade_scripts series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants