"""Backfill show_button NULL → True for overlay-mode configs.

show_button is defined on the model with default=True, but the default
only applies on create(). Rows that pre-date the field's introduction
(or that were inserted via raw SQL / data files without the column)
end up with NULL, which Odoo's ORM treats as False — so the floating
action button (FAB) silently disappears on the affiliate's overlay
embed even though the backend form shows the checkbox as the default.

Scope: only overlay configs read show_button; box/inline/grid don't.
Backfilling box/inline/grid would be a behaviour change for fields
that don't actually drive anything on those modes.
"""


def migrate(cr, version):
    cr.execute(
        """
        UPDATE affiliate_widget_config
        SET show_button = TRUE
        WHERE widget_mode = 'overlay'
          AND show_button IS NULL
        """,
    )
