Change Delivery Date when dragging Sales Order around Calendar

Hello, we are on version-12 latest update, self-hosted.

We encounter a problem when trying to change Sales Order’s Delivery Date, after submission.
We could Cancel, and Amend, but this solution can’t work, when we Drag and Drop a Sales Order in Calendar module.

If I understand it right, the Delivery Date of Sales Order should change itself when Sales Order is being dragged to another day in the Calendar.

Thanks for any insights. Maybe this is a feature, not a bug?

Similar topic (old): How to change delivery date in a submitted Sales Orders

Warm regards

Dear asem89,

we have problem with our customers also changing delivery dates regularly, so i marked delivery_date filed with allow on submit on “Sales Order” doctype. then you have to change “Sales Order items” doctype delivery_date field as allow on submit.
Also you might get error which items date is not updated when you change sales order “Delivery Date” i solved this problem with below script when my delivery date is changed items delivery_date also updated.

frappe.ui.form.on('Sales Order', {
	refresh(frm) {
delivery_date (frm, cdt, cdn){
    var row = locals[cdt][cdn];
    cur_frm.doc.items.forEach(function(row) {
    frappe.model.set_value(row.doctype, row.name, 'delivery_date', frm.doc.delivery_date);
    });
  }
  }
});

i don’t know about calendar edit related to this fields ‘allow on submit’ situation.
Also even in fresh “Sales Order” when you select delivery date and change after it items delivery date is not updated.

Sales Order field - Delivery Date - was already marked as “allow on submit”

When trying to set Sales Order Item - Delivery Date - I get an error

And the field changes back to not allow on submit. Any ideas?

Delivery date is not editable after submit. The order must be cancelled and then amended. This also means you can’t drag it to new date in the calendar.

This is pretty standard in a lot of ERP systems because a delivery date is a somewhat binding part of a SO. Whilst it’s true that in the real world orders can be delayed, or fulfillment might be uncertain, the idea of a delivery date is to make some kind of commitment. It can be amended, but doing so requires the cancellation of the original.

A good compromise would be to allow the option of a separate “expected date” that users can enable.

I added a custom field called “booking_date” to my sales orders and I’ve actually hidden delivery date. I’ve made some changes so that booking date is used to populate the calendar view, but I’m having some problems with the script.

I have no idea how emre’s solution is working, it doesn’t work in V12 and as far as I can tell the devs have prevented delivery date from being set to “allow on submit” due to concerns enabling it could corrupt data.

1 Like

One way to solve this is to apply the following script, which requires user to edit the delivery_date of a line item in the items table, which will then update ALL The delivery_date values for all items in the table, as well as the main document delivery date. Works around the limitation that the parent doc (sales order) delivery date value is dependent on the most recent update in the items table.

frappe.ui.form.on('Sales Order Item', {
	delivery_date:function(frm, cdt, cdn){
		var d = locals[cdt][cdn];
		if (d.delivery_date !== frm.doc.delivery_date){
		    frm.doc.delivery_date = d.delivery_date;
		    frm.doc.items.forEach(function(d) {
			    frappe.model.set_value(d.doctype, d.name, 'delivery_date', frm.doc.delivery_date);
		    });
		    frm.refresh_field('delivery_date');
	    }
	}
});