fix(accounts): add permission checks on invoice_discounting.get_invoices (#58975)

This commit is contained in:
Diptanil Saha
2026-09-11 09:39:38 +05:30
committed by GitHub
parent be8208e7cb
commit b481083ff0
3 changed files with 13 additions and 3 deletions

View File

@@ -136,6 +136,7 @@ frappe.ui.form.on("Invoice Discounting", {
], ],
primary_action: function () { primary_action: function () {
var data = d.get_values(); var data = d.get_values();
data.company = frm.doc.company;
frappe.call({ frappe.call({
method: "erpnext.accounts.doctype.invoice_discounting.invoice_discounting.get_invoices", method: "erpnext.accounts.doctype.invoice_discounting.invoice_discounting.get_invoices",

View File

@@ -1,5 +1,6 @@
{ {
"actions": [], "actions": [],
"allow_bulk_edit": 1,
"allow_import": 1, "allow_import": 1,
"autoname": "ACC-INV-DISC-.YYYY.-.#####", "autoname": "ACC-INV-DISC-.YYYY.-.#####",
"creation": "2019-03-07 12:01:56.296952", "creation": "2019-03-07 12:01:56.296952",
@@ -170,7 +171,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2024-03-27 13:09:52.746196", "modified": "2026-09-09 17:04:59.512294",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Invoice Discounting", "name": "Invoice Discounting",
@@ -187,14 +188,15 @@
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "System Manager", "role": "Accounts Manager",
"share": 1, "share": 1,
"submit": 1, "submit": 1,
"write": 1 "write": 1
} }
], ],
"row_format": "Dynamic",
"sort_field": "creation", "sort_field": "creation",
"sort_order": "DESC", "sort_order": "DESC",
"states": [], "states": [],
"track_changes": 1 "track_changes": 1
} }

View File

@@ -319,6 +319,13 @@ class InvoiceDiscounting(AccountsController):
@frappe.whitelist() @frappe.whitelist()
def get_invoices(filters: str | dict): def get_invoices(filters: str | dict):
filters = frappe._dict(frappe.parse_json(filters)) filters = frappe._dict(frappe.parse_json(filters))
if not filters.get("company"):
frappe.throw(_("Please set company on the Document before requesting for invoices."))
frappe.has_permission("Company", doc=filters.get("company"), throw=True)
frappe.has_permission("Invoice Discounting", throw=True)
si = frappe.qb.DocType("Sales Invoice") si = frappe.qb.DocType("Sales Invoice")
di = frappe.qb.DocType("Discounted Invoice") di = frappe.qb.DocType("Discounted Invoice")