Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions versa_system/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@
}
}





# Scheduled Tasks
# ---------------

Expand Down
12 changes: 12 additions & 0 deletions versa_system/public/js/lead.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,17 @@ frappe.ui.form.on("Lead", {
}
});

frappe.ui.form.on('Lead', {
refresh: function(frm) {
frm.fields_dict['material_details'].grid.get_field('product_item').get_query = function(doc, cdt, cdn) {
return {
query: "versa_system.versa_system.custom_script.lead.get_only_products"
};
};
}
});





26 changes: 15 additions & 11 deletions versa_system/public/js/quotation.js
Original file line number Diff line number Diff line change
@@ -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")
);
}
}
});
});
3 changes: 0 additions & 3 deletions versa_system/public/js/sales_order.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
17 changes: 17 additions & 0 deletions versa_system/versa_system/custom_script/lead.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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]
46 changes: 30 additions & 16 deletions versa_system/versa_system/custom_script/quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,57 @@ 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:
# Append to 'material_item' table if it exists
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}")

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

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
"product_item": 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(
"MOC Design", source_name,
{
"MOC Design": {
"doctype": "Quotation"
"doctype": "Quotation",
"field_map": {
"lead": "party_name"
}
}
}, # Removed the duplicate 'Lead Material Details' mapping
},
target_doc,
set_missing_values
)

return target_doc

3 changes: 1 addition & 2 deletions versa_system/versa_system/custom_script/work_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"fieldname": "lead",
"fieldtype": "Link",
"label": "Lead ",
"options": "Lead"
"options": "Lead",
"read_only": 1
},
{
"fieldname": "feasible_material_details",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand All @@ -45,3 +48,4 @@ def set_missing_values(source,target):




Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"image",
"feasible",
"quantity",
"availability"
"availability",
"product_item"
],
"fields": [
{
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion versa_system/versa_system/doctype/moc_design/moc_design.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
8 changes: 5 additions & 3 deletions versa_system/versa_system/doctype/moc_design/moc_design.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
42 changes: 18 additions & 24 deletions versa_system/versa_system/doctype/moc_design/moc_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,31 @@ 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", [])

target_doc = get_mapped_doc(
"Feasibility Check", source_name,
filtered_materials = [row for row in source.get("feasible_material_details") if row.get("feasible")]

for row in filtered_materials:
target.append("moc_design", {
"material_type": row.material_type,
"product_item":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,
{
"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

Empty file.
Empty file.
Loading