From 92f69ae484c8ccc552b5bbb34211c9f5187770c7 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Tue, 7 Oct 2025 18:07:16 +0530 Subject: [PATCH] fix: validate email address --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 7 ++++++- erpnext/public/js/print.js | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 4196608939a..ed259089fd5 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -308,7 +308,7 @@ class SalesInvoice(SellingController): "email": company_details.get("email"), "address_line": address_line, "company": self.company, - "company_address_display": self.company_address, + "company_address": self.company_address, "name": self.name, }, user=frappe.session.user, @@ -2839,9 +2839,14 @@ def get_loyalty_programs(customer): @frappe.whitelist() def save_company_master_details(name, company, details): + from frappe.utils import validate_email_address + if isinstance(details, str): details = frappe.parse_json(details) + if details.get("email"): + validate_email_address(details.email, throw=True) + company_fields = ["company_logo", "website", "phone_no", "email"] updated_fields = {field: details.get(field) for field in company_fields if details.get(field)} diff --git a/erpnext/public/js/print.js b/erpnext/public/js/print.js index 845746c56df..a85e488b352 100644 --- a/erpnext/public/js/print.js +++ b/erpnext/public/js/print.js @@ -5,6 +5,7 @@ frappe.realtime.on("sales_invoice_before_print", (data) => { if (!beforePrintHandled && route[0] === "print" && route[1] === "Sales Invoice") { beforePrintHandled = true; + let companyDetailsDialog = new frappe.ui.Dialog({ title: "Enter Company Details", fields: [ @@ -33,6 +34,7 @@ frappe.realtime.on("sales_invoice_before_print", (data) => { label: "Email", fieldname: "email", fieldtype: "Data", + options: "Email", reqd: data.email ? 0 : 1, hidden: data.email ? 1 : 0, },