[mapper]
This commit is contained in:
		
							parent
							
								
									2d2d800f0f
								
							
						
					
					
						commit
						fcd9434daf
					
				| @ -55,8 +55,8 @@ erpnext.LeadController = wn.ui.form.Controller.extend({ | |||||||
| 		 | 		 | ||||||
| 		this.frm.__is_customer = this.frm.__is_customer || this.frm.doc.__is_customer; | 		this.frm.__is_customer = this.frm.__is_customer || this.frm.doc.__is_customer; | ||||||
| 		if(!this.frm.doc.__islocal && !this.frm.__is_customer) { | 		if(!this.frm.doc.__islocal && !this.frm.__is_customer) { | ||||||
| 			this.frm.add_custom_button("Create Customer", this.frm.cscript['Create Customer']); | 			this.frm.add_custom_button("Create Customer", this.create_customer); | ||||||
| 			this.frm.add_custom_button("Create Opportunity", this.frm.cscript['Create Opportunity']); | 			this.frm.add_custom_button("Create Opportunity", this.create_opportunity); | ||||||
| 			this.frm.add_custom_button("Send SMS", this.frm.cscript.send_sms); | 			this.frm.add_custom_button("Send SMS", this.frm.cscript.send_sms); | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| @ -93,21 +93,21 @@ erpnext.LeadController = wn.ui.form.Controller.extend({ | |||||||
| 			// note: render_address_row is defined in contact_control.js
 | 			// note: render_address_row is defined in contact_control.js
 | ||||||
| 		} | 		} | ||||||
| 		this.frm.address_list.run(); | 		this.frm.address_list.run(); | ||||||
| 	} | 	},  | ||||||
| }); |  | ||||||
| 	 | 	 | ||||||
| $.extend(cur_frm.cscript, new erpnext.LeadController({frm: cur_frm})); | 	create_customer: function() { | ||||||
| 
 |  | ||||||
| cur_frm.cscript['Create Customer'] = function(){ |  | ||||||
| 		wn.model.open_mapped_doc({ | 		wn.model.open_mapped_doc({ | ||||||
| 			method: "selling.doctype.lead.lead.make_customer", | 			method: "selling.doctype.lead.lead.make_customer", | ||||||
| 			source_name: cur_frm.doc.name | 			source_name: cur_frm.doc.name | ||||||
| 		}) | 		}) | ||||||
| } | 	},  | ||||||
| 	 | 	 | ||||||
| cur_frm.cscript['Create Opportunity'] = function(){ | 	create_opportunity: function() { | ||||||
| 		wn.model.open_mapped_doc({ | 		wn.model.open_mapped_doc({ | ||||||
| 			method: "selling.doctype.lead.lead.make_opportunity", | 			method: "selling.doctype.lead.lead.make_opportunity", | ||||||
| 			source_name: cur_frm.doc.name | 			source_name: cur_frm.doc.name | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | $.extend(cur_frm.cscript, new erpnext.LeadController({frm: cur_frm})); | ||||||
| @ -35,6 +35,13 @@ erpnext.selling.Opportunity = wn.ui.form.Controller.extend({ | |||||||
| 				'address_display', 'contact_display', 'contact_mobile', 'contact_email',  | 				'address_display', 'contact_display', 'contact_mobile', 'contact_email',  | ||||||
| 				'territory', 'customer_group']); | 				'territory', 'customer_group']); | ||||||
| 		} | 		} | ||||||
|  | 	},  | ||||||
|  | 	 | ||||||
|  | 	create_quotation: function() { | ||||||
|  | 		wn.model.open_mapped_doc({ | ||||||
|  | 			method: "selling.doctype.opportunity.opportunity.make_quotation", | ||||||
|  | 			source_name: cur_frm.doc.name | ||||||
|  | 		}) | ||||||
| 	} | 	} | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| @ -54,7 +61,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){ | |||||||
| 	 | 	 | ||||||
| 	cur_frm.clear_custom_buttons(); | 	cur_frm.clear_custom_buttons(); | ||||||
| 	if(doc.docstatus === 1 && doc.status!=="Opportunity Lost") { | 	if(doc.docstatus === 1 && doc.status!=="Opportunity Lost") { | ||||||
| 		cur_frm.add_custom_button('Create Quotation', cur_frm.cscript['Create Quotation']); | 		cur_frm.add_custom_button('Create Quotation', cur_frm.cscript.create_quotation); | ||||||
| 		cur_frm.add_custom_button('Opportunity Lost', cur_frm.cscript['Declare Opportunity Lost']); | 		cur_frm.add_custom_button('Opportunity Lost', cur_frm.cscript['Declare Opportunity Lost']); | ||||||
| 		cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); | 		cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); | ||||||
| 	} | 	} | ||||||
| @ -168,24 +175,15 @@ cur_frm.fields_dict['lead'].get_query = function(doc,cdt,cdn){ | |||||||
| cur_frm.cscript.lead = function(doc, cdt, cdn) { | cur_frm.cscript.lead = function(doc, cdt, cdn) { | ||||||
| 	cur_frm.toggle_display("contact_info", doc.customer || doc.lead); | 	cur_frm.toggle_display("contact_info", doc.customer || doc.lead); | ||||||
| 	 | 	 | ||||||
| 	if(doc.lead) { | 	wn.model.map_current_doc({ | ||||||
| 		cur_frm.call({ | 		method: "selling.doctype.lead.lead.make_opportunity", | ||||||
| 			doc: cur_frm.doc, | 		source_name: cur_frm.doc.lead | ||||||
| 			method: "set_lead_defaults", | 	}) | ||||||
| 			callback: function(r) { | 	 | ||||||
| 				if(!r.exc) { | 	unhide_field(['customer_name', 'address_display','contact_mobile',  | ||||||
| 					cur_frm.refresh_fields(); | 		'contact_email', 'territory']);	 | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		}); |  | ||||||
| 		unhide_field(['customer_name', 'address_display','contact_mobile', 'contact_email',  |  | ||||||
| 			'territory']);	 |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| //item getquery
 |  | ||||||
| //=======================================
 |  | ||||||
| cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) { | cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) { | ||||||
| 	if (doc.enquiry_type == 'Maintenance') | 	if (doc.enquiry_type == 'Maintenance') | ||||||
| 	 	return erpnext.queries.item({ | 	 	return erpnext.queries.item({ | ||||||
| @ -197,25 +195,6 @@ cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = f | |||||||
| 		}); | 		}); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Create New Quotation
 |  | ||||||
| cur_frm.cscript['Create Quotation'] = function(){ |  | ||||||
| 	n = wn.model.make_new_doc_and_get_name("Quotation"); |  | ||||||
| 	$c('dt_map', args={ |  | ||||||
| 		'docs':wn.model.compress([locals["Quotation"][n]]), |  | ||||||
| 		'from_doctype':'Opportunity', |  | ||||||
| 		'to_doctype':'Quotation', |  | ||||||
| 		'from_docname':cur_frm.docname, |  | ||||||
| 		'from_to_list':"[['Opportunity', 'Quotation'],['Opportunity Item','Quotation Item']]" |  | ||||||
| 	} |  | ||||||
| 	, function(r,rt) { |  | ||||||
| 		loaddoc("Quotation", n); |  | ||||||
| 		} |  | ||||||
| 	); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| // declare enquiry	lost
 |  | ||||||
| //-------------------------
 |  | ||||||
| cur_frm.cscript['Declare Opportunity Lost'] = function(){ | cur_frm.cscript['Declare Opportunity Lost'] = function(){ | ||||||
| 	var dialog = new wn.ui.Dialog({ | 	var dialog = new wn.ui.Dialog({ | ||||||
| 		title: "Set as Lost", | 		title: "Set as Lost", | ||||||
|  | |||||||
| @ -66,7 +66,6 @@ class DocType(TransactionBase): | |||||||
| 
 | 
 | ||||||
| 			contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where customer = '%s' and is_customer = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1) | 			contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where customer = '%s' and is_customer = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1) | ||||||
| 
 | 
 | ||||||
| 			 |  | ||||||
| 			ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or '' | 			ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or '' | ||||||
| 			ret['contact_no']		 = contact_det and contact_det[0]['contact_no'] or '' | 			ret['contact_no']		 = contact_det and contact_det[0]['contact_no'] or '' | ||||||
| 			ret['email_id']			 = contact_det and contact_det[0]['email_id'] or '' | 			ret['email_id']			 = contact_det and contact_det[0]['email_id'] or '' | ||||||
| @ -176,3 +175,31 @@ class DocType(TransactionBase): | |||||||
| 
 | 
 | ||||||
| 	def on_trash(self): | 	def on_trash(self): | ||||||
| 		self.delete_events() | 		self.delete_events() | ||||||
|  | 		 | ||||||
|  | @webnotes.whitelist() | ||||||
|  | def make_quotation(source_name, target_doclist=None): | ||||||
|  | 	from webnotes.model.mapper import get_mapped_doclist | ||||||
|  | 	 | ||||||
|  | 	doclist = get_mapped_doclist("Opportunity", source_name, { | ||||||
|  | 		"Opportunity": { | ||||||
|  | 			"doctype": "Quotation",  | ||||||
|  | 			"field_map": { | ||||||
|  | 				"enquiry_from": "quotation_to",  | ||||||
|  | 				"enquiry_type": "order_type",  | ||||||
|  | 				"name": "enq_no",  | ||||||
|  | 			}, | ||||||
|  | 			"validation": { | ||||||
|  | 				"docstatus": ["=", 1] | ||||||
|  | 			} | ||||||
|  | 		},  | ||||||
|  | 		"Opportunity Item": { | ||||||
|  | 			"doctype": "Quotation Item",  | ||||||
|  | 			"field_map": { | ||||||
|  | 				"parent": "prevdoc_docname",  | ||||||
|  | 				"parenttype": "prevdoc_doctype",  | ||||||
|  | 				"uom": "stock_uom" | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}, target_doclist) | ||||||
|  | 		 | ||||||
|  | 	return [d.fields for d in doclist] | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user