-
-
Notifications
You must be signed in to change notification settings - Fork 184
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 #45 from Tecnativa/8.0-migration_sale_condition
[ADD] sale_comment_template: add migration scripts
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
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 @@ | ||
account-invoice-reporting |
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
32 changes: 32 additions & 0 deletions
32
sale_comment_template/migrations/8.0.1.0.0/post-migration.py
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,32 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Tecnativa - Vicent Cubells | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
def migrate_comment_template(cr): | ||
cr.execute( | ||
""" | ||
UPDATE sale_order so | ||
SET comment_template1_id = bct.condition_template_id, | ||
note1 = bct.text | ||
FROM base_comment_template bct | ||
WHERE bct.id = so.condition_template_id | ||
AND bct.position = 'before_lines' | ||
""") | ||
cr.execute( | ||
""" | ||
UPDATE sale_order so | ||
SET comment_template2_id = bct.condition_template_id, | ||
note2 = bct.text | ||
FROM base_comment_template bct | ||
WHERE bct.id = so.condition_template_id | ||
AND bct.position = 'after_lines' | ||
""") | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(cr, version): | ||
if openupgrade.column_exists(cr, 'sale_order', 'condition_template_id'): | ||
migrate_comment_template(cr) |