Skip to content

Commit

Permalink
Merge pull request #38021 from frappe/mergify/bp/version-14/pr-37860
Browse files Browse the repository at this point in the history
refactor: ignore disabled account while selecting Income Accounts (backport #37860)
  • Loading branch information
ruthra-kumar authored Nov 9, 2023
2 parents 5062773 + c3d7348 commit 8969502
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 10 additions & 10 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
erpnext.accounts.unreconcile_payments.add_unreconcile_btn(me.frm);
}


make_maintenance_schedule() {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule",
Expand Down Expand Up @@ -557,15 +556,6 @@ cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) {
}
}

// Income Account in Details Table
// --------------------------------
cur_frm.set_query("income_account", "items", function(doc) {
return{
query: "erpnext.controllers.queries.get_income_account",
filters: {'company': doc.company}
}
});

// Cost Center in Details Table
// -----------------------------
cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(doc) {
Expand Down Expand Up @@ -660,6 +650,16 @@ frappe.ui.form.on('Sales Invoice', {
};
});

frm.set_query("income_account", "items", function() {
return{
query: "erpnext.controllers.queries.get_income_account",
filters: {
'company': frm.doc.company,
"disabled": 0
}
}
});

frm.custom_make_buttons = {
'Delivery Note': 'Delivery',
'Sales Invoice': 'Return / Credit Note',
Expand Down
2 changes: 2 additions & 0 deletions erpnext/controllers/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
if filters.get("company"):
condition += "and tabAccount.company = %(company)s"

condition += f"and tabAccount.disabled = {filters.get('disabled', 0)}"

return frappe.db.sql(
"""select tabAccount.name from `tabAccount`
where (tabAccount.report_type = "Profit and Loss"
Expand Down

0 comments on commit 8969502

Please sign in to comment.