Hi,
In address doctype once a address is created its address type is automatically set in the adress name.
How to set the address name without the address type?
Hi,
In address doctype once a address is created its address type is automatically set in the adress name.
How to set the address name without the address type?
That for, please apply the server script.
if not doc.address_title:
if doc.links:
doc.address_title = doc.links[0].link_name
if doc.address_title:
doc.name = frappe.utils.cstr(doc.address_title).strip()
if frappe.db.exists("Address", doc.name):
last_name = frappe.db.get_value("Address", {"name": ["like", doc.name + "-%"]}, "name", order_by="creation desc")
if last_name:
last_number = int(last_name.split('-')[-1]) + 1
doc.name = f"{doc.name}-{last_number}"
else:
doc.name = f"{doc.name}-1"
else:
frappe.throw(_("Address Title is mandatory."))
Output:
you can modify the code according to the scenario.