Skip to content

Commit

Permalink
Merge 9e4fcf7 into a7567f2
Browse files Browse the repository at this point in the history
  • Loading branch information
MyuddinKhatri committed Sep 14, 2020
2 parents a7567f2 + 9e4fcf7 commit aa05f51
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions erpnext/selling/doctype/sales_order/sales_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ frappe.ui.form.on("Sales Order", {
})
},
customer: function (frm) {
frm.set_value("delivery_date", "")
frappe.call({
method: "erpnext.stock.doctype.delivery_trip.delivery_trip.get_delivery_window",
args: { customer: frm.doc.customer },
Expand Down Expand Up @@ -98,10 +99,25 @@ frappe.ui.form.on("Sales Order", {
},

delivery_date: function(frm) {
if (!frm.doc.customer) {
frappe.throw(__('Please select a customer'));
}
$.each(frm.doc.items || [], function(i, d) {
d.delivery_date = frm.doc.delivery_date;
});
refresh_field("items");
if (frm.doc.delivery_date) {
frappe.db.get_value("Customer", { "name": frm.doc.customer }, "delivery_days", (r) => {
if (r.delivery_days) {
let day = moment(frm.doc.delivery_date).format('dddd');
let weekdays = JSON.parse(r.delivery_days);
if (!weekdays.includes(day)) {
frappe.msgprint(__("This order is set to be delivered on a '{0}', but {1} only accepts deliveries on {2}",
[day, frm.doc.customer, weekdays]));
}
}
})
}
}
});

Expand Down

0 comments on commit aa05f51

Please sign in to comment.