Get attchments from Another Doctype

Taking Sales Order Attachment to my custom doctype

def attach_file(self):
file = frappe.db.get_all(‘File’, filters={
“attached_to_doctype”: “Sales Order”,
“attached_to_name”: self.sales_order,
},fields=[‘file_url’,‘is_private’])
if file:
for img in file:
file_doc = frappe.get_doc({
“doctype”: “File”,
“file_url”: img[‘file_url’],
“attached_to_doctype”: “Production Order”,
“attached_to_name”: self.name,
“is_private”: img[‘is_private’],
}).save()