refactor: reset flag for old records
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 15dfc36..7c2c439 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -356,7 +356,7 @@
erpnext.patches.v15_0.create_advance_payment_status
erpnext.patches.v15_0.allow_on_submit_dimensions_for_repostable_doctypes
erpnext.patches.v14_0.create_accounting_dimensions_in_reconciliation_tool
-erpnext.patches.v14_0.update_flag_for_return_invoices
+erpnext.patches.v14_0.update_flag_for_return_invoices #2024-03-22
# below migration patch should always run last
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
erpnext.stock.doctype.delivery_note.patches.drop_unused_return_against_index # 2023-12-20
diff --git a/erpnext/patches/v14_0/update_flag_for_return_invoices.py b/erpnext/patches/v14_0/update_flag_for_return_invoices.py
index feb43be..bea9957 100644
--- a/erpnext/patches/v14_0/update_flag_for_return_invoices.py
+++ b/erpnext/patches/v14_0/update_flag_for_return_invoices.py
@@ -12,6 +12,10 @@
creation_date = "2024-01-25"
si = qb.DocType("Sales Invoice")
+
+ # unset flag, as migration would have set it for all records, as the field was introduced with default '1'
+ qb.update(si).set(si.update_outstanding_for_self, False).run()
+
if cr_notes := (
qb.from_(si)
.select(si.name)
@@ -37,6 +41,10 @@
).run()
pi = qb.DocType("Purchase Invoice")
+
+ # unset flag, as migration would have set it for all records, as the field was introduced with default '1'
+ qb.update(pi).set(pi.update_outstanding_for_self, False).run()
+
if dr_notes := (
qb.from_(pi)
.select(pi.name)