Skip to content
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
14 changes: 14 additions & 0 deletions openupgrade_scripts/scripts/account/17.0.1.2/end-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ def _assign_journal_xmlids(env):
)


def _get_tax_invoice_description(old, lang_code, record):
return record.with_context(lang=lang_code)["description"]


def _translate_tax_invoice_label(env):
records = env["account.tax"].search([("invoice_label", "=", False)])
openupgrade.update_field_multilang(
records,
"invoice_label",
lambda old, a, k: _get_tax_invoice_description(old, a, k),
)


@openupgrade.migrate()
def migrate(env, version):
_assign_journal_xmlids(env)
_translate_tax_invoice_label(env)
20 changes: 13 additions & 7 deletions openupgrade_scripts/scripts/account/17.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,21 @@ def _convert_account_tax_description(env):
openupgrade.add_columns(
env, [(False, "invoice_label", "char", None, "account_tax")]
)
openupgrade.logged_query(
env.cr,
"""UPDATE account_tax
SET invoice_label = description
WHERE description IS NOT NULL;""",
)
convert_column_translatable(env.cr, "account_tax", "description", "jsonb")
convert_column_translatable(env.cr, "account_tax", "invoice_label", "jsonb")

env.cr.execute(
"""
SELECT name FROM ir_model_fields
WHERE model = 'account.tax'
AND name = 'description'
AND translate = TRUE
""",
)
description_translated_field = [field[0] for field in env.cr.fetchall()]

if not description_translated_field:
convert_column_translatable(env.cr, "account_tax", "description", "jsonb")
Comment on lines +88 to +89
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ở 16 description không được dịch, nếu cài l10n_multilang thì trường này sẽ được dịch.



def _am_create_delivery_date_column(env):
"""
Expand Down