Skip to content

Commit

Permalink
updated the prompt message using after_migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
AbrahamAdekunle committed Dec 31, 2023
1 parent 01c31fd commit bda6eee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
21 changes: 21 additions & 0 deletions one_fm/after_migrate/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,24 @@ def replace_job_opening():
for i in [user_files_path, user_magic_link]:
if not os.path.exists(bench_path+i):
os.mkdir(bench_path+i)


def replace_prompt_message_in_goal():
"""
Replace the prompt message that pop us while changing the KRA of a parent goal
"""
doctype_path = frappe.utils.get_bench_path() + "/apps/hrms/hrms/hr/doctype/goal/"
file_path = os.path.join(doctype_path, "goal.js")

if os.path.exists(file_path):
with open(file_path, 'r') as f:
filedata = f.read()

if not filedata.find("Modifying the KRA in the parent goal will specifically impact those child goals that share the same KRA; any other child goals with different KRAs will remain unaffected.") > 0:
newdata = filedata.replace(
"Changing KRA in this parent goal will align all the child goals to the same KRA, if any.",
"Modifying the KRA in the parent goal will specifically impact those child goals that share the same KRA; any other child goals with different KRAs will remain unaffected."
)

with open(file_path, 'w') as f:
f.write(newdata)
1 change: 1 addition & 0 deletions one_fm/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@
"one_fm.after_migrate.execute.disable_workflow_emails",
"one_fm.after_migrate.execute.comment_payment_entry_in_hrms",
"one_fm.after_migrate.execute.comment_process_expired_allocation_in_hrms",
"one_fm.after_migrate.execute.replace_prompt_message_in_goal",
]

before_migrate = [
Expand Down
29 changes: 1 addition & 28 deletions one_fm/public/js/doctype_js/goal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,5 @@ frappe.ui.form.on("Goal", {
}
}
});
},

// kra: function(frm) {
// if (!frm.doc.appraisal_cycle) {
// frm.set_value("kra", "");

// frappe.msgprint({
// message: __("Please select the Appraisal Cycle first."),
// title: __("Mandatory")
// });

// return;
// }

// if (frm.doc.__islocal || !frm.doc.is_group) return;

// let msg = __("Modifying the KRA in the parent goal will specifically impact those child goals that share the same KRA; any other child goals with different KRAs will remain unaffected.");
// msg += "<br> <br>";
// msg += __("Do you still want to proceed?");

// frappe.confirm(
// msg,
// () => {},
// () => {
// frappe.db.get_value("Goal", frm.doc.name, "kra", (r) => frm.set_value("kra", r.kra));
// }
// );
// },
}
})

0 comments on commit bda6eee

Please sign in to comment.