Skip to content

Commit

Permalink
fix(customer): quick form and integration fixes (#37386)
Browse files Browse the repository at this point in the history
(cherry picked from commit ae50814)
  • Loading branch information
blaggacao authored and mergify[bot] committed Nov 11, 2023
1 parent 99b7cdb commit b47a043
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions erpnext/selling/doctype/customer/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def make_contact(args, is_primary_contact=1):
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")}],
}
Expand All @@ -647,12 +647,16 @@ def make_contact(args, is_primary_contact=1):
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):
Expand All @@ -668,16 +672,23 @@ def make_address(args, is_primary_address=1):
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

Expand Down

0 comments on commit b47a043

Please sign in to comment.