forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.py
33 lines (28 loc) · 1.16 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
# Copyright 2023 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import SUPERUSER_ID, api
def _post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
ICP = env["ir.config_parameter"]
previous_value = ICP.get_param("sale_planner_calendar.action_open_sale_order")
if previous_value:
ICP.set_param(
"sale_planner_calendar.action_open_sale_order_bak", previous_value
)
ICP.set_param(
"sale_planner_calendar.action_open_sale_order",
"sale_order_product_picker.action_open_picker_views",
)
def _uninstall_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
ICP = env["ir.config_parameter"]
previous_value = ICP.get_param("sale_planner_calendar.action_open_sale_order_bak")
if previous_value:
ICP.set_param("sale_planner_calendar.action_open_sale_order", previous_value)
else:
ICP.search(
[
("key", "=", "sale_planner_calendar.action_open_sale_order"),
("value", "=", "sale_order_product_picker.action_open_picker_views"),
]
).unlink()