mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-14 02:31:21 +00:00
Merge pull request #45718 from frappe/mergify/bp/version-15-hotfix/pr-45710
fix: show only items with inspection enabled on create QI dialog (backport #45710)
This commit is contained in:
@@ -1564,6 +1564,27 @@ def repost_required_for_queue(doc: StockController) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def check_item_quality_inspection(doctype, items):
|
||||||
|
if isinstance(items, str):
|
||||||
|
items = json.loads(items)
|
||||||
|
|
||||||
|
inspection_fieldname_map = {
|
||||||
|
"Purchase Receipt": "inspection_required_before_purchase",
|
||||||
|
"Purchase Invoice": "inspection_required_before_purchase",
|
||||||
|
"Subcontracting Receipt": "inspection_required_before_purchase",
|
||||||
|
"Sales Invoice": "inspection_required_before_delivery",
|
||||||
|
"Delivery Note": "inspection_required_before_delivery",
|
||||||
|
}
|
||||||
|
|
||||||
|
items_to_remove = []
|
||||||
|
for item in items:
|
||||||
|
if not frappe.db.get_value("Item", item.get("item_code"), inspection_fieldname_map.get(doctype)):
|
||||||
|
items_to_remove.append(item)
|
||||||
|
items = [item for item in items if item not in items_to_remove]
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_quality_inspections(doctype, docname, items):
|
def make_quality_inspections(doctype, docname, items):
|
||||||
if isinstance(items, str):
|
if isinstance(items, str):
|
||||||
|
|||||||
@@ -2367,29 +2367,39 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
primary_action_label: __("Create")
|
primary_action_label: __("Create")
|
||||||
});
|
});
|
||||||
|
|
||||||
this.frm.doc.items.forEach(item => {
|
frappe.call({
|
||||||
if (this.has_inspection_required(item)) {
|
method: "erpnext.controllers.stock_controller.check_item_quality_inspection",
|
||||||
let dialog_items = dialog.fields_dict.items;
|
args: {
|
||||||
dialog_items.df.data.push({
|
doctype: this.frm.doc.doctype,
|
||||||
"item_code": item.item_code,
|
items: this.frm.doc.items
|
||||||
"item_name": item.item_name,
|
},
|
||||||
"qty": item.qty,
|
freeze: true,
|
||||||
"description": item.description,
|
callback: function (r) {
|
||||||
"serial_no": item.serial_no,
|
r.message.forEach(item => {
|
||||||
"batch_no": item.batch_no,
|
if (me.has_inspection_required(item)) {
|
||||||
"sample_size": item.sample_quantity,
|
let dialog_items = dialog.fields_dict.items;
|
||||||
"child_row_reference": item.name,
|
dialog_items.df.data.push({
|
||||||
|
"item_code": item.item_code,
|
||||||
|
"item_name": item.item_name,
|
||||||
|
"qty": item.qty,
|
||||||
|
"description": item.description,
|
||||||
|
"serial_no": item.serial_no,
|
||||||
|
"batch_no": item.batch_no,
|
||||||
|
"sample_size": item.sample_quantity,
|
||||||
|
"child_row_reference": item.name,
|
||||||
|
});
|
||||||
|
dialog_items.grid.refresh();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
dialog_items.grid.refresh();
|
|
||||||
|
data = dialog.fields_dict.items.df.data;
|
||||||
|
if (!data.length) {
|
||||||
|
frappe.msgprint(__("All items in this document already have a linked Quality Inspection."));
|
||||||
|
} else {
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
data = dialog.fields_dict.items.df.data;
|
|
||||||
if (!data.length) {
|
|
||||||
frappe.msgprint(__("All items in this document already have a linked Quality Inspection."));
|
|
||||||
} else {
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
has_inspection_required(item) {
|
has_inspection_required(item) {
|
||||||
|
|||||||
Reference in New Issue
Block a user