feat: allow bulk rename with merge

This commit is contained in:
Devin Slauenwhite 2021-10-04 14:15:54 -04:00
parent 1027185320
commit a8347c0b27

View file

@ -458,7 +458,7 @@ def bulk_rename(doctype, rows=None, via_console = False):
"""Bulk rename documents
:param doctype: DocType to be renamed
:param rows: list of documents as `((oldname, newname), ..)`"""
:param rows: list of documents as `((oldname, newname, merge(optional)), ..)`"""
if not rows:
frappe.throw(_("Please select a valid csv file with data"))
@ -471,8 +471,9 @@ def bulk_rename(doctype, rows=None, via_console = False):
for row in rows:
# if row has some content
if len(row) > 1 and row[0] and row[1]:
merge = True if len(row) > 2 and (row[2] == "1" or row[2].lower() == "true") else False
try:
if rename_doc(doctype, row[0], row[1]):
if rename_doc(doctype, row[0], row[1], merge=merge):
msg = _("Successful: {0} to {1}").format(row[0], row[1])
frappe.db.commit()
else: