Sales Invoice Error

Hey guys, I just started getting this console error, not sure where it’s coming from:

uncaught exception: field not found: reference_name

I haven’t changed anything on the Sales Invoice lately… .

Is there a traceback you can follow?

Not seeing anything, just the one line. The error originates at form.min.js:267 though.

260 this.grid_rows.splice(data.length);}},setup_fields:function(){var me=this;if(this.frm&&this.frm.docname){this.df=frappe.meta.get_docfield(this.frm.doctype,this.df.fieldname,this.frm.docname);}else{this.df=frappe.meta.get_docfield(this.df.options,this.df.fieldname);}
261 this.docfields=frappe.meta.get_docfields(this.doctype,this.frm.docname);this.docfields.forEach(function(df){me.fields_map[df.fieldname]=df;});},refresh_row:function(docname){this.grid_rows_by_docname[docname]&&this.grid_rows_by_docname[docname].refresh();},data_rows_are_same:function(data){if(this.grid_rows){var same=data.length==this.grid_rows.length&&this.display_status==this.last_display_status&&this.frm.docname==this.last_docname&&!$.map(this.grid_rows,function(g,i){return(g&&g.doc&&g.doc.name==data[i].name)?null:true;}).length;return same;}},make_sortable:function($rows){var me=this;if('ontouchstart'in window){return;}
262 new Sortable($rows.get(0),{handle:".sortable-handle",onUpdate:function(event,ui){me.frm.doc[me.df.fieldname]=[];$rows.find(".grid-row").each(function(i,item){var doc=locals[me.doctype][$(item).attr('data-name')];doc.idx=i+1;me.frm.doc[me.df.fieldname].push(doc);});me.grid_rows=[];me.frm.doc[me.df.fieldname].forEach(function(d){me.grid_rows.push(me.grid_rows_by_docname[d.name]);});me.refresh();me.frm.dirty();}});$(this.frm.wrapper).trigger("grid-make-sortable",[this.frm]);},get_data:function(){var data=this.frm.doc[this.df.fieldname]||[];data.sort(function(a,b){return a.idx-b.idx});return data;},set_column_disp:function(fieldname,show){if($.isArray(fieldname)){var me=this;for(var i=0,l=fieldname.length;i<l;i++){var fname=fieldname[i];me.get_docfield(fname).hidden=show?0:1;}}else{this.get_docfield(fieldname).hidden=show?0:1;}
263 this.refresh(true);},toggle_reqd:function(fieldname,reqd){this.get_docfield(fieldname).reqd=reqd;this.refresh();},toggle_enable:function(fieldname,enable){this.get_docfield(fieldname).read_only=enable?0:1;;this.refresh();},get_docfield:function(fieldname){return frappe.meta.get_docfield(this.doctype,fieldname,this.frm?this.frm.docname:null);},get_grid_row:function(docname){return this.grid_rows_by_docname[docname];},get_field:function(fieldname){if(!this.fieldinfo[fieldname])
264 this.fieldinfo[fieldname]={}
265 return this.fieldinfo[fieldname];},set_value:function(fieldname,value,doc){if(this.display_status!=="None"&&this.grid_rows_by_docname[doc.name]){this.grid_rows_by_docname[doc.name].refresh_field(fieldname);}},add_new_row:function(idx,callback,show){if(this.is_editable()){var d=frappe.model.add_child(this.frm.doc,this.df.options,this.df.fieldname,idx);d.__unedited=true;this.frm.script_manager.trigger(this.df.fieldname+"_add",d.doctype,d.name);this.refresh();if(show&&!this.allow_on_grid_editing()){if(idx){this.wrapper.find("[data-idx='"+idx+"']").data("grid_row").toggle_view(true,callback);}else{this.wrapper.find(".grid-row:last").data("grid_row").toggle_view(true,callback);}}
266 return d;}},set_focus_on_row:function(idx){var me=this;if(!idx){idx=me.grid_rows.length-1;}
267 setTimeout(function(){me.grid_rows[idx].row.find('input,textarea,select').filter(':visible:first').focus();},100);},setup_visible_columns:function(){if(this.visible_columns)return;var total_colsize=1,fields=this.editable_fields||this.docfields;this.visible_columns=[];for(var ci in fields){var _df=fields[ci];df=this.fields_map[_df.fieldname];if(!df){throw'field not found: '+_df.fieldname;}
268 if(_df.columns){df.colsize=_df.columns;}
269 if(!df.hidden&&(this.editable_fields||df.in_list_view)&&this.frm.get_perm(df.permlevel,"read")&&!in_list(frappe.model.layout_fields,df.fieldtype)){if(!df.colsize){var colsize=2;switch(df.fieldtype){case"Text":case"Small Text":colsize=3;break;case"Check":colsize=1;break;}
270 df.colsize=colsize;}

Try bench update --build and see if you get any errors

It looks like the error is coming from frappe/grid.js in the method setup_visible_columns.

One thing I’ve noticed since v7 is that the sorting function can get switched from the usual stuff to a specific field, which can cause errors. Try checking to see if the sort field has changed:

@superlack We performed bench update --build and it updated without any errors. We are still receiving the original error in the Sales Invoice.

@Ben_Cornwell_Mott The error only comes from within a SI itself, not in the list. So perhaps there is a problem with the Sales Invoice Item, but so far I’ve been unable to locate it.

The only place this value comes up in Sales Invoices is in the dashboard. Is this coming up when creating a new SI, or when opening existing ones? If just opening existing ones, it could be that reference_name is missing from one of:

‘Journal Entry’: ‘reference_name’,
‘Payment Entry’: ‘reference_name’,
‘Payment Request’: ‘reference_name’,

@Ben_Cornwell_Mott This is happening both ways, creating new invoices and looking at existing.

@Ben_Cornwell_Mott Seems like it is working on new most of the time. It still throws the error, but it doesn’t grey the screen. But sometimes it does grey the screen. If I refresh the page while in a new sales invoice it will grey out.

Also, if reference_name is missing from one of those, how could I go about correcting that?