From 60403b2d8f72e39e8d720b0ab07a412b6ba4ffa4 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 25 Jul 2013 18:53:22 +0530 Subject: [PATCH] [fix] [minor] [grid] set_colum_disp should force refresh the whole grid --- accounts/doctype/sales_invoice/sales_invoice.js | 7 ++++--- buying/doctype/purchase_common/purchase_common.js | 8 ++++---- public/js/feature_setup.js | 3 +-- stock/doctype/delivery_note/delivery_note.js | 3 +-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 773956a67a..e4de474470 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -176,13 +176,14 @@ cur_frm.cscript.hide_fields = function(doc, cdt, cdn) { if(cint(doc.is_pos) == 1) { hide_field(par_flds); unhide_field('payments_section'); - for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], false); + cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal, false); } else { hide_field('payments_section'); unhide_field(par_flds); - for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], true); + cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal, true); } - for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], (cint(doc.update_stock)==1?true:false)); + + cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos, (cint(doc.update_stock)==1?true:false)); // India related fields var cp = wn.control_panel; diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index 04263c3a5e..494a9dcb2c 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -485,12 +485,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ // toggle columns var item_grid = this.frm.fields_dict[this.fname].grid; - var show = this.frm.doc.currency != company_currency; - $.each(["purchase_rate", "purchase_ref_rate", "amount", "rate"], function(i, fname) { - if(wn.meta.get_docfield(item_grid.doctype, fname)) - item_grid.set_column_disp(fname, show); + var fieldnames = $.map(["purchase_rate", "purchase_ref_rate", "amount", "rate"], function(fname) { + return wn.meta.get_docfield(item_grid.doctype, fname, me.frm.docname) ? fname : null; }); + item_grid.set_column_disp(fieldnames, this.frm.doc.currency != company_currency); + // set labels var $wrapper = $(this.frm.wrapper); $.each(field_label_map, function(fname, label) { diff --git a/public/js/feature_setup.js b/public/js/feature_setup.js index abd3370d87..add4bfda9a 100644 --- a/public/js/feature_setup.js +++ b/public/js/feature_setup.js @@ -209,8 +209,7 @@ $(document).bind('form_refresh', function() { if(fort=='fields') { hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]); } else if(cur_frm.fields_dict[fort]) { - for(grid_field in pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]) - cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort][grid_field], false); + cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort], false); } else { msgprint('Grid "'+fort+'" does not exists'); } diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index e93e6d3a78..a006766179 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -46,8 +46,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( // unhide expense_account and cost_center is auto_inventory_accounting enabled var aii_enabled = cint(sys_defaults.auto_inventory_accounting) - cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("expense_account", aii_enabled); - cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("cost_center", aii_enabled); + cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled); if (this.frm.doc.docstatus===0) { cur_frm.add_custom_button(wn._('From Sales Order'),