Skip to content

Commit

Permalink
fix: adjust score for autocompletions
Browse files Browse the repository at this point in the history
(cherry picked from commit 401d2f0)
  • Loading branch information
ruchamahabal authored and mergify[bot] committed May 29, 2024
1 parent 2090bb2 commit 3eddaed
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions hrms/hr/doctype/appraisal_cycle/appraisal_cycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

frappe.ui.form.on("Appraisal Cycle", {
refresh(frm) {
frm.trigger("set_autocompletions_for_final_score_formula");
frm.set_query("department", () => {
return {
filters: {
Expand All @@ -14,6 +13,7 @@ frappe.ui.form.on("Appraisal Cycle", {

frm.trigger("show_custom_buttons");
frm.trigger("show_appraisal_summary");
frm.trigger("set_autocompletions_for_final_score_formula");
},

show_custom_buttons(frm) {
Expand Down Expand Up @@ -60,26 +60,24 @@ frappe.ui.form.on("Appraisal Cycle", {
set_autocompletions_for_final_score_formula: async (frm) => {
const autocompletions = [
{
value: "goal_score",
score: 8,
meta: "Goal field",
value: "total_score",
score: 10,
meta: __("Total Goal Score"),
},
{
value: "average_feedback_score",
score: 8,
meta: "Appraisal field",
score: 10,
meta: __("Average Feedback Score"),
},
{
value: "self_appraisal_score",
score: 8,
meta: "Appraisal field",
score: 10,
meta: __("Self Appraisal Score"),
},
];

const doctypes = ["Employee", "Appraisal Cycle"];

await Promise.all(
doctypes.map((doctype) =>
["Employee", "Appraisal Cycle", "Appraisal"].map((doctype) =>
frappe.model.with_doctype(doctype, () => {
autocompletions.push(
...frappe.get_meta(doctype).fields.map((f) => ({
Expand All @@ -91,6 +89,7 @@ frappe.ui.form.on("Appraisal Cycle", {
}),
),
);

frm.set_df_property("final_score_formula", "autocompletions", autocompletions);
},

Expand Down

0 comments on commit 3eddaed

Please sign in to comment.