mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 10:11:20 +00:00
Merge pull request #32501 from frappe/mergify/bp/version-14-hotfix/pr-32491
refactor: remove duplicate entries on remarks migration patch (backport #32491)
This commit is contained in:
@@ -3,6 +3,29 @@ from frappe import qb
|
|||||||
from frappe.utils import create_batch
|
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():
|
def execute():
|
||||||
if frappe.reload_doc("accounts", "doctype", "payment_ledger_entry"):
|
if frappe.reload_doc("accounts", "doctype", "payment_ledger_entry"):
|
||||||
|
|
||||||
@@ -34,6 +57,8 @@ def execute():
|
|||||||
.run(as_dict=True)
|
.run(as_dict=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pl_entries = remove_duplicate_entries(pl_entries)
|
||||||
|
|
||||||
if pl_entries:
|
if pl_entries:
|
||||||
# split into multiple batches, update and commit for each batch
|
# split into multiple batches, update and commit for each batch
|
||||||
batch_size = 1000
|
batch_size = 1000
|
||||||
|
|||||||
Reference in New Issue
Block a user