mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-11 19:05:08 +00:00
Co-authored-by: Sakthivel Murugan S <129778327+ssakthivelmurugan@users.noreply.github.com> fix: set customer details on customer creation at login (#53509)
This commit is contained in:
@@ -47,21 +47,8 @@ def create_customer_or_supplier():
|
|||||||
if party_exists(doctype, user):
|
if party_exists(doctype, user):
|
||||||
return
|
return
|
||||||
|
|
||||||
party = frappe.new_doc(doctype)
|
|
||||||
fullname = frappe.utils.get_fullname(user)
|
fullname = frappe.utils.get_fullname(user)
|
||||||
|
party = create_party(doctype, fullname)
|
||||||
if doctype != "Customer":
|
|
||||||
party.update(
|
|
||||||
{
|
|
||||||
"supplier_name": fullname,
|
|
||||||
"supplier_group": "All Supplier Groups",
|
|
||||||
"supplier_type": "Individual",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
party.flags.ignore_mandatory = True
|
|
||||||
party.insert(ignore_permissions=True)
|
|
||||||
|
|
||||||
alternate_doctype = "Customer" if doctype == "Supplier" else "Supplier"
|
alternate_doctype = "Customer" if doctype == "Supplier" else "Supplier"
|
||||||
|
|
||||||
if party_exists(alternate_doctype, user):
|
if party_exists(alternate_doctype, user):
|
||||||
@@ -69,6 +56,22 @@ def create_customer_or_supplier():
|
|||||||
fullname += "-" + doctype
|
fullname += "-" + doctype
|
||||||
|
|
||||||
create_party_contact(doctype, fullname, user, party.name)
|
create_party_contact(doctype, fullname, user, party.name)
|
||||||
|
return party
|
||||||
|
|
||||||
|
|
||||||
|
def create_party(doctype, fullname):
|
||||||
|
party = frappe.new_doc(doctype)
|
||||||
|
# Can't set parent party as group
|
||||||
|
|
||||||
|
party.update(
|
||||||
|
{
|
||||||
|
f"{doctype.lower()}_name": fullname,
|
||||||
|
f"{doctype.lower()}_type": "Individual",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
party.flags.ignore_mandatory = True
|
||||||
|
party.insert(ignore_permissions=True)
|
||||||
|
|
||||||
return party
|
return party
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user