[Enhancement] Added supplier quotation link on rfq
This commit is contained in:
		
							parent
							
								
									7fb79d175f
								
							
						
					
					
						commit
						a26f685b9f
					
				| @ -192,8 +192,6 @@ def create_supplier_quotation(doc): | ||||
| 	if isinstance(doc, basestring): | ||||
| 		doc = json.loads(doc) | ||||
| 
 | ||||
| 	validate_duplicate_supplier_quotation(doc) | ||||
| 
 | ||||
| 	try: | ||||
| 		sq_doc = frappe.get_doc({ | ||||
| 			"doctype": "Supplier Quotation", | ||||
| @ -245,13 +243,3 @@ def get_rfq_doc(doctype, name, supplier_idx): | ||||
| 		args = doc.get('suppliers')[cint(supplier_idx) - 1] | ||||
| 		doc.update_supplier_part_no(args) | ||||
| 		return doc | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
| def validate_duplicate_supplier_quotation(args): | ||||
| 	data = frappe.db.sql("""select sq.name as name from `tabSupplier Quotation` sq,  | ||||
| 		`tabSupplier Quotation Item` sqi where sqi.parent = sq.name and sq.supplier = %(supplier)s  | ||||
| 		and sqi.request_for_quotation = %(rfq)s and sq.docstatus < 2""", | ||||
| 		{'supplier': args.get('supplier'), 'rfq': args.get('name')}, as_dict=True) | ||||
| 
 | ||||
| 	if data and data[0] and data[0].name: | ||||
| 		frappe.throw(_("Already supplier quotation has created")) | ||||
|  | ||||
| @ -18,6 +18,7 @@ rfq = Class.extend({ | ||||
| 		this.change_rate(); | ||||
| 		this.terms(); | ||||
| 		this.submit_rfq(); | ||||
| 		this.navigate_quotations(); | ||||
| 	}, | ||||
| 
 | ||||
| 	onfocus_select_all: function(){ | ||||
| @ -89,5 +90,12 @@ rfq = Class.extend({ | ||||
| 				} | ||||
| 			}) | ||||
| 		}) | ||||
| 	}, | ||||
| 
 | ||||
| 	navigate_quotations: function() { | ||||
| 		$('.quotations').click(function(){ | ||||
| 			name = $(this).attr('idx') | ||||
| 			window.location.href = "/quotations/" + encodeURIComponent(name); | ||||
| 		}) | ||||
| 	} | ||||
| }) | ||||
|  | ||||
| @ -68,6 +68,31 @@ | ||||
| 				<textarea class="form-control terms-feedback" style="height: 100px;"></textarea> | ||||
| 			</div> | ||||
| 		</div> | ||||
| 		<hr> | ||||
| 		<div class="row"> | ||||
| 			<div class="result"> | ||||
| 				<div class="col-xs-12"> | ||||
| 					<p class="text-muted small">{{ _("Quotations: ") }}</p> | ||||
| 					{% if doc.rfq_links %} | ||||
| 						{% for d in doc.rfq_links %} | ||||
| 							<div class="web-list-item transaction-list-item quotations" idx="{{d.name}}"> | ||||
| 								<div class="row"> | ||||
| 									<div class="col-sm-6"> | ||||
| 										<span class="indicator darkgrey"><a href="/quotations/{{d.name}}">{{d.name}}</a></span> | ||||
| 									</div> | ||||
| 									<div class="col-sm-3"> | ||||
| 										<span class="small darkgrey">{{d.status}}</span> | ||||
| 									</div> | ||||
| 									<div class="col-sm-3"> | ||||
| 										<span class="small darkgrey">{{d.transaction_date}}</span> | ||||
| 									</div> | ||||
| 								</div> | ||||
| 							</div> | ||||
| 						{% endfor %} | ||||
| 					{% endif %} | ||||
| 				</div> | ||||
| 			</div> | ||||
| 		</div> | ||||
|     </div> | ||||
| </div> | ||||
| 
 | ||||
|  | ||||
| @ -4,6 +4,7 @@ | ||||
| from __future__ import unicode_literals | ||||
| import frappe | ||||
| from frappe import _ | ||||
| from frappe.utils import formatdate | ||||
| from erpnext.controllers.website_list_for_contact import (get_customers_suppliers, | ||||
| 					get_party_details) | ||||
| 
 | ||||
| @ -13,6 +14,7 @@ def get_context(context): | ||||
| 	context.doc = frappe.get_doc(frappe.form_dict.doctype, frappe.form_dict.name) | ||||
| 	context.parents = frappe.form_dict.parents | ||||
| 	context.doc.supplier = get_supplier() | ||||
| 	context.doc.rfq_links = get_link_quotation(context.doc.supplier, context.doc.name) | ||||
| 	unauthorized_user(context.doc.supplier) | ||||
| 	update_supplier_details(context) | ||||
| 	context["title"] = frappe.form_dict.name | ||||
| @ -42,3 +44,17 @@ def update_supplier_details(context): | ||||
| 	context.doc.currency_symbol = frappe.db.get_value("Currency", context.doc.currency, "symbol") | ||||
| 	context.doc.number_format = frappe.db.get_value("Currency", context.doc.currency, "number_format") | ||||
| 	context.doc.buying_price_list = supplier_doc.default_price_list or '' | ||||
| 
 | ||||
| def get_link_quotation(supplier, rfq): | ||||
| 	quotation = frappe.db.sql(""" select distinct `tabSupplier Quotation Item`.parent as name, | ||||
| 		`tabSupplier Quotation`.status, `tabSupplier Quotation`.transaction_date from | ||||
| 		`tabSupplier Quotation Item`, `tabSupplier Quotation` where `tabSupplier Quotation`.docstatus < 2 and | ||||
| 		`tabSupplier Quotation Item`.request_for_quotation =%(name)s and | ||||
| 		`tabSupplier Quotation Item`.parent = `tabSupplier Quotation`.name and | ||||
| 		`tabSupplier Quotation`.supplier = %(supplier)s order by `tabSupplier Quotation`.creation desc""", | ||||
| 		{'name': rfq, 'supplier': supplier}, as_dict=1) | ||||
| 
 | ||||
| 	for data in quotation: | ||||
| 		data.transaction_date = formatdate(data.transaction_date) | ||||
| 
 | ||||
| 	return quotation or None | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user