Skip to content
Open
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
12 changes: 12 additions & 0 deletions openupgrade_scripts/scripts/base/18.0.1.3/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ def _fix_company_layout_background(cr):
"WHERE layout_background='Geometric'",
)

# trobz migrate
def _fix_barcode_json_value_compatibility(cr):
""" """
openupgrade.logged_query(
cr,
r"""UPDATE res_partner
SET barcode = '"' || barcode || '"'
WHERE barcode IS NOT NULL
AND (barcode !~ '^\s*[{[].*[]}]$');""",
)


@openupgrade.migrate(use_env=False)
def migrate(cr, version):
Expand All @@ -79,3 +90,4 @@ def migrate(cr, version):
_fix_list_view_mode(cr)
_fix_serbian_res_lang_record(cr)
_fix_company_layout_background(cr)
_fix_barcode_json_value_compatibility(cr)
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright 2025 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import logging

from openupgradelib import openupgrade


Expand All @@ -12,10 +14,36 @@ def _update_existing_tax_accounts(env):
fr_companies = env["res.company"].search([("chart_template", "=", "fr")])
for company in fr_companies:
account_44551 = env.ref("account." + str(company.id) + "_pcg_44551", False)

# trobz migrate: somehow, xml_id in tax account 445511 doesn't have correct
# xml_id as above, Trobz search code and company directly here
account_44551_backup = env["account.account"].search(
[("code", "=", "445510"), ("company_ids", "in", company.id)], limit=1
)

if not account_44551:
logging.info(
f"not found account_44551, account_44551_backup: {account_44551_backup}"
)
account_44551 = account_44551_backup

if account_44551:
account_44551.account_type = "liability_payable"
account_44551.non_trade = True

account_44567 = env.ref("account." + str(company.id) + "_pcg_44567", False)

# trobz migrate: somehow, xml_id in tax account 445511 doesn't have correct
# xml_id as above, Trobz search code and company directly here
account_44567_backup = env["account.account"].search(
[("code", "=", "445670"), ("company_ids", "in", company.id)], limit=1
)
if not account_44567:
logging.info(
f"not found account_44567, account_44567_backup: {account_44551_backup}"
)
account_44567 = account_44567_backup

if account_44567:
account_44567.account_type = "asset_receivable"
account_44567.non_trade = True
Expand Down
Loading
Loading