@@ -79,7 +79,7 @@ def share_with_agent(self, agent):
79
79
elif user != agent :
80
80
frappe .share .remove (self .doctype , self .name , user )
81
81
82
- def create_contact (self , throw = True ):
82
+ def create_contact (self , throw = False ):
83
83
if not self .lead_name :
84
84
self .set_full_name ()
85
85
self .set_lead_name ()
@@ -162,36 +162,13 @@ def contact_exists(self, throw=True):
162
162
return False
163
163
164
164
def create_opportunity (self , contact , customer ):
165
- opportunity = frappe .new_doc ("Opportunity" )
166
-
167
- lead_opportunity_map = {
168
- "lead_owner" : "opportunity_owner" ,
169
- }
170
-
171
- restricted_fieldtypes = ["Tab Break" , "Section Break" , "Column Break" , "HTML" , "Button" , "Attach" , "Table" ]
172
- restricted_map_fields = ["name" , "naming_series" , "creation" , "owner" , "modified" , "modified_by" , "idx" , "docstatus" , "status" , "email_id" , "mobile_no" , "phone" , "sla" , "sla_status" , "response_by" , "first_response_time" , "first_responded_on" , "communication_status" , "sla_creation" ]
173
-
174
- for field in self .meta .fields :
175
- if field .fieldtype in restricted_fieldtypes :
176
- continue
177
- if field .fieldname in restricted_map_fields :
178
- continue
179
-
180
- fieldname = field .fieldname
181
- if field .fieldname in lead_opportunity_map :
182
- fieldname = lead_opportunity_map [field .fieldname ]
183
-
184
- if hasattr (opportunity , fieldname ):
185
- if fieldname == "customer" :
186
- opportunity .update ({fieldname : customer })
187
- else :
188
- opportunity .update ({fieldname : self .get (field .fieldname )})
165
+ from erpnext .crm .doctype .lead .lead import make_opportunity
166
+ opportunity = make_opportunity (self .name )
189
167
190
168
opportunity .update (
191
169
{
192
- "opportunity_from" : "lead" ,
193
- "party_name" : self .name ,
194
170
"contacts" : [{"contact" : contact }],
171
+ "customer" : customer
195
172
}
196
173
)
197
174
0 commit comments