Fetching default Selling Terms in Sales Invoice

I have created terms and conditions template with all the three checkboxes checked and set default selling terms in company master but its not automatically pulling the same in the sales invoice, have to manually select it.
Whats the correct way to implement it?

Sales Invoice does not fetch terms and conditions automatically. However, if you want to set it in sales invoice, you can set it through customize form, just set the default value for “Terms” field as your desired terms and condition template.

Whats happening is that I am able to pull the “Terms” field automatically but the actual terms fields doesnt get populated.
Tried putting company.default_selling_terms in “Fetch From” in terms field under sales invoice doctype but it doesnt seem to work.
Also, no output in console.

Found a proper working solution now. Adding the following custom script works well.

frappe.ui.form.on('Sales Invoice', 
{
     onload: function(frm) {
                                            frappe.call(
														{
															method: "frappe.client.get_value",
															args: {
																	"doctype" : "Company",
																	"filters" : {"company_name" : cur_frm.get_field("Company") },
																	"fieldname" : "default_selling_terms"
																	},
															
															callback: function(r) {
																					var result = r.message["default_selling_terms"]
																					console.log(r.message["default_selling_terms"]);
																					cur_frm.set_value("tc_name", result);
																				}
														},
														
														{
															method: "frappe.client.get_value",
															args: {
																	"doctype" : "Terms and Conditions",
																	"filters" : {"title" : cur_frm.get_field("tc_name") },
																	"fieldname" : "terms"
																},
														
															callback: function(r) {
																					var result = r.message["terms"]
																					console.log(r.message["terms"]);
																					cur_frm.set_value("terms", result);
																				}  
														}

														)
        
    }
    
    
    
})
1 Like

Thank you very much, I have tested this scripts and It works perfectly.
Once again, Thanks for your contribution.

1 Like