-
-
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.
[MIG] account_check_printing: Migration script
- Loading branch information
tranngocson1996
committed
Jan 10, 2022
1 parent
57db16f
commit 67e01a6
Showing
4 changed files
with
77 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
8 changes: 8 additions & 0 deletions
8
openupgrade_scripts/scripts/account_check_printing/14.0.1.0/post-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,8 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.load_data( | ||
env.cr, "account_check_printing", "14.0.1.0/noupdate_changes.xml" | ||
) |
48 changes: 48 additions & 0 deletions
48
openupgrade_scripts/scripts/account_check_printing/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,48 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def add_preferred_payment_method_id_field_account_move(env): | ||
if not openupgrade.column_exists( | ||
env.cr, "account_move", "preferred_payment_method_id" | ||
): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE account_move | ||
ADD COLUMN preferred_payment_method_id integer | ||
""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE account_move am | ||
SET preferred_payment_method_id = CAST( | ||
SPLIT_PART(ip.value_reference, ',', 2) AS int) | ||
FROM ir_property ip | ||
WHERE ip.company_id = am.company_id AND | ||
ip.res_id = CONCAT('res.partner,', am.partner_id) AND | ||
ip.name = 'property_payment_method_id' | ||
""", | ||
) | ||
|
||
|
||
def fill_res_company_account_check_printing_layout(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE res_company | ||
SET account_check_printing_layout = 'disabled' | ||
WHERE account_check_printing_layout != 'disabled' AND | ||
account_check_printing_layout IS NOT NULL | ||
""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.copy_columns( | ||
env.cr, | ||
{"res_company": [("account_check_printing_layout", None, None)]}, | ||
) | ||
add_preferred_payment_method_id_field_account_move(env) | ||
fill_res_company_account_check_printing_layout(env) |
20 changes: 20 additions & 0 deletions
20
openupgrade_scripts/scripts/account_check_printing/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,20 @@ | ||
---Models in module 'account_check_printing'--- | ||
---Fields in module 'account_check_printing'--- | ||
account_check_printing / account.move / preferred_payment_method_id (many2one): NEW relation: account.payment.method, isfunction: function, stored | ||
# DONE: pre-migration: created preferred_payment_method_id column and set the value | ||
|
||
account_check_printing / account.payment / check_amount_in_words (char) : now a function | ||
account_check_printing / account.payment / check_number (char) : now a function | ||
# NOTHING TO DO: automated field filling | ||
|
||
account_check_printing / res.company / account_check_printing_layout (selection): selection_keys is now '['disabled']' ('['action_print_check_bottom', 'action_print_check_middle', 'action_print_check_top', 'disabled']') | ||
# DONE: pre-migration: ensuring records are filled with default value ('disabled') | ||
|
||
account_check_printing / res.partner / property_payment_method_id (many2one): NEW relation: account.payment.method, hasdefault | ||
# NOTHING TO DO | ||
|
||
---XML records in module 'account_check_printing'--- | ||
NEW ir.model.access: account_check_printing.access_print_prenumbered_checks | ||
NEW ir.ui.view: account_check_printing.view_account_invoice_filter | ||
NEW ir.ui.view: account_check_printing.view_partner_property_form | ||
# NOTHING TO DO: noupdate="0" records |