Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG][14.0] account_check_printing: Migration script #3044

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docsource/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
| |del| account_bank_statement_import | Adopted in OCA as account_statement_import |
+--------------------------------------------+-------------------------------------------------+
|account_check_printing | |
|account_check_printing | Done |
+--------------------------------------------+-------------------------------------------------+
|account_debit_note | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
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"
)
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):
tranngocson1996 marked this conversation as resolved.
Show resolved Hide resolved
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)
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']')
tranngocson1996 marked this conversation as resolved.
Show resolved Hide resolved
# 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