Skip to content
Open
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
31 changes: 22 additions & 9 deletions openupgrade_scripts/scripts/account/15.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,25 @@ def _fast_fill_account_move_amount_total_in_currency_signed(env):


def _fast_fill_account_move_line_tax_tag_invert(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_move_line
ADD COLUMN IF NOT EXISTS tax_tag_invert BOOL""",
has_mig18_tax_tag_invert = openupgrade.column_exists(
env.cr, "account_move_line", "mig18_tax_tag_invert"
)
if has_mig18_tax_tag_invert:
if not openupgrade.column_exists(env.cr, "account_move_line", "tax_tag_invert"):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_move_line
RENAME COLUMN mig18_tax_tag_invert TO tax_tag_invert""",
)
return
else:
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_move_line
ADD COLUMN IF NOT EXISTS tax_tag_invert BOOL""",
)
# 1. Invoices imported from other softwares might only have kept the tags,
# not the taxes
openupgrade.logged_query(
Expand Down Expand Up @@ -203,7 +216,8 @@ def _fast_fill_account_move_line_tax_tag_invert(env):
END
FROM account_move am
WHERE am.id = aml.move_id AND am.move_type != 'entry'
AND aml.tax_tag_invert IS NULL""",
AND aml.tax_tag_invert IS NULL
""",
)
# 3. For misc operations,
# cash basis entries and write-offs from the bank reconciliation widget
Expand All @@ -228,8 +242,7 @@ def _fast_fill_account_move_line_tax_tag_invert(env):
LEFT JOIN account_tax invoice_tax ON invoice_tax.id = atpl.invoice_tax_id
WHERE am.move_type = 'entry'
) sub
WHERE sub.id = aml.id AND aml.tax_tag_invert IS NULL
""",
WHERE sub.id = aml.id AND aml.tax_tag_invert IS NULL""",
)
openupgrade.logged_query(
env.cr,
Expand Down Expand Up @@ -402,4 +415,4 @@ def migrate(env, version):
_fill_res_company_account_journal_payment_accounts(env)
_fast_create_account_payment_outstanding_account_id(env)
_fill_account_tax_country_id(env)
_remove_table_constraints(env)
_remove_table_constraints(env)
Loading