Field Renaming

From version 14.0 to version 15.0, in the module mail, in the model mail.activity.type the html field default_description has been renamed into default_note.

Analysis

...
---Fields in module 'mail'---
...
mail         / mail.activity.type       / default_description (html)    : DEL
...
mail         / mail.activity.type       / default_note (html)           : NEW

See Full V15 Analysis File.

Source Code Differences

Version 14.0

class MailActivityType(models.Model):

    _name = 'mail.activity.type'

    default_description = fields.Html(
        string="Default Description",
        translate=True,
    )

See Full V14 Code Source.

Version 15.0

class MailActivityType(models.Model):

    _name = 'mail.activity.type'

    default_note = fields.Html(
        string="Default Description",
        translate=True,
    )

See Full V15 Code Source.

Result without migration script / Expected Result

V14 table mail_activity_type

id

name

default_description

1

Email

<p>A description</p>

2

Call

3

Meeting

<p>Another description</p>

V15 table mail_activity_type (Without migration script)

id

name

default_note

1

Email

2

Call

3

Meeting

Problem : the data is lost during them migration process, and the new column is empty.

V15 table mail_activity_type (With migration script)

id

name

default_note

1

Email

<p>A description</p>

2

Call

3

Meeting

<p>Another description</p>

Contribution to OpenUpgrade

Update upgrade_analysis_work.txt file

  • Place side by side the two lines that correspond to the change

  • Mention the operation performed, starting with # DONE:

---Fields in module 'mail'---
mail         / mail.activity.type       / default_note (html)           : NEW
mail         / mail.activity.type       / default_description (html)    : DEL
# DONE: pre-migration, rename fields default_description -> default_note

See Full V15 Work Analysis File.

Write migration Script

in the pre-migration.py script add:

from openupgradelib import openupgrade

def _rename_fields(env):
    openupgrade.rename_fields(
        env,
        [
            (
                "mail.activity.type",
                "mail_activity_type",
                "default_description",
                "default_note",
            ),
        ]
    )

@openupgrade.migrate()
def migrate(env, version):
    _rename_fields(env)

See Full pre migration Script.