fix: Hide Make Depreciation Entry if the Asset is not in the Submitted or Partially Depreciated state

This commit is contained in:
GangaManoj
2022-01-14 17:40:59 +05:30
parent 1800ce2780
commit 73243c8ac3

View File

@@ -78,6 +78,7 @@ frappe.ui.form.on('Asset', {
frappe.ui.form.trigger("Asset", "is_existing_asset");
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
frm.events.make_schedules_editable(frm);
frm.trigger("toggle_make_depreciation_entry");
if (frm.doc.docstatus==1) {
if (in_list(["Submitted", "Partially Depreciated", "Fully Depreciated"], frm.doc.status)) {
@@ -141,6 +142,18 @@ frappe.ui.form.on('Asset', {
}
},
toggle_make_depreciation_entry: function(frm) {
if (frm.doc.calculate_depreciation){
if (in_list(["Submitted", "Partially Depreciated"], frm.doc.status)){
frm.fields_dict['schedules'].grid.set_column_disp('make_depreciation_entry', true);
} else {
frm.fields_dict['schedules'].grid.set_column_disp('make_depreciation_entry', false);
}
frm.refresh_field('schedules');
}
},
toggle_reference_doc: function(frm) {
if (frm.doc.purchase_receipt && frm.doc.purchase_invoice && frm.doc.docstatus === 1) {
frm.set_df_property('purchase_invoice', 'read_only', 1);