forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.py
40 lines (38 loc) · 1.28 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
39
40
from odoo.tools.sql import column_exists
def _pre_init_global_discount_fields(cr):
if not column_exists(cr, "sale_order", "amount_global_discount"):
cr.execute(
"""
ALTER TABLE "sale_order"
ADD COLUMN "amount_global_discount" double precision DEFAULT 0
"""
)
cr.execute(
"""
ALTER TABLE "sale_order" ALTER COLUMN "amount_global_discount" DROP DEFAULT
"""
)
if not column_exists(cr, "sale_order", "amount_untaxed_before_global_discounts"):
cr.execute(
"""
ALTER TABLE "sale_order"
ADD COLUMN "amount_untaxed_before_global_discounts" double precision
"""
)
cr.execute(
"""
update sale_order set amount_untaxed_before_global_discounts = amount_untaxed
"""
)
if not column_exists(cr, "sale_order", "amount_total_before_global_discounts"):
cr.execute(
"""
ALTER TABLE "sale_order"
ADD COLUMN "amount_total_before_global_discounts" double precision
"""
)
cr.execute(
"""
update sale_order set amount_total_before_global_discounts = amount_total
"""
)