fix: create Quality Inspection button not showing (backport #47746) (#47750)

fix: create Quality Inspection button not showing (#47746)

(cherry picked from commit d8cb073eaf)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot]
2025-05-27 13:06:32 +05:30
committed by GitHub
parent b9698366c3
commit 60dfe36195
3 changed files with 20 additions and 1 deletions

View File

@@ -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."""

View File

@@ -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()

View File

@@ -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"));