How to create and insert a new doc from custom script when there are mandatory fields?

I’m trying to create a doctype > Payables which has some mandatory fields.

def create_cabin_35_doc(self):

doc = frappe.new_doc("Payables")
doc.update({"doc.sales_invoice" : self,
			"doc.customer" : self.customer,
			"doc.customer_name" : self.customer_name
})
doc.insert()

I’m getting the following error when creating this doctype

`MandatoryError: [Payables, CP - 00004]: sales_invoice, customer, customer_name

@Sai_Sasank,

use the ignore_mandatory flag,

e.g. doc.flag.ignore_mandatory = True.

mandatory field validations will be skipped using this flag while insert or save of a document.

Thanks, Makarand

I want to save the mandatory fields as well
This is the code i’m adding in the on_submit of “Sales invoice” doctype to create a new doctype payables. sales_invoice is the mandatory field.

def create_cabin_35_doc(self):

sales_invoice_doc = frappe.get_doc("Sales Invoice", self.name)
doc = frappe.new_doc("Payables")

doc.sales_invoice = sales_invoice_doc,
doc.customer = sales_invoice_doc.customer,
doc.customer_name = sales_invoice_doc.customer_name
doc.insert()

But i’m getting an error like this
TypeError: coercing to Unicode: need string or buffer, SalesInvoice found

In the doc i have a sales_invoice field where it is linked to > Sales Invoice . I’m populating that column by the above code is it okay?

Any Idea how to insert a child table. Say from custom script we create a new Doc “sales Invoice” and need to create Items in the new DocType.

What is the procedure?