From bae61e43627fbdc53051d7886c95caf9b7c633fe Mon Sep 17 00:00:00 2001 From: sappu-hub Date: Wed, 12 Mar 2025 00:34:39 +0530 Subject: [PATCH 1/5] add : added filters in lead to only fetch products --- versa_system/hooks.py | 6 ++ versa_system/public/js/lead.js | 15 ++++ versa_system/public/js/quotation.js | 26 +++--- versa_system/public/js/sales_order.js | 3 - .../versa_system/custom_script/lead.py | 18 ++++ .../versa_system/custom_script/quotation.py | 38 +++++--- .../feasibility_check/feasibility_check.json | 5 +- .../feasibility_check/feasibility_check.py | 4 + .../doctype/final_design/final_design.json | 5 +- .../lead_material_details.json | 11 ++- .../doctype/moc_design/moc_design.json | 8 +- .../doctype/moc_design/moc_design.py | 88 ++++++++++++++----- versa_system/versa_system/report/__init__.py | 0 .../report/sales_order_report/__init__.py | 0 .../sales_order_report/sales_order_report.js | 8 ++ .../sales_order_report.json | 39 ++++++++ .../sales_order_report/sales_order_report.py | 9 ++ 17 files changed, 224 insertions(+), 59 deletions(-) create mode 100644 versa_system/versa_system/custom_script/lead.py create mode 100644 versa_system/versa_system/report/__init__.py create mode 100644 versa_system/versa_system/report/sales_order_report/__init__.py create mode 100644 versa_system/versa_system/report/sales_order_report/sales_order_report.js create mode 100644 versa_system/versa_system/report/sales_order_report/sales_order_report.json create mode 100644 versa_system/versa_system/report/sales_order_report/sales_order_report.py diff --git a/versa_system/hooks.py b/versa_system/hooks.py index 16bf1c6..2d277ab 100644 --- a/versa_system/hooks.py +++ b/versa_system/hooks.py @@ -145,6 +145,12 @@ "onload": "versa_system.versa_system.custom_script.work_order.update_sales_order_status_on_work_order_completion" } } +doc_events = { + "Lead": { + "on_change": "versa_system.versa_system.custom_script.lead.get_only_products" + } +} + diff --git a/versa_system/public/js/lead.js b/versa_system/public/js/lead.js index 3a7e77c..0bfc337 100644 --- a/versa_system/public/js/lead.js +++ b/versa_system/public/js/lead.js @@ -13,5 +13,20 @@ frappe.ui.form.on("Lead", { } }); +frappe.ui.form.on('Lead', { + refresh: function(frm) { + console.log("Lead form loaded - setting product filter"); + + frm.fields_dict['material_details'].grid.get_field('product_item').get_query = function(doc, cdt, cdn) { + console.log("Product item field filter applied"); + return { + query: "versa_system.versa_system.custom_script.lead.get_only_products" + }; + }; + } +}); + + + diff --git a/versa_system/public/js/quotation.js b/versa_system/public/js/quotation.js index 87c9bb1..692c08a 100644 --- a/versa_system/public/js/quotation.js +++ b/versa_system/public/js/quotation.js @@ -1,14 +1,18 @@ + + frappe.ui.form.on("Quotation", { refresh: function(frm) { - frm.add_custom_button( - __("GoTo Final Design"), - function () { - frappe.model.open_mapped_doc({ - method: "versa_system.versa_system.doctype.final_design.final_design.map_quotation_to_final_design", - source_name: frm.doc.name - }); - }, - __("Create") - ); + if (frm.doc.workflow_state === "Approved") { + frm.add_custom_button( + __("GoTo Final Design"), + function () { + frappe.model.open_mapped_doc({ + method: "versa_system.versa_system.doctype.final_design.final_design.map_quotation_to_final_design", + source_name: frm.doc.name + }); + }, + __("Create") + ); // <-- Corrected closing bracket + } } -}); \ No newline at end of file +}); diff --git a/versa_system/public/js/sales_order.js b/versa_system/public/js/sales_order.js index 9aaeb97..f32cfbb 100644 --- a/versa_system/public/js/sales_order.js +++ b/versa_system/public/js/sales_order.js @@ -1,16 +1,13 @@ frappe.ui.form.on("Sales Order", { refresh: function (frm) { - // Set the indicator label based on the current status setStatusIndicator(frm); }, status: function (frm) { - // Update the indicator label dynamically when the status changes setStatusIndicator(frm); }, }); -// Function to set the indicator label based on status function setStatusIndicator(frm) { if (frm.doc.status === "Proforma Invoice") { frm.page.set_indicator("Proforma Invoice", "blue"); diff --git a/versa_system/versa_system/custom_script/lead.py b/versa_system/versa_system/custom_script/lead.py new file mode 100644 index 0000000..1e89c98 --- /dev/null +++ b/versa_system/versa_system/custom_script/lead.py @@ -0,0 +1,18 @@ +import frappe + +@frappe.whitelist() +def get_only_products(doctype, txt='', searchfield='name', start=0, page_len=20, filters=None): + """ + Fetch only 'Products' from the Item doctype. + """ + items = frappe.db.get_list( + "Item", + filters={"item_group": "Products"}, + fields=["name"], + order_by="modified DESC", + start=start, + page_length=page_len + ) + + + return [(item["name"],) for item in items] diff --git a/versa_system/versa_system/custom_script/quotation.py b/versa_system/versa_system/custom_script/quotation.py index b2fa958..c40471b 100644 --- a/versa_system/versa_system/custom_script/quotation.py +++ b/versa_system/versa_system/custom_script/quotation.py @@ -9,6 +9,9 @@ def map_moc_design_to_quotation(source_name, target_doc=None): """ def set_missing_values(source, target): + + + lead_materials = frappe.get_all( "Lead Material Details", filters={"parent": source.name}, @@ -16,24 +19,33 @@ def set_missing_values(source, target): ) for item in lead_materials: + item_code = item.get("material_type") + + # Fetch `item_name` and `uom` from Item doctype + item_details = frappe.get_value("Item", item_code, ["item_name", "stock_uom"], as_dict=True) + + if not item_details: + frappe.throw(f"Item `{item_code}` not found in Item Master.") + # Append to 'material_item' table if it exists if hasattr(target, "material_item"): target.append("material_item", { - "material_type": item.material_type, - "size": item.size, - "brand": item.brand, - "rate_range": item.rate_range, - "image": item.image, - "feasible": item.feasible, - "quantity": item.quantity + "material_type": item_code, + "size": item.get("size"), + "brand": item.get("brand"), + "rate_range": item.get("rate_range"), + "image": item.get("image"), + "feasible": item.get("feasible"), + "quantity": item.get("quantity") }) - # Append to 'items' table if it exists if hasattr(target, "items"): target.append("items", { - "item_code": item.material_type, - "rate": item.rate_range, - "qty": item.quantity + "item_code": item_code, + "item_name": item_details["item_name"], + "rate": item.get("rate_range"), + "qty": item.get("quantity"), + "uom": item_details["stock_uom"] }) target_doc = get_mapped_doc( @@ -42,10 +54,12 @@ def set_missing_values(source, target): "MOC Design": { "doctype": "Quotation" } - }, # Removed the duplicate 'Lead Material Details' mapping + }, target_doc, set_missing_values ) return target_doc + + diff --git a/versa_system/versa_system/doctype/feasibility_check/feasibility_check.json b/versa_system/versa_system/doctype/feasibility_check/feasibility_check.json index 9e3e03e..cbd7e4c 100644 --- a/versa_system/versa_system/doctype/feasibility_check/feasibility_check.json +++ b/versa_system/versa_system/doctype/feasibility_check/feasibility_check.json @@ -14,7 +14,8 @@ "fieldname": "lead", "fieldtype": "Link", "label": "Lead ", - "options": "Lead" + "options": "Lead", + "read_only": 1 }, { "fieldname": "feasible_material_details", @@ -25,7 +26,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2025-02-28 02:44:35.596369", + "modified": "2025-03-04 23:53:23.789715", "modified_by": "Administrator", "module": "Versa System", "name": "Feasibility Check", diff --git a/versa_system/versa_system/doctype/feasibility_check/feasibility_check.py b/versa_system/versa_system/doctype/feasibility_check/feasibility_check.py index 127fe78..411bfdb 100644 --- a/versa_system/versa_system/doctype/feasibility_check/feasibility_check.py +++ b/versa_system/versa_system/doctype/feasibility_check/feasibility_check.py @@ -16,6 +16,8 @@ def map_lead_to_feasibility_check(source_name, target_doc=None): def set_missing_values(source,target): pass + + target_doc = get_mapped_doc("Lead", source_name, { "Lead": { @@ -26,6 +28,7 @@ def set_missing_values(source,target): "doctype": "Lead Material Details", "field_map": { "material_type": "material_type", + "product_item":"product_item", "size": "size", "brand": "brand", "rate_range": "rate_range", @@ -45,3 +48,4 @@ def set_missing_values(source,target): + diff --git a/versa_system/versa_system/doctype/final_design/final_design.json b/versa_system/versa_system/doctype/final_design/final_design.json index d1514dd..313536b 100644 --- a/versa_system/versa_system/doctype/final_design/final_design.json +++ b/versa_system/versa_system/doctype/final_design/final_design.json @@ -20,12 +20,13 @@ "fieldname": "lead", "fieldtype": "Link", "label": "Lead", - "options": "Lead" + "options": "Lead", + "read_only": 1 } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2025-02-25 22:19:47.411803", + "modified": "2025-03-05 21:04:15.751651", "modified_by": "Administrator", "module": "Versa System", "name": "Final Design", diff --git a/versa_system/versa_system/doctype/lead_material_details/lead_material_details.json b/versa_system/versa_system/doctype/lead_material_details/lead_material_details.json index 4259cd8..efa843e 100644 --- a/versa_system/versa_system/doctype/lead_material_details/lead_material_details.json +++ b/versa_system/versa_system/doctype/lead_material_details/lead_material_details.json @@ -13,7 +13,8 @@ "image", "feasible", "quantity", - "availability" + "availability", + "product_item" ], "fields": [ { @@ -60,12 +61,18 @@ "fieldtype": "Select", "label": "Availability", "options": "Available\nNot Available" + }, + { + "fieldname": "product_item", + "fieldtype": "Link", + "label": "Product Item", + "options": "Item" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2025-02-25 23:48:13.158021", + "modified": "2025-03-10 03:31:21.387104", "modified_by": "Administrator", "module": "Versa System", "name": "Lead Material Details", diff --git a/versa_system/versa_system/doctype/moc_design/moc_design.json b/versa_system/versa_system/doctype/moc_design/moc_design.json index bf746e5..5553190 100644 --- a/versa_system/versa_system/doctype/moc_design/moc_design.json +++ b/versa_system/versa_system/doctype/moc_design/moc_design.json @@ -21,18 +21,20 @@ "fieldname": "feasibility_check", "fieldtype": "Link", "label": "Feasibility Check", - "options": "Feasibility Check" + "options": "Feasibility Check", + "read_only": 1 }, { "fieldname": "lead", "fieldtype": "Link", "label": "Lead", - "options": "Lead" + "options": "Lead", + "read_only": 1 } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2025-02-23 22:03:54.661291", + "modified": "2025-03-04 23:54:59.326096", "modified_by": "Administrator", "module": "Versa System", "name": "MOC Design", diff --git a/versa_system/versa_system/doctype/moc_design/moc_design.py b/versa_system/versa_system/doctype/moc_design/moc_design.py index 98a87e6..2da9a38 100644 --- a/versa_system/versa_system/doctype/moc_design/moc_design.py +++ b/versa_system/versa_system/doctype/moc_design/moc_design.py @@ -1,5 +1,49 @@ +# import frappe +# from frappe.model.document import Document +# from frappe.model.mapper import get_mapped_doc + +# class MOCDesign(Document): +# pass + +# @frappe.whitelist() +# def map_feasibility_check_to_moc_design(source_name, target_doc=None): +# """ +# Map fields from Feasibility Check to MOC Design, +# including child table 'Feasible Material Details' -> 'MOC Material Details' +# """ +# def set_missing_values(source, target): +# pass + +# target_doc = get_mapped_doc( +# "Feasibility Check", source_name, +# { +# "Feasibility Check": { +# "doctype": "MOC Design", +# "field_map": {} + +# }, +# "Lead Material Details": { +# "doctype": "Lead Material Details", +# "field_map": { +# "material_type": "material_type", +# "size": "size", +# "brand": "brand", +# "rate_range": "rate_range", +# "image": "image", +# "feasible": "feasible", +# "quantity": "quantity" +# }, +# "add_if_empty": True +# } +# }, +# target_doc, +# set_missing_values +# ) + +# return target_doc + import frappe from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc @@ -10,37 +54,33 @@ class MOCDesign(Document): @frappe.whitelist() def map_feasibility_check_to_moc_design(source_name, target_doc=None): """ - Map fields from Feasibility Check to MOC Design, - including child table 'Feasible Material Details' -> 'MOC Material Details' + Map Feasibility Check to MOC Design, including only child table rows where 'feasible' is checked. """ def set_missing_values(source, target): - pass + target.set("Lead Material Details", []) + + # Filter only those rows where 'feasible' is checked + filtered_materials = [row for row in source.get("feasible_material_details") if row.get("feasible")] + + # Append only feasible items to the target document + for row in filtered_materials: + target.append("moc_design", { + "material_type": row.material_type, + "product_items":row.product_item, + "size": row.size, + "brand": row.brand, + "rate_range": row.rate_range, + "image": row.image, + "feasible": row.feasible, + "quantity": row.quantity + }) - target_doc = get_mapped_doc( - "Feasibility Check", source_name, + target_doc = get_mapped_doc("Feasibility Check", source_name, { "Feasibility Check": { "doctype": "MOC Design", "field_map": {} - - }, - "Lead Material Details": { - "doctype": "Lead Material Details", - "field_map": { - "material_type": "material_type", - "size": "size", - "brand": "brand", - "rate_range": "rate_range", - "image": "image", - "feasible": "feasible", - "quantity": "quantity" - }, - "add_if_empty": True } - }, - target_doc, - set_missing_values - ) + }, target_doc, set_missing_values) return target_doc - diff --git a/versa_system/versa_system/report/__init__.py b/versa_system/versa_system/report/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/versa_system/versa_system/report/sales_order_report/__init__.py b/versa_system/versa_system/report/sales_order_report/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/versa_system/versa_system/report/sales_order_report/sales_order_report.js b/versa_system/versa_system/report/sales_order_report/sales_order_report.js new file mode 100644 index 0000000..02df9e8 --- /dev/null +++ b/versa_system/versa_system/report/sales_order_report/sales_order_report.js @@ -0,0 +1,8 @@ +// Copyright (c) 2025, efeone and contributors +// For license information, please see license.txt + +frappe.query_reports["Sales Order Report"] = { + "filters": [ + + ] +}; diff --git a/versa_system/versa_system/report/sales_order_report/sales_order_report.json b/versa_system/versa_system/report/sales_order_report/sales_order_report.json new file mode 100644 index 0000000..e50eaa3 --- /dev/null +++ b/versa_system/versa_system/report/sales_order_report/sales_order_report.json @@ -0,0 +1,39 @@ +{ + "add_total_row": 0, + "columns": [], + "creation": "2025-03-03 00:37:59.668841", + "disabled": 0, + "docstatus": 0, + "doctype": "Report", + "filters": [], + "idx": 0, + "is_standard": "Yes", + "letterhead": null, + "modified": "2025-03-03 00:37:59.668841", + "modified_by": "Administrator", + "module": "Versa System", + "name": "Sales Order Report", + "owner": "Administrator", + "prepared_report": 0, + "ref_doctype": "Sales Order", + "report_name": "Sales Order Report", + "report_type": "Script Report", + "roles": [ + { + "role": "Sales User" + }, + { + "role": "Sales Manager" + }, + { + "role": "Maintenance User" + }, + { + "role": "Accounts User" + }, + { + "role": "Stock User" + } + ], + "timeout": 0 +} \ No newline at end of file diff --git a/versa_system/versa_system/report/sales_order_report/sales_order_report.py b/versa_system/versa_system/report/sales_order_report/sales_order_report.py new file mode 100644 index 0000000..dd44daa --- /dev/null +++ b/versa_system/versa_system/report/sales_order_report/sales_order_report.py @@ -0,0 +1,9 @@ +# Copyright (c) 2025, efeone and contributors +# For license information, please see license.txt + +# import frappe + + +def execute(filters=None): + columns, data = [], [] + return columns, data From 754ba5a76b30bb2c91c59cb94aec0bc06e54d6f1 Mon Sep 17 00:00:00 2001 From: sappu-hub Date: Thu, 13 Mar 2025 00:07:24 +0530 Subject: [PATCH 2/5] fix: after applying filters in product_items i make changes in py files to fetch the table properly --- versa_system/public/js/lead.js | 3 -- versa_system/public/js/quotation.js | 2 +- .../versa_system/custom_script/quotation.py | 24 +++++----- .../doctype/final_design/final_design.py | 3 -- .../doctype/moc_design/moc_design.py | 48 +------------------ 5 files changed, 14 insertions(+), 66 deletions(-) diff --git a/versa_system/public/js/lead.js b/versa_system/public/js/lead.js index 0bfc337..bf6f1af 100644 --- a/versa_system/public/js/lead.js +++ b/versa_system/public/js/lead.js @@ -15,10 +15,7 @@ frappe.ui.form.on("Lead", { frappe.ui.form.on('Lead', { refresh: function(frm) { - console.log("Lead form loaded - setting product filter"); - frm.fields_dict['material_details'].grid.get_field('product_item').get_query = function(doc, cdt, cdn) { - console.log("Product item field filter applied"); return { query: "versa_system.versa_system.custom_script.lead.get_only_products" }; diff --git a/versa_system/public/js/quotation.js b/versa_system/public/js/quotation.js index 692c08a..ccc8f77 100644 --- a/versa_system/public/js/quotation.js +++ b/versa_system/public/js/quotation.js @@ -12,7 +12,7 @@ frappe.ui.form.on("Quotation", { }); }, __("Create") - ); // <-- Corrected closing bracket + ); } } }); diff --git a/versa_system/versa_system/custom_script/quotation.py b/versa_system/versa_system/custom_script/quotation.py index c40471b..53e0dd7 100644 --- a/versa_system/versa_system/custom_script/quotation.py +++ b/versa_system/versa_system/custom_script/quotation.py @@ -9,28 +9,28 @@ def map_moc_design_to_quotation(source_name, target_doc=None): """ def set_missing_values(source, target): - - + target.party_name = source.lead lead_materials = frappe.get_all( "Lead Material Details", filters={"parent": source.name}, - fields=["material_type", "size", "brand", "rate_range", "quantity", "image", "feasible"] + fields=["product_item", "size", "brand", "rate_range", "quantity", "image", "feasible"] ) for item in lead_materials: - item_code = item.get("material_type") + item_code = item.get("product_item") + + if not item_code: + frappe.throw(f"Product Item is missing for an entry in Lead Material Details: {item}") - # Fetch `item_name` and `uom` from Item doctype item_details = frappe.get_value("Item", item_code, ["item_name", "stock_uom"], as_dict=True) if not item_details: - frappe.throw(f"Item `{item_code}` not found in Item Master.") + frappe.throw(f"Item {item_code} not found in Item Master.") - # Append to 'material_item' table if it exists if hasattr(target, "material_item"): target.append("material_item", { - "material_type": item_code, + "product_item": item_code, "size": item.get("size"), "brand": item.get("brand"), "rate_range": item.get("rate_range"), @@ -52,7 +52,10 @@ def set_missing_values(source, target): "MOC Design", source_name, { "MOC Design": { - "doctype": "Quotation" + "doctype": "Quotation", + "field_map": { + "lead": "party_name" + } } }, target_doc, @@ -60,6 +63,3 @@ def set_missing_values(source, target): ) return target_doc - - - diff --git a/versa_system/versa_system/doctype/final_design/final_design.py b/versa_system/versa_system/doctype/final_design/final_design.py index f28cf84..132630c 100644 --- a/versa_system/versa_system/doctype/final_design/final_design.py +++ b/versa_system/versa_system/doctype/final_design/final_design.py @@ -10,13 +10,10 @@ def before_save(self): self.fetch_lead_items() def fetch_lead_items(self): - # Fetch Lead document lead_doc = frappe.get_doc("Lead", self.lead) - # Clear existing items in the child table self.set("items", []) - # Check if the lead has a child table named 'lead_material_details' if hasattr(lead_doc, "lead_material_details"): for item in lead_doc.lead_material_details: self.append("items", { diff --git a/versa_system/versa_system/doctype/moc_design/moc_design.py b/versa_system/versa_system/doctype/moc_design/moc_design.py index 2da9a38..008b6b3 100644 --- a/versa_system/versa_system/doctype/moc_design/moc_design.py +++ b/versa_system/versa_system/doctype/moc_design/moc_design.py @@ -1,49 +1,5 @@ -# import frappe -# from frappe.model.document import Document -# from frappe.model.mapper import get_mapped_doc - -# class MOCDesign(Document): -# pass - -# @frappe.whitelist() -# def map_feasibility_check_to_moc_design(source_name, target_doc=None): -# """ -# Map fields from Feasibility Check to MOC Design, -# including child table 'Feasible Material Details' -> 'MOC Material Details' -# """ -# def set_missing_values(source, target): -# pass - -# target_doc = get_mapped_doc( -# "Feasibility Check", source_name, -# { -# "Feasibility Check": { -# "doctype": "MOC Design", -# "field_map": {} - -# }, -# "Lead Material Details": { -# "doctype": "Lead Material Details", -# "field_map": { -# "material_type": "material_type", -# "size": "size", -# "brand": "brand", -# "rate_range": "rate_range", -# "image": "image", -# "feasible": "feasible", -# "quantity": "quantity" -# }, -# "add_if_empty": True -# } -# }, -# target_doc, -# set_missing_values -# ) - -# return target_doc - import frappe from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc @@ -59,14 +15,12 @@ def map_feasibility_check_to_moc_design(source_name, target_doc=None): def set_missing_values(source, target): target.set("Lead Material Details", []) - # Filter only those rows where 'feasible' is checked filtered_materials = [row for row in source.get("feasible_material_details") if row.get("feasible")] - # Append only feasible items to the target document for row in filtered_materials: target.append("moc_design", { "material_type": row.material_type, - "product_items":row.product_item, + "product_item":row.product_item, "size": row.size, "brand": row.brand, "rate_range": row.rate_range, From a3eeed696f5b0ca719c08f8fa83f5d9fd122fcff Mon Sep 17 00:00:00 2001 From: sappu-hub Date: Thu, 13 Mar 2025 00:33:21 +0530 Subject: [PATCH 3/5] fix : changes made in hook.py removed unwantd line --- versa_system/hooks.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/versa_system/hooks.py b/versa_system/hooks.py index 2d277ab..6bf8baf 100644 --- a/versa_system/hooks.py +++ b/versa_system/hooks.py @@ -145,11 +145,7 @@ "onload": "versa_system.versa_system.custom_script.work_order.update_sales_order_status_on_work_order_completion" } } -doc_events = { - "Lead": { - "on_change": "versa_system.versa_system.custom_script.lead.get_only_products" - } -} + From 7e39d73c241b6650bb12a3b844ed613179268e1f Mon Sep 17 00:00:00 2001 From: sappu-hub Date: Sat, 15 Mar 2025 01:15:07 +0530 Subject: [PATCH 4/5] fix : workorder and material request button only shows after the save --- versa_system/versa_system/custom_script/lead.py | 1 - versa_system/versa_system/custom_script/work_order.py | 3 +-- .../doctype/feasibility_check/feasibility_check.js | 2 +- .../versa_system/doctype/material_check/material_check.js | 2 ++ versa_system/versa_system/doctype/moc_design/moc_design.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/versa_system/versa_system/custom_script/lead.py b/versa_system/versa_system/custom_script/lead.py index 1e89c98..c47aab4 100644 --- a/versa_system/versa_system/custom_script/lead.py +++ b/versa_system/versa_system/custom_script/lead.py @@ -14,5 +14,4 @@ def get_only_products(doctype, txt='', searchfield='name', start=0, page_len=20, page_length=page_len ) - return [(item["name"],) for item in items] diff --git a/versa_system/versa_system/custom_script/work_order.py b/versa_system/versa_system/custom_script/work_order.py index 57b6046..3136dbc 100644 --- a/versa_system/versa_system/custom_script/work_order.py +++ b/versa_system/versa_system/custom_script/work_order.py @@ -3,14 +3,13 @@ @frappe.whitelist() def update_sales_order_status_on_work_order_completion(doc, method): - # Fetch the latest status directly from the database + current_status = frappe.db.get_value("Work Order", doc.name, "status") if current_status == "Completed" and doc.sales_order: try: sales_order = frappe.get_doc("Sales Order", doc.sales_order) - # Check if status needs to be updated if sales_order.status != "Proforma Invoice": sales_order.status = "Proforma Invoice" sales_order.save(ignore_permissions=True) diff --git a/versa_system/versa_system/doctype/feasibility_check/feasibility_check.js b/versa_system/versa_system/doctype/feasibility_check/feasibility_check.js index 7def155..1f64c00 100644 --- a/versa_system/versa_system/doctype/feasibility_check/feasibility_check.js +++ b/versa_system/versa_system/doctype/feasibility_check/feasibility_check.js @@ -3,7 +3,7 @@ frappe.ui.form.on("Feasibility Check", { refresh(frm) { - if (frm.doc.workflow_state === "Approved") { // Ensure the button appears only after saving + if (frm.doc.workflow_state === "Approved") { frm.add_custom_button( __("GoTo MOC Design"), function () { diff --git a/versa_system/versa_system/doctype/material_check/material_check.js b/versa_system/versa_system/doctype/material_check/material_check.js index e82ffdd..cb11999 100644 --- a/versa_system/versa_system/doctype/material_check/material_check.js +++ b/versa_system/versa_system/doctype/material_check/material_check.js @@ -3,12 +3,14 @@ frappe.ui.form.on("Material Check", { refresh(frm) { + if(!frm.is_new()) frm.add_custom_button( __("Material Request"), function () { frappe.set_route("Form", "Material Request", "new-material-request"); } ); + if(!frm.is_new()) frm.add_custom_button( __("Work Order"), function () { diff --git a/versa_system/versa_system/doctype/moc_design/moc_design.js b/versa_system/versa_system/doctype/moc_design/moc_design.js index ad504a2..ded7978 100644 --- a/versa_system/versa_system/doctype/moc_design/moc_design.js +++ b/versa_system/versa_system/doctype/moc_design/moc_design.js @@ -3,7 +3,7 @@ frappe.ui.form.on("MOC Design", { refresh(frm) { - if (frm.doc.workflow_state === "Approved") { // Ensure the button appears only after saving + if (frm.doc.workflow_state === "Approved") { frm.add_custom_button( __("GoTo Quotation"), function () { From e9950913fb3b22e40a583ff78806db30085ef165 Mon Sep 17 00:00:00 2001 From: sappu-hub Date: Sat, 15 Mar 2025 01:46:01 +0530 Subject: [PATCH 5/5] fix : removed empty line from hooks --- versa_system/hooks.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/versa_system/hooks.py b/versa_system/hooks.py index 6bf8baf..290d7fc 100644 --- a/versa_system/hooks.py +++ b/versa_system/hooks.py @@ -146,12 +146,6 @@ } } - - - - - - # Scheduled Tasks # ---------------