ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Facing trouble in Popup Table Field


#1

In my case, I want to fetch Item Name and Item Group based on Item Code,

But when I Click on Any row, Field set to blank automatically, when I lose focus from row, data will set automatically. I don’t know what is happening with Table.

Even I expand row then field set to blank.


#2
frappe.call({
						"method": "custom_bom.api.getBomDetail",
						args: {
							bom_no: bom_name
						},
						freeze: true,
						freeze_message: __("Loading"),
						callback: function (r, rt) {
							console.log("response message = "+ JSON.stringify(r.message))
							data = r.message.items
							var material_popup = new frappe.ui.Dialog({
								'title': 'Select Material',
								'fields': [{
										fieldname: 'material',
										fieldtype: 'Table',
										fields: [
													{
														fieldtype:'Link',
														fieldname:'item_code',
														options: 'Item',
														label: __('Item Code'),
														in_list_view:1,
														get_query: function() {
													
														},
														onchange:function(){
															frappe.msgprint("asd")
																				frappe.call({
																					"method": "custom_bom.api.getBomDetail",
																					args: {
																						bom_no: bom_name
																					},
																					freeze: true,
																					freeze_message: __("Loading"),
																					callback: function (r, rt) {
																						console.log("response message = "+ JSON.stringify(r.message))
																					}
																					})
														}
													},{
														fieldtype:'Data',
														fieldname:'item_name',
														label: __('Item Name'),
														default:'item_code.item_name',
														in_list_view:1
													},{
														fieldtype:'Link',
														fieldname:'item_group',
														options: 'Item Group',
														label: __('Item Group'),
														in_list_view:1,
														default:'item_code.item_group'
													},{
														fieldtype:'Float',
														fieldname:'qty',
														label: __('Qty'),
														in_list_view:1
													},{
														fieldtype:'Currency',
														fieldname:'rate',
														label: __('Rate'),
														in_list_view:1
													},{
														fieldtype:'Currency',
														fieldname:'amount',
														label: __('Amount'),
														in_list_view:1
													}
												],
										data: data,
										get_data: function() {
											return data;
										}
								}],
								primary_action: function(){
									material_popup.hide();
									console.log(material_popup.get_values().material);
									
										frappe.call({
											"method": "custom_bom.api.saveBOM",
											args: {
												item :d2.item_code,
												currency :'INR',
												items : material_popup.get_values().material
												
											},
											freeze: true,
											freeze_message: __("Loading"),
											callback: function (r, rt) {
												d2.rate = r.message.total_cost
												d2.amount = d2.rate * d2.qty
												frm.trigger("calculate_taxes_and_totals")
												frm.refresh_field("items")
												material_popup.hide();
												
											}
										})
									
								}
							});
							material_popup.show();
						}
					})

#3

Is there any my mistake or limitation of PopupBox in frappe??

@nabinhait @rohit_w