mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
fix(setup): scope regional-tax-settings rollback to a savepoint (review)
from_detailed_data inserts tax templates/accounts before update_regional_tax_settings in the same transaction; a full frappe.db.rollback() on regional-setup failure discarded those templates while the wizard continued. Take a savepoint before the regional call and roll back only to it.
This commit is contained in:
@@ -120,6 +120,7 @@ def from_detailed_data(company_name, data):
|
|||||||
def update_regional_tax_settings(country, company):
|
def update_regional_tax_settings(country, company):
|
||||||
path = frappe.get_app_path("erpnext", "regional", frappe.scrub(country))
|
path = frappe.get_app_path("erpnext", "regional", frappe.scrub(country))
|
||||||
if os.path.exists(path.encode("utf-8")):
|
if os.path.exists(path.encode("utf-8")):
|
||||||
|
frappe.db.savepoint("regional_tax_settings")
|
||||||
try:
|
try:
|
||||||
module_name = f"erpnext.regional.{frappe.scrub(country)}.setup.update_regional_tax_settings"
|
module_name = f"erpnext.regional.{frappe.scrub(country)}.setup.update_regional_tax_settings"
|
||||||
frappe.get_attr(module_name)(country, company)
|
frappe.get_attr(module_name)(country, company)
|
||||||
@@ -127,7 +128,7 @@ def update_regional_tax_settings(country, company):
|
|||||||
pass
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
# Log error and ignore if failed to setup regional tax settings
|
# Log error and ignore if failed to setup regional tax settings
|
||||||
frappe.db.rollback()
|
frappe.db.rollback(save_point="regional_tax_settings")
|
||||||
frappe.log_error("Unable to setup regional tax settings")
|
frappe.log_error("Unable to setup regional tax settings")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user