I have one child Table called Sales Variant. I put that table under Item Group DocType. Now If Item Group has one Finished Goods with single or multiple records in that child Table Sales Variant. I want to show that Sales Variant records in Item record if Item Group is Finished Goods.
Below you can check code I written as screenshot I have attached for better understanding. In Item DocType Record is visible but If I try to save Item Record it’s creating record in Sales Variant as taking Item as parent.
fetch_sales_variants(frm){
// As of now Table should be readonly
frm.set_df_property("sales_variants", "read_only", 1);
if (frm.doc.selling == 1) {
frappe.db.get_list("Sales Variants", {
filters: {'parentfield': 'sales_variants','parenttype': 'Item Group', 'parent': frm.doc.item_group},
fields: ["*"],
limit: 20
}).then((res) => {
frm.doc.sales_variants = []
$.each(res, function(_i, e){
let entry = frm.add_child("sales_variants");
// entry.name = e.name; // If I try to store name field record is not showing as expected.
entry.item_code = e.item_code;
entry.item_name = e.item_name;
})
refresh_field("sales_variants")
});
};
}