Hi everyone,
I am building a new Contact Doctype from scratch called “contacts” with the help of the “contact” doctype.
I have not found out where in the contact.py file the update was being launched.
It seems the autoname(self) does not do that job.
Here is my own contacts.py:
import frappe
from frappe import _
from frappe.contacts.address_and_contact import set_link_title
from frappe.core.doctype.dynamic_link.dynamic_link import deduplicate_dynamic_links
from frappe.model.document import Document
from frappe.model.naming import append_number_if_name_exists
from frappe.utils import cstr
class Contacts(Document):
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from frappe.types import DF
first_name: DF.Data | None
full_name: DF.Data | None
last_name: DF.Data | None
def autoname(self):
self.name = self._get_full_name()
if frappe.db.exists("Contacts", self.name):
self.name = append_number_if_name_exists("Contacts", self.name)
def validate(self):
self.full_name = self._get_full_name()
def _get_full_name(self) -> str:
return get_full_name(self.first_name, self.last_name)
def get_full_name(
first: str | None = None,
last: str | None = None,
) -> str:
full_name = " ".join(filter(None, [cstr(f).strip() for f in [first, last]]))
return full_name
Many thanks for your input !