Inserting into child table

Hello;

I found that we can get the values of child table using:

frappe.model.get_list

as in the below script:

var restricted_in_source = frappe.model.get_list(“Stock Entry Detail”,
{parent:cur_frm.doc.name, s_warehouse:“Restricted”});

Which was taken from this link: from the link: https://erpnext.org/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-user-based-on-child-record

The question is:
Is there frappe method to add records in the child table or I have to add it using database method in python (frappe.db.sql)?

Regards
Bilal

Yes there is. Look at the code snippet below: It creates an invoice and add Invoce Items as child doctypes using frappe-client

def create_invoice(self):
            client = FrappeClient("XXXXXXXX", "XXXXXXXXXXX", "XXXXXXXXXXXXXX")
            self.create_customer()
            invoice_doc = {
                "doctype": "Sales Invoice",
                "customer": "XXXXX",
                "company": "XXXXXX",
                "due_date": "2017-12-30",
                "currency": "RWF",
                "conversion_rate": 1.0,
                'selling_price_list': 'Standard Selling',
                'price_list_currency': 'RWF',
                'plc_conversion_rate': 1.0,
                'naming_series': 'SINV-',
                'base_net_total':0,
                'base_grand_total':0,
                'base_total':0,
                'grand_total':0,
                'debit_to': "Debtors - U",
                "submit_on_creation": 1,
                "docstatus": 1,
                'items':[]
            }
            program_offering = frappe.get_doc("Program Offering", self.program_offering)
            for fee in program_offering.fees:
                invoice_doc['items'].append({
                    'qty': fee.quantity,
                    'doctype':'Sales Invoice Item',
                    'item_name': fee.fee_item,
                    'description': "Applicatin Fees",
                    'uom':'Nos',
                    'conversion_factor': 1.0,
                    'rate': fee.unit_price,
                    'income_account': 'Sales - U',
                    'cost_center': 'Main - U'
                })

            invoice = client.insert(invoice_doc)

Thanks a lot for the help and kindly reply.
What is the parameters of FrappeClient that need to be passed?

client = FrappeClient(“XXXXXXXX”, “XXXXXXXXXXX”, “XXXXXXXXXXXXXX”)

And what it means each parameter.
Actually I looked for this link: https://github.com/frappe/frappe-client but I did not understand what these parameters? Can I have more explaination about it please?

From the other side: as we can use self.create_customer(), so why we can not use something similar to it to insert records in the child table instead of using client?
In other words, there is not something like self.insert () “I am just guessing” so I can use it instead of using API?

Regards
Bilal

client = FrappeClient(SERVER_URL, USERNAME, PASSWORD)

Example from github: client = FrappeClient(“example.com”, "user@example.com", “password”)

Using client or API in general is the proper way of doing this remotely

Thank you.

USERNAME and PASSWORD are those that are used to login to erpnext application or database username and password?

Regards
Bilal

those that are used to login to erpnext application