Skip to content

[FIX] util.move_model: add version check for email.template#398

Open
MrRose765 wants to merge 1 commit intoodoo:masterfrom
odoo-dev:master-fix_move_model_mail_template-cymo
Open

[FIX] util.move_model: add version check for email.template#398
MrRose765 wants to merge 1 commit intoodoo:masterfrom
odoo-dev:master-fix_move_model_mail_template-cymo

Conversation

@MrRose765
Copy link
Copy Markdown

In this PR, the email_template update line was preventing people from creating an email.template custom model even though it is not used in standard since version 8.

Related issues :

@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Mar 26, 2026

Pull request status dashboard

Comment on lines +1271 to +1274
if version_gte("9.0"):
update_imd("mail.template", path="model")
else:
update_imd("email.template", path="model")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rename happens in 8.saas~6.1 (weird old versioning scheme). Thus when Odoo 9.0 is running it can still encounter it.
https://github.com/odoo/upgrade/blob/9d12694ed46d478492ad43611b284c754ae69ce6/migrations/mail/8.saas~6.1.0/pre-adapt-models.py#L5

Suggested change
if version_gte("9.0"):
update_imd("mail.template", path="model")
else:
update_imd("email.template", path="model")
update_imd("mail.template" if version_gte("10.0") else "email.template", path="model")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, wouldn't it be a problem for the upgrade scripts that call move_model in 9.* ? (In other words, after the rename but before 10.0)

Example : https://github.com/odoo/upgrade/blob/94b2c0207acb488ec68cdad65884e05773b8dab1/migrations/account_extra_reports/9.0.1.1/pre-get-from-account.py#L5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no perfect solution. When Odoo 9 is running both models could appear --before or after the rename. We could do as well:

    if not version_gte("10.0"):
        update_imd("mail.template", path="model")  # renamed in 8.saas~6.1
    update_imd("email.template", path="model")

This could cause issues if email.template was used in a DB in 8.0, but we get every few such upgrades nowadays, and they need other specific fixes anyway.

@aj-fuentes aj-fuentes requested a review from KangOl March 26, 2026 14:48
In [this](odoo/upgrade#4570 (comment)) PR, the [email_template update line](https://github.com/odoo/upgrade-util/blob/f97b7a28ef62fe4a7b0417854a904d132adc9882/src/util/modules.py#L1271) was preventing people from creating an `email.template` custom model even though it is not used in standard since version 8.

Related issues :
- [PR-specific](odoo/upgrade-specific#20818)
- [OPW-6055415](https://www.odoo.com/odoo/project/70/tasks/6055415)
@MrRose765 MrRose765 force-pushed the master-fix_move_model_mail_template-cymo branch from 652d65a to f7fa7cd Compare March 26, 2026 15:46
@KangOl
Copy link
Copy Markdown
Contributor

KangOl commented Mar 26, 2026

upgradeci retry with always only mail in all versions

@KangOl
Copy link
Copy Markdown
Contributor

KangOl commented Mar 26, 2026

upgradeci retry with always only account crm im_chat in 9.0 master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants