Skip to content

[17.0][OU-FIX] sms: fill sms_sms.uuid per row before the ORM creates the column#23

Open
eantones wants to merge 1 commit into
17.0from
17.0-fix-sms-uuid-prefill
Open

[17.0][OU-FIX] sms: fill sms_sms.uuid per row before the ORM creates the column#23
eantones wants to merge 1 commit into
17.0from
17.0-fix-sms-uuid-prefill

Conversation

@eantones

Copy link
Copy Markdown
Member

Problem

The uuid field on sms.sms (new in 17.0) is declared with a callable default and a unique constraint:

uuid = fields.Char('UUID', copy=False, readonly=True, default=lambda self: uuid4().hex)
_sql_constraints = [('uuid_unique', 'unique(uuid)', 'UUID must be unique')]

The upgrade analysis flags both (uuid (char): NEW + NEW ir.model.constraint: sms.constraint_sms_sms_uuid_unique), but openupgrade_scripts/scripts/sms/17.0.3.0/ has no migration script. Without one, the ORM creates the missing column during the upgrade and evaluates the callable default once, so every pre-existing sms_sms row receives the same value and the uuid_unique constraint fails to install:

WARNING odoo.schema: Table 'sms_sms': unable to add constraint 'sms_sms_uuid_unique'

Observed on a real 14.0→18.0 chain: all pre-existing rows ended up sharing one uuid.

Fix

Add sms/17.0.3.0/pre-migration.py: pre-create the column if missing and backfill a deterministic per-row value (md5 over the row id — same 32-hex shape as uuid4().hex). The WHERE also breaks any duplicate group left by a previous upgrade run executed without this script, and makes the script idempotent.

sms.tracker.sms_uuid (also flagged) needs nothing: the model is new in 17.0, the table is created empty.

@eantones eantones added the oca-candidate Contains commits of ours that will be proposed to OCA at submit time. label Jul 20, 2026
…the column

The uuid field (new in 17.0) has a callable default and a unique
constraint, but no migration script fills it for pre-existing rows.
The ORM creates the column during the upgrade and evaluates the
default once, so every existing row gets the same value and the
uuid_unique constraint fails to install.

Pre-create the column and backfill a deterministic per-row value
(md5 over the id, same 32-hex shape as uuid4().hex). Also breaks any
duplicate group left by a previous upgrade run without this script.
@eantones
eantones force-pushed the 17.0-fix-sms-uuid-prefill branch from bad539a to 6df0ec7 Compare July 20, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oca-candidate Contains commits of ours that will be proposed to OCA at submit time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant