forked from faide/reporting-engine
-
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.
[OU-FIX] base_comment_template: Do on post + avoid conflicts
- Loading branch information
1 parent
2dd2457
commit e82f354
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
base_comment_template/migrations/13.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,24 @@ | ||
# Copyright 2020 NextERP Romania SRL | ||
# Copyright 2021 Tecnativa - Víctor Martínez | ||
# Copyright 2021 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
INSERT INTO base_comment_template_res_partner_rel | ||
(res_partner_id, base_comment_template_id) | ||
SELECT SPLIT_PART(ip.res_id, ',', 2)::int AS res_partner_id, | ||
SPLIT_PART(ip.value_reference, ',', 2)::int AS base_comment_template_id | ||
FROM ir_property ip | ||
JOIN ir_model_fields imf ON ip.fields_id = imf.id | ||
WHERE imf.name = 'property_comment_template_id' | ||
AND imf.model = 'res.partner' | ||
AND ip.res_id IS NOT NULL | ||
ON CONFLICT DO NOTHING | ||
""", | ||
) |