Hi,
I want to create a “MAKE” on my form named “Processing”, onClicking make button it should show the option of Sales Tax and takes to the doctype name “Sales Tax”.
like this:
Hi,
I want to create a “MAKE” on my form named “Processing”, onClicking make button it should show the option of Sales Tax and takes to the doctype name “Sales Tax”.
like this:
frappe.ui.form.on("Processing", "refresh", function(frm) {
frm.add_custom_button(__("Make"), function() {
// Do your magic here
},__("Sales Tax"));
});
@vishdha
thanks for your reply,
sorry to say your code isn’t working.
i’ve already scripted something for Processing doctype, and have put yours code at the end, please take a look into it. and please point out where i am doing mistake.
frappe.ui.form.on(“Processing”, {
weeksalea: function(frm) {
calculate_total(frm);
},
weeksaleb: function(frm) {
calculate_total(frm);
},
weeksalec: function(frm) {
calculate_total(frm);
},
weeksaled: function(frm) {
calculate_total(frm);
},
customer_primary_contact(frm)
{
assign_value(frm);
},
assign_to(frm)
{
assign_value(frm);
}
});
var assign_value = function (frm)
{
if(frm.doc.assign_to == “Key Accounts Manager 4”)
{
frm.set_df_property(“reconciled_by”, “options”, [“Bakhtiar”, “Saqib”, “Muzammil”]);
}
else if(frm.doc.assign_to == “Key Accounts Manager 3”)
{
frm.set_df_property(“reconciled_by”, “options”, [“Owais Warsi”, “Danish Javed”]);
}
else if(frm.doc.assign_to == “Key Accounts Manager 2”)
{
frm.set_df_property(“reconciled_by”, “options”, [“Waqas Jalees”, “Muhammed Ahmed”, “Waleed Siddiqui”, “Waqar Mukhtar”]);
}
}
var calculate_total = function(frm) {
frm.set_value(“total_period_sale”, frm.doc.weeksalea + frm.doc.weeksaleb + frm.doc.weeksalec + frm.doc.weeksaled);
}
frappe.ui.form.on(“Processing”, “refresh”, function(frm) {
frm.add_custom_button(__(“Make”), function() {
frappe.msgprint("Testing");
});
},__(“Sales Tax”));
});
I want to link that button to Sales Tax doctype, and processing auto generated id should be picked up automatically, Sales Tax’s doctype has a field with linked to Processing doctype.
I’ve used this script, its working but not picking up Processing Id into Sales Tax field (linked with Processing)
frappe.ui.form.on("Processing", "refresh", function(frm) {
frm.add_custom_button(__("Make Sales Tax"), function() {
frappe.set_route("Form", "Sales Tax", "New Sales Tax 1")
});
});
Below are some Screen Shots.
This is the processing ID auto generated.
please refer add_fetch(link_fieldname, source_fieldname, target_fieldname)
try this in sales tax custom script
cur_frm.add_fetch(‘Processing’,‘name’,‘processing_id’)
@vishdha it isn’t working, actually didn’t know that where to put these lines in my scripts. please guide.
i am providing you my both scripts.
Processing Script.
frappe.ui.form.on("Processing", "refresh", function(frm) {
frm.add_custom_button(__("Make Sales Tax"), function() {
frappe.set_route("Form", "Sales Tax", "New Sales Tax");
});
});
Sales Tax Script.
frappe.ui.form.on("Sales Tax", "processing_id", function(frm) {
frappe.call({
"method": "frappe.client.get",
"args": {
"doctype": "Processing",
"name": frm.doc.processing_id
},
"callback": function(response) {
var processing_id = response.message;
if (processing_id)
{
frm.set_value('taxabel_sales', processing_id.taxabel_sales_dollar);
frm.set_value('meal_tax', processing_id.meal_tax);
frm.set_value('sales_tax', processing_id.sales_tax);
frm.set_value('status', processing_id.status);
frm.set_value('week_sale_a', processing_id.weeksalea);
frm.set_value('week_sale_b', processing_id.weeksaleb);
frm.set_value('week_sale_c', processing_id.weeksalec);
frm.set_value('week_sale_d', processing_id.weeksaled);
frm.set_value('total_period_sale', processing_id.total_period_sale);
frm.set_value('non_taxable_sales', processing_id.non_taxable_sales);
}
}
});
});