fix: permission based revision of budget

This commit is contained in:
khushi8112
2025-11-19 17:05:26 +05:30
parent 8fd5d7187a
commit acec1a7a9d
2 changed files with 19 additions and 18 deletions

View File

@@ -4,16 +4,6 @@ frappe.provide("erpnext.accounts.dimensions");
frappe.ui.form.on("Budget", { frappe.ui.form.on("Budget", {
onload: function (frm) { onload: function (frm) {
frm.set_query("account", "accounts", function () {
return {
filters: {
company: frm.doc.company,
report_type: "Profit and Loss",
is_group: 0,
},
};
});
frm.set_query("monthly_distribution", function () { frm.set_query("monthly_distribution", function () {
return { return {
filters: { filters: {
@@ -30,10 +20,19 @@ frappe.ui.form.on("Budget", {
}); });
}, },
refresh: function (frm) { refresh: async function (frm) {
frm.trigger("toggle_reqd_fields"); frm.trigger("toggle_reqd_fields");
if (!frm.doc.__islocal && frm.doc.docstatus == 1) { if (!frm.doc.__islocal && frm.doc.docstatus == 1) {
let exception_role = await frappe.db.get_value(
"Company",
frm.doc.company,
"exception_budget_approver_role"
);
const role = exception_role.message.exception_budget_approver_role;
if (role && frappe.user.has_role(role)) {
frm.add_custom_button( frm.add_custom_button(
__("Revise Budget"), __("Revise Budget"),
function () { function () {
@@ -42,6 +41,7 @@ frappe.ui.form.on("Budget", {
__("Actions") __("Actions")
); );
} }
}
}, },
budget_against: function (frm) { budget_against: function (frm) {

View File

@@ -184,6 +184,7 @@
"options": "\nStop\nWarn\nIgnore" "options": "\nStop\nWarn\nIgnore"
}, },
{ {
"default": "BUDGET-.########",
"fieldname": "naming_series", "fieldname": "naming_series",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Series", "label": "Series",
@@ -308,7 +309,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2025-11-17 17:38:27.759355", "modified": "2025-11-19 17:00:00.648224",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Budget", "name": "Budget",