diff --git a/erpnext/patches.txt b/erpnext/patches.txt index d5f2ccb2ca..c03a5456ac 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -89,6 +89,7 @@ erpnext.patches.v4_2.recalculate_bom_cost erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions erpnext.patches.v4_2.update_requested_and_ordered_qty erpnext.patches.v4_2.party_model +erpnext.patches.v4_4.make_email_accounts erpnext.patches.v5_0.update_frozen_accounts_permission_role erpnext.patches.v5_0.update_dn_against_doc_fields -execute:frappe.db.sql("update `tabMaterial Request` set material_request_type = 'Material Transfer' where material_request_type = 'Transfer'") \ No newline at end of file +execute:frappe.db.sql("update `tabMaterial Request` set material_request_type = 'Material Transfer' where material_request_type = 'Transfer'") diff --git a/erpnext/patches/v4_4/make_email_accounts.py b/erpnext/patches/v4_4/make_email_accounts.py index 9e8538db25..950b2a6741 100644 --- a/erpnext/patches/v4_4/make_email_accounts.py +++ b/erpnext/patches/v4_4/make_email_accounts.py @@ -4,69 +4,72 @@ def execute(): frappe.reload_doc("email", "doctype", "email_account") # outgoing - outgoing = frappe.get_doc("Outgoing Email Settings") - account = frappe.new_doc("Email Account") - mapping = { - "email_id": "mail_login", - "password": "mail_password", - "footer": "footer", - "smtp_server": "mail_server", - "smtp_port": "mail_port", - "use_tls": "use_ssl" - } - - for target_fieldname, source_fieldname in mapping.iteritems(): - account.set(target_fieldname, outgoing.get(source_fieldname)) - - account.enable_outgoing = 1 - account.enable_incoming = 0 - account.is_global = 1 - - account.insert() - - # support - support = frappe.get_doc("Support Email Settings") - account = frappe.new_doc("Email Account") - mapping = { - "enable_incoming": "sync_support_mails", - "email_id": "mail_login", - "password": "mail_password", - "pop3_server": "mail_server", - "use_ssl": "use_ssl", - "signature": "support_signature", - "enable_auto_reply": "send_autoreply", - "auto_reply_message": "support_autoreply" - } - - for target_fieldname, source_fieldname in mapping.iteritems(): - account.set(target_fieldname, support.get(source_fieldname)) - - account.enable_outgoing = 0 - account.is_global = 1 - - account.insert() - - # sales, jobs - for doctype in ("Sales Email Settings", "Jobs Email Settings"): - source = frappe.get_doc(doctype) + if frappe.db.exists("DocType", "Outgoing Email Settings"): + outgoing = dict(frappe.db.sql("select field, value from tabSingles where doctype='Outgoing Email Settings'")) account = frappe.new_doc("Email Account") mapping = { - "enable_incoming": "extract_emails", - "email_id": "username", - "password": "password", - "pop3_server": "host", - "use_ssl": "use_ssl", + "email_id": "mail_login", + "password": "mail_password", + "footer": "footer", + "smtp_server": "mail_server", + "smtp_port": "mail_port", + "use_tls": "use_ssl" } for target_fieldname, source_fieldname in mapping.iteritems(): - account.set(target_fieldname, source.get(source_fieldname)) + account.set(target_fieldname, outgoing.get(source_fieldname)) + + account.enable_outgoing = 1 + account.enable_incoming = 0 + account.is_global = 1 + + account.insert() + + # support + if frappe.db.exists("DocType", "Support Email Settings"): + support = dict(frappe.db.sql("select field, value from tabSingles where doctype='Support Email Settings'")) + account = frappe.new_doc("Email Account") + mapping = { + "enable_incoming": "sync_support_mails", + "email_id": "mail_login", + "password": "mail_password", + "pop3_server": "mail_server", + "use_ssl": "use_ssl", + "signature": "support_signature", + "enable_auto_reply": "send_autoreply", + "auto_reply_message": "support_autoreply" + } + + for target_fieldname, source_fieldname in mapping.iteritems(): + account.set(target_fieldname, support.get(source_fieldname)) account.enable_outgoing = 0 account.is_global = 1 - account.append_to = "Lead" if doctype=="Sales Email Settings" else "Job Applicant" account.insert() + # sales, jobs + for doctype in ("Sales Email Settings", "Jobs Email Settings"): + if frappe.db.exists("DocType", doctype): + source = dict(frappe.db.sql("select field, value from tabSingles where doctype=%s", doctype)) + account = frappe.new_doc("Email Account") + mapping = { + "enable_incoming": "extract_emails", + "email_id": "username", + "password": "password", + "pop3_server": "host", + "use_ssl": "use_ssl", + } + + for target_fieldname, source_fieldname in mapping.iteritems(): + account.set(target_fieldname, source.get(source_fieldname)) + + account.enable_outgoing = 0 + account.is_global = 1 + account.append_to = "Lead" if doctype=="Sales Email Settings" else "Job Applicant" + + account.insert() + for doctype in ("Outgoing Email Settings", "Support Email Settings", "Sales Email Settings", "Jobs Email Settings"): frappe.delete_doc("DocType", doctype)