Merge pull request #2505 from nabinhait/fix1

Reapply price list if pricing rule reset as blank
This commit is contained in:
Nabin Hait
2014-12-17 15:39:28 +05:30

View File

@@ -402,20 +402,26 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
}, },
_set_values_for_item_list: function(children) { _set_values_for_item_list: function(children) {
var me = this;
$.each(children, function(i, d) { $.each(children, function(i, d) {
var existing_pricing_rule = frappe.model.get_value(d.doctype, d.name, "pricing_rule");
$.each(d, function(k, v) { $.each(d, function(k, v) {
if (["doctype", "name"].indexOf(k)===-1) { if (["doctype", "name"].indexOf(k)===-1) {
frappe.model.set_value(d.doctype, d.name, k, v); frappe.model.set_value(d.doctype, d.name, k, v);
} }
}); });
// if pricing rule set as blank from an existing value, apply price_list
if(existing_pricing_rule && !d.pricing_rule) {
me.apply_price_list(frappe.get_doc(d.doctype, d.name));
}
}); });
}, },
apply_price_list: function() { apply_price_list: function(item) {
var me = this; var me = this;
return this.frm.call({ return this.frm.call({
method: "erpnext.stock.get_item_details.apply_price_list", method: "erpnext.stock.get_item_details.apply_price_list",
args: { args: this._get_args() }, args: { args: this._get_args(item) },
callback: function(r) { callback: function(r) {
if (!r.exc) { if (!r.exc) {
me.in_apply_price_list = true; me.in_apply_price_list = true;