Send attachment to another doctype

I’m creating an employee from Employee visa process doctype and sending all the values to Employee doctype, i want to send attached files to Employee doctype.

Inserting values to Employee doctype:

emp = frappe.get_doc({“doctype”: “Employee”,
“employee_name”: self.employee_name,
“salary”: self.salary,
“passport_number”: self.passport_number,
“gender”: self.gender,
“offer_date”: self.offer_letter_date,
“nationality”: self.nationality,
“date_of_birth”: self.date_of_birth,
“date_of_joining”: self.date_of_joining,
“scheduled_confirmation_date”: self.offer_letter_date,
“nationality”: self.nationality,
“shift”: self.shift}).insert()

Inserting attached files:
In Employee doctype there is a table named Employee documents, attachments will be added in employee documents table.
Sample code, how i thought it should be done but its not working.

attach = frappe.get_doc({“doctype”: “Employee Documents”,
“attachment”: self.offer_letter_attachment}).update()

@Danyal.Khan are you using API to insert? i think the attachment of the document is not used in doctype but as a system wide mentioning what document you need to insert the attachment to…

@rmehta am i right?

Yes i’m using API to insert, the attachment will be inserted in Employee Visa Process doctype and on submitting data will be inserted in Employee Doctype for e.g name, number, DOB, date of joining etc, now i want to insert attached files of Employee Visa Process in Employee doctype.

@Ben_Cornwell_Mott posted a way to do this on the ERPNext wiki on github.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.