diff --git a/crm/fcrm/doctype/crm_agent/crm_agent.json b/crm/fcrm/doctype/crm_agent/crm_agent.json index e3ee9758..c765290d 100644 --- a/crm/fcrm/doctype/crm_agent/crm_agent.json +++ b/crm/fcrm/doctype/crm_agent/crm_agent.json @@ -49,6 +49,8 @@ "label": "Image" }, { + "fetch_from": "user.first_name", + "fetch_if_empty": 1, "fieldname": "first_name", "fieldtype": "Data", "in_list_view": 1, @@ -70,7 +72,7 @@ "image_field": "image", "index_web_pages_for_search": 1, "links": [], - "modified": "2025-05-21 13:25:01.497196", + "modified": "2025-05-21 16:35:07.667954", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Agent", diff --git a/crm/fcrm/doctype/crm_agent/crm_agent.py b/crm/fcrm/doctype/crm_agent/crm_agent.py index 5cde4225..34c524b6 100644 --- a/crm/fcrm/doctype/crm_agent/crm_agent.py +++ b/crm/fcrm/doctype/crm_agent/crm_agent.py @@ -6,7 +6,19 @@ from frappe.model.document import Document class CRMAgent(Document): - pass + def validate(self): + if self.user: + user = frappe.get_doc("User", self.user) + if not self.first_name: + self.first_name = user.first_name + if not self.middle_name: + self.middle_name = user.middle_name + if not self.last_name: + self.last_name = user.last_name + if not self.agent_name: + self.agent_name = user.full_name + if not self.image: + self.image = user.user_image @frappe.whitelist()