-
-
Notifications
You must be signed in to change notification settings - Fork 711
/
hooks.py
25 lines (21 loc) · 906 Bytes
/
hooks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright 2022 ACSONE SA/NV
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from openupgradelib import openupgrade
from odoo import SUPERUSER_ID, api
def pre_init_hook(cr):
if openupgrade.table_exists(cr, "product_packaging_type"):
env = api.Environment(cr, SUPERUSER_ID, {})
# Former version of the module is present
models = [("product.packaging.type", "product.packaging.level")]
openupgrade.rename_models(env.cr, models)
fields = [
(
"product.packaging",
"product_packaging",
"packaging_type_id",
"packaging_level_id",
)
]
openupgrade.rename_fields(env, fields, no_deep=True)
modules = [("product_packaging_type", "product_packaging_level")]
openupgrade.update_module_names(env.cr, modules, merge_modules=True)