Merge pull request #30453 from rahib-hassan/fix-paymentorder-row-delete
fix: enable row deletion in reference table
diff --git a/erpnext/accounts/doctype/payment_order/payment_order.js b/erpnext/accounts/doctype/payment_order/payment_order.js
index 9074def..7d85d89 100644
--- a/erpnext/accounts/doctype/payment_order/payment_order.js
+++ b/erpnext/accounts/doctype/payment_order/payment_order.js
@@ -12,7 +12,6 @@
});
frm.set_df_property('references', 'cannot_add_rows', true);
- frm.set_df_property('references', 'cannot_delete_rows', true);
},
refresh: function(frm) {
if (frm.doc.docstatus == 0) {
diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.js b/erpnext/accounts/report/accounts_payable/accounts_payable.js
index 81c60bb..f6961eb 100644
--- a/erpnext/accounts/report/accounts_payable/accounts_payable.js
+++ b/erpnext/accounts/report/accounts_payable/accounts_payable.js
@@ -54,6 +54,22 @@
}
},
{
+ "fieldname": "party_account",
+ "label": __("Payable Account"),
+ "fieldtype": "Link",
+ "options": "Account",
+ get_query: () => {
+ var company = frappe.query_report.get_filter_value('company');
+ return {
+ filters: {
+ 'company': company,
+ 'account_type': 'Payable',
+ 'is_group': 0
+ }
+ };
+ }
+ },
+ {
"fieldname": "ageing_based_on",
"label": __("Ageing Based On"),
"fieldtype": "Select",
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
index 5700298..748bcde 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js
@@ -67,6 +67,22 @@
}
},
{
+ "fieldname": "party_account",
+ "label": __("Receivable Account"),
+ "fieldtype": "Link",
+ "options": "Account",
+ get_query: () => {
+ var company = frappe.query_report.get_filter_value('company');
+ return {
+ filters: {
+ 'company': company,
+ 'account_type': 'Receivable',
+ 'is_group': 0
+ }
+ };
+ }
+ },
+ {
"fieldname": "ageing_based_on",
"label": __("Ageing Based On"),
"fieldtype": "Select",
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 7bf9539..de9d63d 100755
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -111,6 +111,7 @@
voucher_type=gle.voucher_type,
voucher_no=gle.voucher_no,
party=gle.party,
+ party_account=gle.account,
posting_date=gle.posting_date,
account_currency=gle.account_currency,
remarks=gle.remarks if self.filters.get("show_remarks") else None,
@@ -777,18 +778,22 @@
conditions.append("party=%s")
values.append(self.filters.get(party_type_field))
- # get GL with "receivable" or "payable" account_type
- account_type = "Receivable" if self.party_type == "Customer" else "Payable"
- accounts = [
- d.name
- for d in frappe.get_all(
- "Account", filters={"account_type": account_type, "company": self.filters.company}
- )
- ]
+ if self.filters.party_account:
+ conditions.append("account =%s")
+ values.append(self.filters.party_account)
+ else:
+ # get GL with "receivable" or "payable" account_type
+ account_type = "Receivable" if self.party_type == "Customer" else "Payable"
+ accounts = [
+ d.name
+ for d in frappe.get_all(
+ "Account", filters={"account_type": account_type, "company": self.filters.company}
+ )
+ ]
- if accounts:
- conditions.append("account in (%s)" % ",".join(["%s"] * len(accounts)))
- values += accounts
+ if accounts:
+ conditions.append("account in (%s)" % ",".join(["%s"] * len(accounts)))
+ values += accounts
def add_customer_filters(self, conditions, values):
if self.filters.get("customer_group"):
@@ -888,6 +893,13 @@
options=self.party_type,
width=180,
)
+ self.add_column(
+ label="Receivable Account" if self.party_type == "Customer" else "Payable Account",
+ fieldname="party_account",
+ fieldtype="Link",
+ options="Account",
+ width=180,
+ )
if self.party_naming_by == "Naming Series":
self.add_column(
diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py
index 7a6989f..f38890e 100644
--- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py
@@ -50,12 +50,19 @@
make_credit_note(name)
report = execute(filters)
- expected_data_after_credit_note = [100, 0, 0, 40, -40]
+ expected_data_after_credit_note = [100, 0, 0, 40, -40, "Debtors - _TC2"]
row = report[1][0]
self.assertEqual(
expected_data_after_credit_note,
- [row.invoice_grand_total, row.invoiced, row.paid, row.credit_note, row.outstanding],
+ [
+ row.invoice_grand_total,
+ row.invoiced,
+ row.paid,
+ row.credit_note,
+ row.outstanding,
+ row.party_account,
+ ],
)