Skip to content

Commit

Permalink
fix: do not clear promotion/transfer details if doc is amended (#32000)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal authored Aug 29, 2022
1 parent 8eded43 commit 074d484
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions erpnext/hr/employee_property_update.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ frappe.ui.form.on(cur_frm.doctype, {
};
});
},
onload: function(frm){
if(frm.doc.__islocal){
if(frm.doctype == "Employee Promotion"){
onload: function(frm) {
if (frm.doc.__islocal && !frm.doc.amended_from) {
if (frm.doctype == "Employee Promotion") {
frm.doc.promotion_details = [];
}else if (frm.doctype == "Employee Transfer") {
} else if (frm.doctype == "Employee Transfer") {
frm.doc.transfer_details = [];
}
}
Expand Down Expand Up @@ -106,12 +106,12 @@ var render_dynamic_field = function(d, fieldtype, options, fieldname) {

var add_to_details = function(frm, d, table) {
let data = d.data;
if(data.fieldname){
if(validate_duplicate(frm, table, data.fieldname)){
if (data.fieldname) {
if (validate_duplicate(frm, table, data.fieldname)) {
frappe.show_alert({message:__("Property already added"), indicator:'orange'});
return false;
}
if(data.current == data.new){
if (data.current == data.new) {
frappe.show_alert({message:__("Nothing to change"), indicator:'orange'});
d.get_primary_btn().attr('disabled', false);
return false;
Expand All @@ -123,12 +123,14 @@ var add_to_details = function(frm, d, table) {
new: data.new
});
frm.refresh_field(table);
frm.fields_dict[table].grid.wrapper.find(".grid-add-row").hide();

d.fields_dict.field_html.$wrapper.html("");
d.set_value("property", "");
d.set_value('current', "");
frappe.show_alert({message:__("Added to details"),indicator:'green'});
d.data = {};
}else {
} else {
frappe.show_alert({message:__("Value missing"),indicator:'red'});
}
};
Expand Down

0 comments on commit 074d484

Please sign in to comment.