-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][IMP] sale_global_discount, added init hook to avoid memory iss…
…ues on big database installation
- Loading branch information
1 parent
257971e
commit ded6836
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import models | ||
from .hooks import _pre_init_global_discount_fields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
""" | ||
) |