Víctor Martínez
4 years ago
11 changed files with 78 additions and 101 deletions
-
12base_comment_template/README.rst
-
2base_comment_template/__manifest__.py
-
25base_comment_template/migrations/13.0.1.0.0/pre-migration.py
-
12base_comment_template/migrations/13.0.2.0.0/pre-migration.py
-
21base_comment_template/migrations/13.0.3.0.0/pre-migration.py
-
26base_comment_template/migrations/14.0.1.0.0/pre-migration.py
-
29base_comment_template/migrations/14.0.2.0.0/post-migration.py
-
30base_comment_template/migrations/14.0.2.0.0/pre-migration.py
-
3base_comment_template/models/base_comment_template.py
-
8base_comment_template/static/description/index.html
-
9base_comment_template/tests/test_base_comment_template.py
@ -1,25 +0,0 @@ |
|||
# Copyright 2020 NextERP Romania SRL |
|||
# Copyright 2021 Tecnativa - Víctor Martínez |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|||
from openupgradelib import openupgrade |
|||
|
|||
|
|||
@openupgrade.migrate() |
|||
def migrate(env, version): |
|||
# Not tested |
|||
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 |
|||
JOIN res_partner rp ON rp.id = SPLIT_PART(ip.res_id, ',', 2)::int |
|||
JOIN base_comment_template bct |
|||
ON bct.id = SPLIT_PART(ip.value_reference, ',', 2)::int |
|||
WHERE imf.name = 'property_comment_template_id' |
|||
AND imf.model = 'res.partner' |
|||
""", |
|||
) |
@ -1,12 +0,0 @@ |
|||
# Copyright 2021 Tecnativa - Víctor Martínez |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from openupgradelib import openupgrade # pylint: disable=W7936 |
|||
|
|||
field_renames = [ |
|||
("base.comment.template", "base_comment_template", "priority", "sequence"), |
|||
] |
|||
|
|||
|
|||
@openupgrade.migrate() |
|||
def migrate(env, version): |
|||
openupgrade.rename_fields(env, field_renames) |
@ -1,21 +0,0 @@ |
|||
# Copyright 2021 Tecnativa - Pedro M: Baeza |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from openupgradelib import openupgrade # pylint: disable=W7936 |
|||
|
|||
|
|||
@openupgrade.migrate() |
|||
def migrate(env, version): |
|||
if openupgrade.table_exists(env.cr, "base_comment_template_res_partner_rel"): |
|||
# Swap column names, as they were incorrect |
|||
env.cr.execute( |
|||
"ALTER TABLE base_comment_template_res_partner_rel " |
|||
"RENAME base_comment_template_id TO temp" |
|||
) |
|||
env.cr.execute( |
|||
"ALTER TABLE base_comment_template_res_partner_rel " |
|||
"RENAME res_partner_id TO base_comment_template_id" |
|||
) |
|||
env.cr.execute( |
|||
"ALTER TABLE base_comment_template_res_partner_rel " |
|||
"RENAME temp TO res_partner_id" |
|||
) |
@ -1,26 +0,0 @@ |
|||
# Copyright 2021 Tecnativa - Víctor Martínez |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|||
from openupgradelib import openupgrade |
|||
|
|||
field_renames = [ |
|||
("base.comment.template", "base_comment_template", "priority", "sequence"), |
|||
] |
|||
|
|||
|
|||
@openupgrade.migrate() |
|||
def migrate(env, version): |
|||
# Not tested |
|||
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' |
|||
""", |
|||
) |
|||
openupgrade.rename_fields(env, field_renames) |
@ -0,0 +1,29 @@ |
|||
# 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 |
|||
|
|||
from odoo.tools import parse_version |
|||
|
|||
|
|||
@openupgrade.migrate() |
|||
def migrate(env, version): |
|||
if parse_version(version) == parse_version("14.0.1.0.0"): |
|||
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 |
|||
JOIN res_partner rp ON rp.id = SPLIT_PART(ip.res_id, ',', 2)::int |
|||
JOIN base_comment_template bct |
|||
ON bct.id = SPLIT_PART(ip.value_reference, ',', 2)::int |
|||
WHERE imf.name = 'property_comment_template_id' |
|||
AND imf.model = 'res.partner' |
|||
AND ip.res_id IS NOT NULL |
|||
ON CONFLICT DO NOTHING |
|||
""", |
|||
) |
@ -0,0 +1,30 @@ |
|||
# 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 |
|||
|
|||
from odoo.tools import parse_version |
|||
|
|||
field_renames = [ |
|||
("base.comment.template", "base_comment_template", "priority", "sequence"), |
|||
] |
|||
|
|||
|
|||
@openupgrade.migrate() |
|||
def migrate(env, version): |
|||
if parse_version(version) == parse_version("14.0.1.0.0"): |
|||
openupgrade.rename_fields(env, field_renames) |
|||
if openupgrade.table_exists(env.cr, "base_comment_template_res_partner_rel"): |
|||
# Swap column names, as they were incorrect |
|||
env.cr.execute( |
|||
"ALTER TABLE base_comment_template_res_partner_rel " |
|||
"RENAME base_comment_template_id TO temp" |
|||
) |
|||
env.cr.execute( |
|||
"ALTER TABLE base_comment_template_res_partner_rel " |
|||
"RENAME res_partner_id TO base_comment_template_id" |
|||
) |
|||
env.cr.execute( |
|||
"ALTER TABLE base_comment_template_res_partner_rel " |
|||
"RENAME temp TO res_partner_id" |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue