added code to fetch item name and desc on change of item code

This commit is contained in:
Neil Trini Lasrado 2015-06-08 12:28:56 +05:30
parent 9fd42ed2f7
commit 9dbdef3bd5
3 changed files with 28 additions and 1 deletions

View File

@ -57,3 +57,18 @@ cur_frm.fields_dict['item_serial_no'].get_query = function(doc, cdt, cdn) {
return { filters: filter }
}
frappe.ui.form.on("Quality Inspection", "item_code", function(frm) {
frappe.call({
method: 'erpnext.buying.doctype.quality_inspection.quality_inspection.get_item_details',
args: {
"item_code": frm.doc.item_code
},
callback: function(r) {
if(!r.exc && r.message) {
frm.set_value("item_name", r.message.item_name);
frm.set_value("description", r.message.description);
}
}
});
})

View File

@ -127,6 +127,14 @@
"permlevel": 0,
"width": "50%"
},
{
"fieldname": "item_name",
"fieldtype": "Data",
"label": "Item Name",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "description",
"fieldtype": "Small Text",
@ -219,7 +227,7 @@
"icon": "icon-search",
"idx": 1,
"is_submittable": 1,
"modified": "2015-04-14 07:37:07.331291",
"modified": "2015-06-08 02:40:25.121948",
"modified_by": "Administrator",
"module": "Buying",
"name": "Quality Inspection",

View File

@ -39,6 +39,10 @@ class QualityInspection(Document):
where t1.parent = %s and t1.item_code = %s and t1.parent = t2.name""",
(self.modified, self.purchase_receipt_no, self.item_code))
@frappe.whitelist()
def get_item_details(item_code):
item_details = frappe.db.sql("select item_name, description from tabItem where item_code=%s", item_code, as_dict=1)
return item_details[0] if item_details else {}
def item_query(doctype, txt, searchfield, start, page_len, filters):
if filters.get("from"):