UnboundLocalError: local variable 'tax_types' referenced before assignment

File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v12_0/move_item_tax_to_item_tax_template.py”, line 73, in execute
item_tax_map, d.item_code, d.parenttype, d.parent, tax_types=tax_types)
UnboundLocalError: local variable ‘tax_types’ referenced before assignment

Can any one help with this? Am trying to convert a v10 db to v13 usisng bench migration. I have never seeing this error before and everything i try is not working.

I think i may have found a bug. As describe in my previous post, am trying to bench migrate a v10 site to v13 after restoreing a backup from v10 server to v13 server.
In move_item_tax_to_item_tax_template.py line 73 i note a loop used to recreate tax on item to tax template. i think this need some kind of validation to chake for item_tax configuration in previous data before tring to recreate the new tax tamplate table.

What did i do to fix my proble?
In my case i did not have any tax configuration on my items in version 10 so i remove the section of code in the patch to allow the migration to continue.

for dt in doctypes:
for d in frappe.db.sql(“”“select name, parenttype, parent, item_code, item_tax_rate from tab{0} Item
where ifnull(item_tax_rate, ‘’) not in (‘’, ‘{{}}’)
and item_tax_template is NULL”“”.format(dt), as_dict=1):
item_tax_map = json.loads(d.item_tax_rate)
item_tax_template_name = get_item_tax_template(item_tax_templates,
item_tax_map, d.item_code, d.parenttype, d.parent, tax_types=tax_types)
frappe.db.set_value(dt + " Item", d.name, “item_tax_template”, item_tax_template_name)
frappe.db.auto_commit_on_many_writes = False
settings = frappe.get_single(“Accounts Settings”)
settings.add_taxes_from_item_tax_template = 0
settings.determine_address_tax_category_from = “Billing Address”
settings.save()

Now am not recommnding this as solution however if you are stuck with migration error and you dont have tax configure in you old data you can try.