diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.js b/erpnext/buying/doctype/quality_inspection/quality_inspection.js index 6b504c474e..3188c3c135 100644 --- a/erpnext/buying/doctype/quality_inspection/quality_inspection.js +++ b/erpnext/buying/doctype/quality_inspection/quality_inspection.js @@ -4,7 +4,7 @@ cur_frm.cscript.inspection_type = function(doc, cdt, cdn) { if(doc.inspection_type == 'Incoming'){ doc.delivery_note_no = ''; - hide_field('delivery_note_no'); + hide_field('delivery_note_no'); unhide_field('purchase_receipt_no'); } else if(doc.inspection_type == 'Outgoing'){ @@ -15,7 +15,7 @@ cur_frm.cscript.inspection_type = function(doc, cdt, cdn) { } else { doc.purchase_receipt_no = ''; - doc.delivery_note_no = ''; + doc.delivery_note_no = ''; hide_field('purchase_receipt_no'); hide_field('delivery_note_no'); } @@ -54,6 +54,6 @@ cur_frm.fields_dict['item_serial_no'].get_query = function(doc, cdt, cdn) { } } else filter = { 'status': "Available" } - + return { filters: filter } -} \ No newline at end of file +} diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.json b/erpnext/buying/doctype/quality_inspection/quality_inspection.json index 97d6f315f4..e1b57e4e08 100644 --- a/erpnext/buying/doctype/quality_inspection/quality_inspection.json +++ b/erpnext/buying/doctype/quality_inspection/quality_inspection.json @@ -4,21 +4,6 @@ "docstatus": 0, "doctype": "DocType", "fields": [ - { - "fieldname": "qa_inspection", - "fieldtype": "Section Break", - "label": "QA Inspection", - "no_copy": 0, - "oldfieldtype": "Section Break", - "permlevel": 0 - }, - { - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "permlevel": 0, - "width": "50%" - }, { "fieldname": "naming_series", "fieldtype": "Select", @@ -29,18 +14,7 @@ "reqd": 1 }, { - "fieldname": "inspection_type", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Inspection Type", - "oldfieldname": "inspection_type", - "oldfieldtype": "Select", - "options": "\nIncoming\nOutgoing\nIn Process", - "permlevel": 0, - "reqd": 1 - }, - { + "default": "Today", "fieldname": "report_date", "fieldtype": "Date", "in_filter": 1, @@ -53,67 +27,22 @@ "search_index": 1 }, { - "fieldname": "item_code", - "fieldtype": "Link", - "hidden": 0, + "fieldname": "column_break_4", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "inspection_type", + "fieldtype": "Select", "in_filter": 1, "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", + "label": "Inspection Type", + "oldfieldname": "inspection_type", + "oldfieldtype": "Select", + "options": "\nIncoming\nOutgoing\nIn Process", "permlevel": 0, - "reqd": 1, - "search_index": 1 - }, - { - "fieldname": "sample_size", - "fieldtype": "Float", - "in_filter": 0, - "label": "Sample Size", - "oldfieldname": "sample_size", - "oldfieldtype": "Currency", - "permlevel": 0, - "reqd": 1, - "search_index": 0 - }, - { - "fieldname": "description", - "fieldtype": "Small Text", - "in_filter": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "permlevel": 0, - "search_index": 0, - "width": "300px" - }, - { - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "permlevel": 0, - "width": "50%" - }, - { - "fieldname": "item_serial_no", - "fieldtype": "Link", - "hidden": 0, - "label": "Item Serial No", - "oldfieldname": "item_serial_no", - "oldfieldtype": "Link", - "options": "Serial No", - "permlevel": 0, - "print_hide": 0 - }, - { - "fieldname": "batch_no", - "fieldtype": "Link", - "label": "Batch No", - "oldfieldname": "batch_no", - "oldfieldtype": "Link", - "options": "Batch", - "permlevel": 0 + "reqd": 1 }, { "fieldname": "purchase_receipt_no", @@ -141,14 +70,105 @@ "search_index": 1 }, { + "fieldname": "section_break_7", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "item_serial_no", + "fieldtype": "Link", + "hidden": 0, + "label": "Item Serial No", + "oldfieldname": "item_serial_no", + "oldfieldtype": "Link", + "options": "Serial No", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "batch_no", + "fieldtype": "Link", + "label": "Batch No", + "oldfieldname": "batch_no", + "oldfieldtype": "Link", + "options": "Batch", + "permlevel": 0 + }, + { + "fieldname": "sample_size", + "fieldtype": "Float", + "in_filter": 0, + "label": "Sample Size", + "oldfieldname": "sample_size", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_filter": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "search_index": 0, + "width": "300px" + }, + { + "fieldname": "section_break_14", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "default": "user", "fieldname": "inspected_by", - "fieldtype": "Data", + "fieldtype": "Link", "label": "Inspected By", "oldfieldname": "inspected_by", "oldfieldtype": "Data", + "options": "User", "permlevel": 0, "reqd": 1 }, + { + "fieldname": "verified_by", + "fieldtype": "Data", + "label": "Verified By", + "oldfieldname": "verified_by", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "column_break_17", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "remarks", "fieldtype": "Text", @@ -158,14 +178,6 @@ "oldfieldtype": "Text", "permlevel": 0 }, - { - "fieldname": "verified_by", - "fieldtype": "Data", - "label": "Verified By", - "oldfieldname": "verified_by", - "oldfieldtype": "Data", - "permlevel": 0 - }, { "fieldname": "amended_from", "fieldtype": "Link", @@ -207,7 +219,7 @@ "icon": "icon-search", "idx": 1, "is_submittable": 1, - "modified": "2015-02-20 05:09:09.998457", + "modified": "2015-04-14 07:37:07.331291", "modified_by": "Administrator", "module": "Buying", "name": "Quality Inspection", diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index a2d5be5223..fe41b4fb93 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -4,6 +4,27 @@ {% include 'buying/doctype/purchase_common/purchase_common.js' %}; frappe.provide("erpnext.stock"); + +frappe.ui.form.on("Purchase Receipt", { + onload: function(frm) { + // default values for quotation no + var qa_no = frappe.meta.get_docfield("Purchase Receipt Item", "qa_no"); + qa_no.get_route_options_for_new_doc = function(field) { + if(frm.is_new()) return; + var doc = field.doc; + return { + "inspection_type": "Incoming", + "purchase_receipt_no": frm.doc.name, + "item_code": doc.item_code, + "description": doc.description, + "item_serial_no": doc.serial_no ? doc.serial_no.split("\n")[0] : null, + "batch_no": doc.batch_no + } + } + } +}); + + erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({ refresh: function() { this._super(); @@ -91,6 +112,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend }); + // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.stock.PurchaseReceiptController({frm: cur_frm})); diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index e785041234..9813251b7d 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -151,7 +151,7 @@ class PurchaseReceipt(BuyingController): })) self.bk_flush_supp_wh(sl_entries) - self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock, + self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock, via_landed_cost_voucher=via_landed_cost_voucher) def update_ordered_qty(self): @@ -199,6 +199,8 @@ class PurchaseReceipt(BuyingController): ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No' if ins_reqd == 'Yes' and not d.qa_no: frappe.msgprint(_("Quality Inspection required for Item {0}").format(d.item_code)) + if self.docstatus==1: + raise frappe.ValidationError # Check for Stopped status def check_for_stopped_status(self, pc_obj): @@ -206,7 +208,7 @@ class PurchaseReceipt(BuyingController): for d in self.get('items'): if d.meta.get_field('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list: check_list.append(d.prevdoc_docname) - pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname) + pc_obj.check_for_stopped_status(d.prevdoc_doctype, d.prevdoc_docname) # on submit def on_submit(self):