How to implement a mechanism using the example of Work Order - >> Stock Entry?

After creating a Work Order and pressing the start button, a new Stock Entry appears on the screen with already filled fields for moving raw materials to a warehouse for production.

I would like to implement such a mechanism for my custom doctypes - when press the Submit button in “1 doctype” - so that “2 doctype” appear on the screen.

How can I do that?

Привет Дмитрий,

You can create a new doc using frappe.model.with_doctype, and frappe.model.get_new_doc. Fill the doc with the data you might need.

e.g.

frappe.model.with_doctype("Customer Issue", function() {
  var doc = frappe.model.get_new_doc("Customer Issue");
  doc.customer = frm.customer;
  frappe.set_route("Form", "Customer Issue", doc.name);
}

Example of making another doctype from existing doctype.

Regards,

Ivan

1 Like