Make pricing rule from Supplier and Customer Doc (#15533)
* Make pricing rule from Supplier and Customer Doc * Make sure the "+" button also works the same way as the "Make" button
This commit is contained in:
parent
6ecb2556b7
commit
90cf2ddc01
@ -116,6 +116,18 @@ frappe.ui.form.on('Pricing Rule', {
|
||||
};
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
if(frm.doc.__islocal && !frm.doc.applicable_for && (frm.doc.customer || frm.doc.supplier)) {
|
||||
if(frm.doc.customer) {
|
||||
frm.doc.applicable_for = "Customer";
|
||||
frm.doc.selling = 1
|
||||
} else {
|
||||
frm.doc.applicable_for = "Supplier";
|
||||
frm.doc.buying = 1
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
var help_content =
|
||||
`<table class="table table-bordered" style="background-color: #f9f9f9;">
|
||||
|
@ -384,3 +384,13 @@ def set_transaction_type(args):
|
||||
args.transaction_type = "selling"
|
||||
else:
|
||||
args.transaction_type = "buying"
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_pricing_rule(doctype, docname):
|
||||
doc = frappe.new_doc("Pricing Rule")
|
||||
doc.applicable_for = doctype
|
||||
doc.set(frappe.scrub(doctype), docname)
|
||||
doc.selling = 1 if doctype == "Customer" else 0
|
||||
doc.buying = 1 if doctype == "Supplier" else 0
|
||||
|
||||
return doc
|
@ -49,6 +49,10 @@ frappe.ui.form.on("Supplier", {
|
||||
erpnext.utils.make_bank_account(frm.doc.doctype, frm.doc.name);
|
||||
}, __("Make"));
|
||||
|
||||
frm.add_custom_button(__('Pricing Rule'), function () {
|
||||
erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name);
|
||||
}, __("Make"));
|
||||
|
||||
// indicators
|
||||
erpnext.utils.set_party_dashboard_indicators(frm);
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ def get_data():
|
||||
{
|
||||
'label': _('Orders'),
|
||||
'items': ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice']
|
||||
},
|
||||
{
|
||||
'label': _('Pricing'),
|
||||
'items': ['Pricing Rule']
|
||||
}
|
||||
]
|
||||
}
|
@ -173,6 +173,20 @@ $.extend(erpnext.utils, {
|
||||
})
|
||||
},
|
||||
|
||||
make_pricing_rule: function(doctype, docname) {
|
||||
frappe.call({
|
||||
method: "erpnext.accounts.doctype.pricing_rule.pricing_rule.make_pricing_rule",
|
||||
args: {
|
||||
doctype: doctype,
|
||||
docname: docname
|
||||
},
|
||||
callback: function(r) {
|
||||
var doclist = frappe.model.sync(r.message);
|
||||
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if the first row of a given child table is empty
|
||||
* @param child_table - Child table Doctype
|
||||
|
@ -106,6 +106,10 @@ frappe.ui.form.on("Customer", {
|
||||
frappe.set_route('query-report', 'Accounts Receivable', {customer:frm.doc.name});
|
||||
});
|
||||
|
||||
frm.add_custom_button(__('Pricing Rule'), function () {
|
||||
erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name);
|
||||
}, __("Make"));
|
||||
|
||||
// indicator
|
||||
erpnext.utils.set_party_dashboard_indicators(frm);
|
||||
|
||||
|
@ -21,6 +21,10 @@ def get_data():
|
||||
{
|
||||
'label': _('Projects'),
|
||||
'items': ['Project']
|
||||
},
|
||||
{
|
||||
'label': _('Pricing'),
|
||||
'items': ['Pricing Rule']
|
||||
}
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user