forked from OCA/OpenUpgrade
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OCA#2455 from ForgeFlow/13.0-fix-utm-avoid-foreign…
…_key-error [13.0][FIX] utm: avoid foreign_key error in utm_tag_rel table
- Loading branch information
Showing
3 changed files
with
22 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2020 ForgeFlow <http://www.forgeflow.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def update_utm_tag_rel(env): | ||
openupgrade.logged_query( | ||
env.cr, """ | ||
INSERT INTO utm_tag_rel (tag_id, campaign_id) | ||
SELECT rel.tag_id, mmc.campaign_id | ||
FROM mail_mass_mailing_tag_rel rel | ||
JOIN mail_mass_mailing_campaign mmc ON mmc.id = rel.campaign_id""" | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
if openupgrade.table_exists(env.cr, 'mail_mass_mailing_stage'): | ||
update_utm_tag_rel(env) |
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