forked from shopinvader/odoo-shopinvader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.py
38 lines (29 loc) · 1.04 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from openupgradelib import openupgrade
from odoo import SUPERUSER_ID, api
_logger = logging.getLogger(__name__)
def _rename_applied_transaction_uuids(env):
openupgrade.rename_fields(
env,
[
(
"sale.order",
"sale_order",
"applied_transaction_uuids",
"applied_cart_api_transaction_uuids",
)
],
)
def pre_init_hook(cr):
cr.execute("SELECT name FROM ir_module_module WHERE name='sale_cart_rest_api';")
if cr.fetchall():
_logger.info("Rename sale_cart_rest_api to shopinvader_api_cart")
openupgrade.update_module_names(
cr, [("sale_cart_rest_api", "shopinvader_api_cart")], True
)
# Rename applied_transaction_uuids -> applied_cart_api_transaction_uuids
# Nothing done if column doesn't exist
env = api.Environment(cr, SUPERUSER_ID, {})
_rename_applied_transaction_uuids(env)