Skip to content

Commit 5b4e3e9

Browse files
fix: set customer details on customer creation at login (backport #53509) (#53629)
Co-authored-by: Sakthivel Murugan S <129778327+ssakthivelmurugan@users.noreply.github.com> fix: set customer details on customer creation at login (#53509)
1 parent 2d1dd03 commit 5b4e3e9

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

erpnext/portal/utils.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,31 @@ def create_customer_or_supplier():
4747
if party_exists(doctype, user):
4848
return
4949

50-
party = frappe.new_doc(doctype)
5150
fullname = frappe.utils.get_fullname(user)
52-
53-
if doctype != "Customer":
54-
party.update(
55-
{
56-
"supplier_name": fullname,
57-
"supplier_group": "All Supplier Groups",
58-
"supplier_type": "Individual",
59-
}
60-
)
61-
62-
party.flags.ignore_mandatory = True
63-
party.insert(ignore_permissions=True)
64-
51+
party = create_party(doctype, fullname)
6552
alternate_doctype = "Customer" if doctype == "Supplier" else "Supplier"
6653

6754
if party_exists(alternate_doctype, user):
6855
# if user is both customer and supplier, alter fullname to avoid contact name duplication
6956
fullname += "-" + doctype
7057

7158
create_party_contact(doctype, fullname, user, party.name)
59+
return party
60+
61+
62+
def create_party(doctype, fullname):
63+
party = frappe.new_doc(doctype)
64+
# Can't set parent party as group
65+
66+
party.update(
67+
{
68+
f"{doctype.lower()}_name": fullname,
69+
f"{doctype.lower()}_type": "Individual",
70+
}
71+
)
72+
73+
party.flags.ignore_mandatory = True
74+
party.insert(ignore_permissions=True)
7275

7376
return party
7477

0 commit comments

Comments
 (0)