-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] mail_environment: Keep existing settings at install of module
- Loading branch information
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import models | ||
from .hooks import post_init_hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def post_init_hook(env): | ||
# Migrate Outgoing Mail Server data | ||
env.cr.execute("SELECT * FROM ir_mail_server") | ||
for row in env.cr.dictfetchall(): | ||
mail_server = env["ir.mail_server"].search([("name", "=", row["name"])]) | ||
if not mail_server: | ||
continue | ||
for field_name, _options in env["ir.mail_server"]._server_env_fields.items(): | ||
if field_name in row: | ||
mail_server[field_name] = row[field_name] | ||
|
||
# Migrate Incoming Mail Server data | ||
env.cr.execute("SELECT * FROM fetchmail_server") | ||
for row in env.cr.dictfetchall(): | ||
mail_server = env["fetchmail.server"].search([("name", "=", row["name"])]) | ||
if not mail_server: | ||
continue | ||
for field_name, _options in env["fetchmail.server"]._server_env_fields.items(): | ||
if field_name in row: | ||
mail_server[field_name] = row[field_name] | ||