fix: too many writes while renaming company abbreviation (#26142)
This commit is contained in:
parent
3b5978cdb8
commit
64c6b34b94
@ -407,8 +407,6 @@ def replace_abbr(company, old, new):
|
|||||||
|
|
||||||
frappe.only_for("System Manager")
|
frappe.only_for("System Manager")
|
||||||
|
|
||||||
frappe.db.set_value("Company", company, "abbr", new)
|
|
||||||
|
|
||||||
def _rename_record(doc):
|
def _rename_record(doc):
|
||||||
parts = doc[0].rsplit(" - ", 1)
|
parts = doc[0].rsplit(" - ", 1)
|
||||||
if len(parts) == 1 or parts[1].lower() == old.lower():
|
if len(parts) == 1 or parts[1].lower() == old.lower():
|
||||||
@ -419,11 +417,18 @@ def replace_abbr(company, old, new):
|
|||||||
doc = (d for d in frappe.db.sql("select name from `tab%s` where company=%s" % (dt, '%s'), company))
|
doc = (d for d in frappe.db.sql("select name from `tab%s` where company=%s" % (dt, '%s'), company))
|
||||||
for d in doc:
|
for d in doc:
|
||||||
_rename_record(d)
|
_rename_record(d)
|
||||||
|
try:
|
||||||
|
frappe.db.auto_commit_on_many_writes = 1
|
||||||
|
frappe.db.set_value("Company", company, "abbr", new)
|
||||||
|
for dt in ["Warehouse", "Account", "Cost Center", "Department",
|
||||||
|
"Sales Taxes and Charges Template", "Purchase Taxes and Charges Template"]:
|
||||||
|
_rename_records(dt)
|
||||||
|
frappe.db.commit()
|
||||||
|
|
||||||
for dt in ["Warehouse", "Account", "Cost Center", "Department",
|
except Exception:
|
||||||
"Sales Taxes and Charges Template", "Purchase Taxes and Charges Template"]:
|
frappe.log_error(title=_('Abbreviation Rename Error'))
|
||||||
_rename_records(dt)
|
finally:
|
||||||
frappe.db.commit()
|
frappe.db.auto_commit_on_many_writes = 0
|
||||||
|
|
||||||
|
|
||||||
def get_name_with_abbr(name, company):
|
def get_name_with_abbr(name, company):
|
||||||
|
Loading…
Reference in New Issue
Block a user