Insert Data to Table MultiSelect Field

How to add data to MultiSelect in doc type that have Table MultiSelect Field using frappe?

if(frm.doc.__islocal){
            var new_row = frm.add_child("table_fieldname");
                new_row.fieldname_in_childtable = "Test 1";
                frm.refresh_field("table_fieldname");
        }

in python you can do this :
doc = frappe.get_doc(“Item”,‘test’)
doc_row = doc.append(‘custom_brand’, {})
doc_row.brand = frappe.get_doc(“Brand”,‘Al Galria’)
doc.save()
note : the child table has a filed call brand and its a link to Brand doctype
so you add a object not a name str . this way it will works .