From d8cb073eafdfc5e35aca876c6af5f6fe285dfc7b Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 27 May 2025 12:18:39 +0530 Subject: [PATCH] fix: create Quality Inspection button not showing (#47746) --- erpnext/controllers/buying_controller.py | 8 ++++++++ erpnext/controllers/selling_controller.py | 8 ++++++++ erpnext/public/js/controllers/transaction.js | 5 ++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 67163ecf114..34ed97f43fc 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -70,6 +70,14 @@ class BuyingController(SubcontractingController): frappe.db.get_single_value("Buying Settings", "backflush_raw_materials_of_subcontract_based_on"), ) + if self.docstatus == 1 and self.doctype in ["Purchase Receipt", "Purchase Invoice"]: + self.set_onload( + "allow_to_make_qc_after_submission", + frappe.db.get_single_value( + "Stock Settings", "allow_to_make_quality_inspection_after_purchase_or_delivery" + ), + ) + def create_package_for_transfer(self) -> None: """Create serial and batch package for Sourece Warehouse in case of inter transfer.""" diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 1644160cf75..dff14d91daa 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -31,6 +31,14 @@ class SellingController(StockController): ) ) + if self.docstatus == 1 and self.doctype in ["Delivery Note", "Sales Invoice"]: + self.set_onload( + "allow_to_make_qc_after_submission", + frappe.db.get_single_value( + "Stock Settings", "allow_to_make_quality_inspection_after_purchase_or_delivery" + ), + ) + def validate(self): super().validate() self.validate_items() diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 7db0fb1a5b5..470791c4025 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -330,7 +330,10 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } const me = this; - if (!this.frm.is_new() && this.frm.doc.docstatus === 0 && frappe.model.can_create("Quality Inspection") && show_qc_button) { + if (!this.frm.is_new() + && (this.frm.doc.docstatus === 0 || this.frm.doc.__onload?.allow_to_make_qc_after_submission) + && frappe.model.can_create("Quality Inspection") + && show_qc_button) { this.frm.add_custom_button(__("Quality Inspection(s)"), () => { me.make_quality_inspection(); }, __("Create"));