Merge pull request #32491 from ruthra-kumar/performance_issue_on_migrate_remarks_patch
refactor: remove duplicate entries on remarks migration patch
This commit is contained in:
commit
777ed10e21
@ -3,6 +3,29 @@ from frappe import qb
|
||||
from frappe.utils import create_batch
|
||||
|
||||
|
||||
def remove_duplicate_entries(pl_entries):
|
||||
unique_vouchers = set()
|
||||
for x in pl_entries:
|
||||
unique_vouchers.add(
|
||||
(x.company, x.account, x.party_type, x.party, x.voucher_type, x.voucher_no, x.gle_remarks)
|
||||
)
|
||||
|
||||
entries = []
|
||||
for x in unique_vouchers:
|
||||
entries.append(
|
||||
frappe._dict(
|
||||
company=x[0],
|
||||
account=x[1],
|
||||
party_type=x[2],
|
||||
party=x[3],
|
||||
voucher_type=x[4],
|
||||
voucher_no=x[5],
|
||||
gle_remarks=x[6],
|
||||
)
|
||||
)
|
||||
return entries
|
||||
|
||||
|
||||
def execute():
|
||||
if frappe.reload_doc("accounts", "doctype", "payment_ledger_entry"):
|
||||
|
||||
@ -34,6 +57,8 @@ def execute():
|
||||
.run(as_dict=True)
|
||||
)
|
||||
|
||||
pl_entries = remove_duplicate_entries(pl_entries)
|
||||
|
||||
if pl_entries:
|
||||
# split into multiple batches, update and commit for each batch
|
||||
batch_size = 1000
|
||||
|
Loading…
x
Reference in New Issue
Block a user