feat(customer): add button to quick-create sales order and quotation (#37320)
* feat(customer): add button to quick-create sales order and quotation * fix: create buttons in customer * refactor: don't repeat yourself --------- Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com>
This commit is contained in:
parent
4a111f7362
commit
ea7565889f
@ -3,17 +3,32 @@
|
|||||||
|
|
||||||
frappe.ui.form.on("Customer", {
|
frappe.ui.form.on("Customer", {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
|
frm.custom_make_buttons = {
|
||||||
|
"Opportunity": "Opportunity",
|
||||||
|
"Quotation": "Quotation",
|
||||||
|
"Sales Order": "Sales Order",
|
||||||
|
"Pricing Rule": "Pricing Rule",
|
||||||
|
};
|
||||||
frm.make_methods = {
|
frm.make_methods = {
|
||||||
'Quotation': () => frappe.model.open_mapped_doc({
|
"Quotation": () =>
|
||||||
method: "erpnext.selling.doctype.customer.customer.make_quotation",
|
frappe.model.open_mapped_doc({
|
||||||
frm: cur_frm
|
method: "erpnext.selling.doctype.customer.customer.make_quotation",
|
||||||
}),
|
frm: frm,
|
||||||
'Opportunity': () => frappe.model.open_mapped_doc({
|
}),
|
||||||
method: "erpnext.selling.doctype.customer.customer.make_opportunity",
|
"Sales Order": () =>
|
||||||
frm: cur_frm
|
frappe.model.with_doctype("Sales Order", function () {
|
||||||
})
|
var so = frappe.model.get_new_doc("Sales Order");
|
||||||
}
|
so.customer = frm.doc.name; // Set the current customer as the SO customer
|
||||||
|
frappe.set_route("Form", "Sales Order", so.name);
|
||||||
|
}),
|
||||||
|
"Opportunity": () =>
|
||||||
|
frappe.model.open_mapped_doc({
|
||||||
|
method: "erpnext.selling.doctype.customer.customer.make_opportunity",
|
||||||
|
frm: frm,
|
||||||
|
}),
|
||||||
|
"Pricing Rule": () =>
|
||||||
|
erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name),
|
||||||
|
};
|
||||||
|
|
||||||
frm.add_fetch('lead_name', 'company_name', 'customer_name');
|
frm.add_fetch('lead_name', 'company_name', 'customer_name');
|
||||||
frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
|
frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
|
||||||
@ -146,9 +161,9 @@ frappe.ui.form.on("Customer", {
|
|||||||
{party_type: 'Customer', party: frm.doc.name, party_name: frm.doc.customer_name});
|
{party_type: 'Customer', party: frm.doc.name, party_name: frm.doc.customer_name});
|
||||||
}, __('View'));
|
}, __('View'));
|
||||||
|
|
||||||
frm.add_custom_button(__('Pricing Rule'), function () {
|
for (const doctype in frm.make_methods) {
|
||||||
erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name);
|
frm.add_custom_button(__(doctype), frm.make_methods[doctype], __("Create"));
|
||||||
}, __('Create'));
|
}
|
||||||
|
|
||||||
frm.add_custom_button(__('Get Customer Group Details'), function () {
|
frm.add_custom_button(__('Get Customer Group Details'), function () {
|
||||||
frm.trigger("get_customer_group_details");
|
frm.trigger("get_customer_group_details");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user