-
-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3096 from hieu1211/v14_mig_sale_margin
[OU-ADD] sale_margin: migration script
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
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
26 changes: 26 additions & 0 deletions
26
openupgrade_scripts/scripts/sale_margin/14.0.1.0/pre-migration.py
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,26 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, installed_version): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE sale_order_line | ||
ADD COLUMN IF NOT EXISTS margin_percent double precision; | ||
ALTER TABLE sale_order | ||
ADD COLUMN IF NOT EXISTS margin_percent double precision; | ||
""", | ||
) | ||
|
||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE sale_order_line | ||
SET margin_percent = COALESCE(margin / NULLIF(price_subtotal, 0), 0); | ||
UPDATE sale_order | ||
SET margin_percent = COALESCE(margin / NULLIF(amount_untaxed, 0), 0); | ||
""", | ||
) |
12 changes: 12 additions & 0 deletions
12
openupgrade_scripts/scripts/sale_margin/14.0.1.0/upgrade_analysis_work.txt
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,12 @@ | ||
---Models in module 'sale_margin'--- | ||
---Fields in module 'sale_margin'--- | ||
sale_margin / sale.order / margin_percent (float) : NEW : function, stored | ||
sale_margin / sale.order.line / margin_percent (float) : NEW isfunction: function, stored | ||
# DONE: pre-migration fast filled | ||
|
||
sale_margin / sale.order.line / purchase_price (float) : now a function | ||
# NOTHING TO DO | ||
|
||
---XML records in module 'sale_margin'--- | ||
NEW ir.ui.view: sale_margin.sale_margin_sale_order_pivot | ||
# NOTHING TO DO |