mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[OU-ADD] rma: Migration scripts
This commit is contained in:
39
rma/migrations/13.0.1.0.0/post-migration.py
Normal file
39
rma/migrations/13.0.1.0.0/post-migration.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# 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
|
||||
from psycopg2 import sql
|
||||
|
||||
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
openupgrade.logged_query(
|
||||
env.cr,
|
||||
"""
|
||||
UPDATE account_move_line aml
|
||||
SET rma_id = ail.rma_id
|
||||
FROM account_invoice_line ail
|
||||
WHERE ail.id = aml.old_invoice_line_id""",
|
||||
)
|
||||
openupgrade.logged_query(
|
||||
env.cr,
|
||||
sql.SQL(
|
||||
"""
|
||||
UPDATE rma
|
||||
SET refund_id = am.id
|
||||
FROM account_move am
|
||||
WHERE am.old_invoice_id = {}
|
||||
"""
|
||||
).format(sql.Identifier(openupgrade.get_legacy_name("refund_id"))),
|
||||
)
|
||||
openupgrade.logged_query(
|
||||
env.cr,
|
||||
sql.SQL(
|
||||
"""
|
||||
UPDATE rma
|
||||
SET refund_line_id = aml.id
|
||||
FROM account_move_line aml
|
||||
WHERE aml.old_invoice_line_id = {}
|
||||
"""
|
||||
).format(sql.Identifier(openupgrade.get_legacy_name("refund_id"))),
|
||||
)
|
||||
11
rma/migrations/13.0.1.0.0/pre-migration.py
Normal file
11
rma/migrations/13.0.1.0.0/pre-migration.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# 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):
|
||||
openupgrade.rename_columns(
|
||||
env.cr, {"rma": [("refund_id", None), ("refund_line_id", None)]}
|
||||
)
|
||||
Reference in New Issue
Block a user