Skip to content

Commit ad8c054

Browse files
authored
fix: make ledger entries submittable and cleanup invalid test submissions (#52921)
* fix: enable submittability for ledger entries and cleanup invalid test submissions * fix: reverted child table submittability * fix: added ignore_links flag for back gl entry * fix: add ignore_links for reconcile,cancelled PLE,cancelled SLE * fix: update test_recreate_stock_ledgers to use db.delete instead of doc.delete * chore: temporary test against frappe PR 37009 * fix: make Advance Payment Ledger Entry submittable * refactor: add extra line for create_shipping_rule * chore: revert temporary test against frappe PR 37009 * fix: use parent doc save with ignore_validate_update_after_submit for child table updates * chore: temporary test against frappe PR 37009 * chore: revert temporary test against frappe PR 37009 * fix: use skip_docstatus_validation
1 parent 0e888cc commit ad8c054

16 files changed

Lines changed: 48 additions & 39 deletions

File tree

erpnext/accounts/doctype/account_closing_balance/account_closing_balance.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"doctype": "DocType",
66
"document_type": "Document",
77
"engine": "InnoDB",
8+
"is_submittable": 1,
89
"field_order": [
910
"closing_date",
1011
"account",

erpnext/accounts/doctype/advance_payment_ledger_entry/advance_payment_ledger_entry.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"creation": "2024-10-16 16:57:12.085072",
55
"doctype": "DocType",
66
"engine": "InnoDB",
7+
"is_submittable": 1,
78
"field_order": [
89
"company",
910
"voucher_type",

erpnext/accounts/doctype/gl_entry/gl_entry.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"doctype": "DocType",
66
"document_type": "Document",
77
"engine": "InnoDB",
8+
"is_submittable": 1,
89
"field_order": [
910
"dates_section",
1011
"posting_date",

erpnext/accounts/doctype/payment_ledger_entry/payment_ledger_entry.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"doctype": "DocType",
66
"editable_grid": 1,
77
"engine": "InnoDB",
8+
"is_submittable": 1,
89
"field_order": [
910
"posting_date",
1011
"company",

erpnext/accounts/doctype/pos_invoice/pos_invoice.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,11 +867,16 @@ def update_payments(self, payments: list):
867867

868868
idx = self.payments[-1].idx if self.payments else -1
869869

870+
self.reload()
871+
self.flags.ignore_validate_update_after_submit = True
872+
870873
for d in payments:
871874
idx += 1
872875
payment = create_payments_on_invoice(self, idx, frappe._dict(d))
873876
paid_amount += flt(payment.amount)
874-
payment.submit()
877+
self.append("payments", payment)
878+
879+
self.save()
875880

876881
paid_amount = flt(flt(paid_amount), self.precision("paid_amount"))
877882
base_paid_amount = flt(flt(paid_amount * self.conversion_rate), self.precision("base_paid_amount"))

erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ def create_shipping_rule(shipping_rule_type, shipping_rule_name):
8585
},
8686
)
8787
sr.insert(ignore_permissions=True)
88-
sr.submit()
88+
8989
return sr

erpnext/accounts/doctype/tax_withholding_entry/tax_withholding_entry.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def _adjust_against_old_entries(self, field_type: str) -> set:
197197

198198
new_entry = frappe.copy_doc(old_entry)
199199
new_entry.update(values_to_update)
200+
new_entry.skip_docstatus_validation = True
200201
new_entry.insert()
201202

202203
docs_needing_reindex.add((old_entry.parenttype, old_entry.parent))
@@ -335,6 +336,7 @@ def _handle_return_invoice_cancellation(self, filters):
335336
"withholding_date": None,
336337
}
337338
new_entry.update(values_to_update)
339+
new_entry.skip_docstatus_validation = True
338340
new_entry.insert()
339341

340342
docs_needing_reindex.add((entry.parenttype, entry.parent))

erpnext/accounts/general_ledger.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ def make_entry(args, adv_adj, update_outstanding, from_repost=False):
429429
gle.flags.adv_adj = adv_adj
430430
gle.flags.update_outstanding = update_outstanding or "Yes"
431431
gle.flags.notify_update = False
432+
if gle.is_cancelled:
433+
gle.flags.ignore_links = True
432434
gle.submit()
433435

434436
if (

erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -692,11 +692,9 @@ def test_future_payments(self):
692692
)
693693

694694
def test_sales_person(self):
695-
sales_person = (
696-
frappe.get_doc({"doctype": "Sales Person", "sales_person_name": "John Clark", "enabled": True})
697-
.insert()
698-
.submit()
699-
)
695+
sales_person = frappe.get_doc(
696+
{"doctype": "Sales Person", "sales_person_name": "John Clark", "enabled": True}
697+
).insert()
700698
si = self.create_sales_invoice(do_not_submit=True)
701699
si.append("sales_team", {"sales_person": sales_person.name, "allocated_percentage": 100})
702700
si.save().submit()
@@ -772,18 +770,14 @@ def test_multi_customer_group_filter(self):
772770

773771
def test_party_account_filter(self):
774772
si1 = self.create_sales_invoice()
775-
self.customer2 = (
776-
frappe.get_doc(
777-
{
778-
"doctype": "Customer",
779-
"customer_name": "Jane Doe",
780-
"type": "Individual",
781-
"default_currency": "USD",
782-
}
783-
)
784-
.insert()
785-
.submit()
786-
)
773+
self.customer2 = frappe.get_doc(
774+
{
775+
"doctype": "Customer",
776+
"customer_name": "Jane Doe",
777+
"type": "Individual",
778+
"default_currency": "USD",
779+
}
780+
).insert()
787781

788782
si2 = self.create_sales_invoice(do_not_submit=True)
789783
si2.posting_date = add_days(today(), -1)
@@ -995,18 +989,14 @@ def test_report_output_if_party_is_missing(self):
995989
self.assertEqual(expected_data, report_output)
996990

997991
def test_future_payments_on_foreign_currency(self):
998-
self.customer2 = (
999-
frappe.get_doc(
1000-
{
1001-
"doctype": "Customer",
1002-
"customer_name": "Jane Doe",
1003-
"type": "Individual",
1004-
"default_currency": "USD",
1005-
}
1006-
)
1007-
.insert()
1008-
.submit()
1009-
)
992+
self.customer2 = frappe.get_doc(
993+
{
994+
"doctype": "Customer",
995+
"customer_name": "Jane Doe",
996+
"type": "Individual",
997+
"default_currency": "USD",
998+
}
999+
).insert()
10101000

10111001
si = self.create_sales_invoice(do_not_submit=True)
10121002
si.posting_date = add_days(today(), -1)

erpnext/accounts/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,7 @@ def create_payment_ledger_entry(
21422142
if is_immutable_ledger_enabled():
21432143
ple.delinked = 0
21442144
ple.posting_date = frappe.form_dict.get("posting_date") or getdate()
2145+
ple.flags.ignore_links = True
21452146

21462147
ple.flags.ignore_permissions = 1
21472148
ple.flags.adv_adj = adv_adj

0 commit comments

Comments
 (0)