fix(customer): quick form and integration fixes (#37386)
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index a7a1aa2..9e6095f 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -638,7 +638,7 @@
contact = frappe.get_doc(
{
"doctype": "Contact",
- "first_name": args.get("name"),
+ "first_name": args.get("customer_name"),
"is_primary_contact": is_primary_contact,
"links": [{"link_doctype": args.get("doctype"), "link_name": args.get("name")}],
}
@@ -647,12 +647,16 @@
contact.add_email(args.get("email_id"), is_primary=True)
if args.get("mobile_no"):
contact.add_phone(args.get("mobile_no"), is_primary_mobile_no=True)
- contact.insert()
+
+ if flags := args.get("flags"):
+ contact.insert(ignore_permissions=flags.get("ignore_permissions"))
+ else:
+ contact.insert()
return contact
-def make_address(args, is_primary_address=1):
+def make_address(args, is_primary_address=1, is_shipping_address=1):
reqd_fields = []
for field in ["city", "country"]:
if not args.get(field):
@@ -668,16 +672,23 @@
address = frappe.get_doc(
{
"doctype": "Address",
- "address_title": args.get("name"),
+ "address_title": args.get("customer_name"),
"address_line1": args.get("address_line1"),
"address_line2": args.get("address_line2"),
"city": args.get("city"),
"state": args.get("state"),
"pincode": args.get("pincode"),
"country": args.get("country"),
+ "is_primary_address": is_primary_address,
+ "is_shipping_address": is_shipping_address,
"links": [{"link_doctype": args.get("doctype"), "link_name": args.get("name")}],
}
- ).insert()
+ )
+
+ if flags := args.get("flags"):
+ address.insert(ignore_permissions=flags.get("ignore_permissions"))
+ else:
+ address.insert()
return address