Merge pull request #45324 from frappe/mergify/bp/version-15-hotfix/pr-45298
fix: company in quality inspection (backport #45298)
This commit is contained in:
@@ -4,12 +4,26 @@
|
||||
cur_frm.cscript.refresh = cur_frm.cscript.inspection_type;
|
||||
|
||||
frappe.ui.form.on("Quality Inspection", {
|
||||
onload(frm) {
|
||||
frm.trigger("set_default_company");
|
||||
},
|
||||
|
||||
set_default_company(frm) {
|
||||
if (!frm.doc.company) {
|
||||
frm.set_value("company", frappe.defaults.get_default("company"));
|
||||
}
|
||||
},
|
||||
|
||||
setup: function (frm) {
|
||||
frm.set_query("reference_name", function () {
|
||||
frm.set_query("reference_name", function (doc) {
|
||||
let filters = { docstatus: ["!=", 2] };
|
||||
|
||||
if (doc.company) {
|
||||
filters["company"] = doc.company;
|
||||
}
|
||||
|
||||
return {
|
||||
filters: {
|
||||
docstatus: ["!=", 2],
|
||||
},
|
||||
filters: filters,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"naming_series",
|
||||
"company",
|
||||
"report_date",
|
||||
"status",
|
||||
"manual_inspection",
|
||||
"child_row_reference",
|
||||
"column_break_4",
|
||||
"inspection_type",
|
||||
"reference_type",
|
||||
"reference_name",
|
||||
"child_row_reference",
|
||||
"section_break_7",
|
||||
"item_code",
|
||||
"item_serial_no",
|
||||
@@ -27,6 +27,7 @@
|
||||
"bom_no",
|
||||
"specification_details",
|
||||
"quality_inspection_template",
|
||||
"manual_inspection",
|
||||
"readings",
|
||||
"section_break_14",
|
||||
"inspected_by",
|
||||
@@ -248,6 +249,12 @@
|
||||
"no_copy": 1,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"label": "Company",
|
||||
"options": "Company"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-search",
|
||||
@@ -255,7 +262,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-12-30 19:08:16.611192",
|
||||
"modified": "2025-01-16 17:00:48.774532",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Quality Inspection",
|
||||
|
||||
@@ -30,6 +30,7 @@ class QualityInspection(Document):
|
||||
batch_no: DF.Link | None
|
||||
bom_no: DF.Link | None
|
||||
child_row_reference: DF.Data | None
|
||||
company: DF.Link | None
|
||||
description: DF.SmallText | None
|
||||
inspected_by: DF.Link
|
||||
inspection_type: DF.Literal["", "Incoming", "Outgoing", "In Process"]
|
||||
@@ -76,6 +77,13 @@ class QualityInspection(Document):
|
||||
|
||||
self.validate_inspection_required()
|
||||
self.set_child_row_reference()
|
||||
self.set_company()
|
||||
|
||||
def set_company(self):
|
||||
if self.reference_type and self.reference_name:
|
||||
company = frappe.get_cached_value(self.reference_type, self.reference_name, "company")
|
||||
if company != self.company:
|
||||
self.company = company
|
||||
|
||||
def set_child_row_reference(self):
|
||||
if self.child_row_reference:
|
||||
|
||||
Reference in New Issue
Block a user