[Fixes] RFQ contact and multiple creation of supplier quotation issue

This commit is contained in:
Rohit Waghchaure 2016-07-06 17:26:15 +05:30
parent e739c0cf4e
commit f154c611bb
3 changed files with 27 additions and 3 deletions

View File

@ -100,8 +100,19 @@ frappe.ui.form.on("Request for Quotation",{
frappe.ui.form.on("Request for Quotation Supplier",{
supplier: function(frm, cdt, cdn) {
var d = locals[cdt][cdn]
frappe.model.set_value(cdt, cdn, 'contact', '')
frappe.model.set_value(cdt, cdn, 'email_id', '')
frappe.call({
method:"erpnext.accounts.party.get_party_details",
args:{
party: d.supplier,
party_type: 'Supplier'
},
callback: function(r){
if(r.message){
frappe.model.set_value(cdt, cdn, 'contact', r.message.contact_person)
frappe.model.set_value(cdt, cdn, 'email_id', r.message.contact_email)
}
}
})
},
download_pdf: function(frm, cdt, cdn) {

View File

@ -192,6 +192,8 @@ 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",
@ -242,4 +244,14 @@ def get_rfq_doc(doctype, name, supplier_idx):
doc = frappe.get_doc(doctype, name)
args = doc.get('suppliers')[cint(supplier_idx) - 1]
doc.update_supplier_part_no(args)
return doc
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"))

View File

@ -79,6 +79,7 @@ rfq = Class.extend({
},
btn: this,
callback: function(r){
$('.btn-sm').hide()
frappe.unfreeze();
}
})