feat:assign appointments from opportunity
diff --git a/erpnext/crm/doctype/appointment/appointment.py b/erpnext/crm/doctype/appointment/appointment.py
index 2da4acc..5615ae1 100644
--- a/erpnext/crm/doctype/appointment/appointment.py
+++ b/erpnext/crm/doctype/appointment/appointment.py
@@ -106,6 +106,16 @@
         self.lead = lead.name
 
     def auto_assign(self):
+		# If the latest opportunity is assigned to someone
+		# Assign the appointment to the same
+		existing_assignee = self.get_assignee_from_latest_opportunity()
+		if existing_assignee:
+			add_assignemnt({
+				'doctype':self.doctype
+				'name':self.name
+				'assign_to':existing_assignee
+			})
+			return
         if self._assign:
             return
         available_agents = _get_agents_sorted_by_asc_workload(
@@ -120,6 +130,25 @@
                 })
             break
 
+    def get_assignee_from_latest_opportunity(self):
+        if not self.lead:
+            return None
+        if not frappe.db.exists('Lead', self.lead):
+            return None
+        opporutnities = frappe.get_list(
+            'Opportunity',
+            filters={
+                'party_name': self.lead,
+            },
+            order_by='creation desc')
+        latest_opportunity = frappe.get_doc(
+            'Opportunity', opporutnities[0].name)
+        assignee = latest_opportunity._assign
+        if not assignee:
+            return None
+        assignee = frappe.parse_json(assignee)[0]
+        return assignee
+
     def create_calendar_event(self):
         if self.calendar_event:
             return