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
14 changes: 14 additions & 0 deletions versa_system/versa_system/custom_script/quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,17 @@ def filter_approved_items(source, target, source_parent):
)

return target_doc

@frappe.whitelist()
def get_quotations_by_lead(lead_name):
"""
Function to fetch all Quotations associated with a specific Lead.
This method is intended to be called from the client side via an API call
"""
if not lead_name:
frappe.throw(_("Lead name is required"))
return frappe.get_all(
"Quotation",
filters={"party_name": lead_name}, # Use the correct field here
fields=["name"]
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,33 @@ frappe.ui.form.on('Raw Material Request', {
}
);
}

// Add "Go to Quotation" button if all rows are checked
if (all_checked) {
frm.add_custom_button(
__('Go to Quotation'),
function() {
frappe.call({
method: "frappe.client.get_list",
args: {
doctype: "Quotation",
fields: ["name"]
},
callback: function(response) {
if (response.message && response.message.length > 0) {
// Navigate to the existing Quotation
frappe.set_route('Form', 'Quotation', response.message[0].name);
} else {
// Create and navigate to a new Quotation
frappe.new_doc('Quotation');
}
}
});
// Add a custom button labeled 'Go to Quotation' in the form
if (all_checked){
frm.add_custom_button(__('Go to Quotation'), function() {
if (!frm.doc.lead) {
frappe.msgprint(__('No Lead is linked to this Raw Material Request.'));
return;
}
frappe.call({
method: "versa_system.versa_system.custom_script.quotation.get_quotations_by_lead",
args: {
lead_name: frm.doc.lead
},
callback: function(response) {
if (response.message && response.message.length > 0) {
frappe.set_route("Form", "Quotation", response.message[0].name);
} else {
frappe.msgprint(__('No Quotation is linked to the Lead associated with this Raw Material Request.'));
}
}
);
}
});
});
}

if (frm.fields_dict['item_details']) {
frm.fields_dict['item_details'].grid.toggle_display('is_customized', false);
frm.fields_dict['item_details'].grid.toggle_display('is_feasible', false);
frm.fields_dict['item_details'].grid.toggle_display('is_customized', false); // Hide the 'is_customized' column in the child table
frm.fields_dict['item_details'].grid.toggle_display('is_feasible', false); // Hide the 'is_feasible' column in the child table

}
}
});