fix: Validation for delivery date in Sales Order (#35597)
* fix: Validation for delivery date in Sales Order
* chore: update utils
* chore: revert
* chore: Add default delivery date
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 61969fe..8ff681b 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -299,6 +299,7 @@
)
target.flags.ignore_permissions = ignore_permissions
+ target.delivery_date = nowdate()
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
@@ -306,6 +307,7 @@
balance_qty = obj.qty - ordered_items.get(obj.item_code, 0.0)
target.qty = balance_qty if balance_qty > 0 else 0
target.stock_qty = flt(target.qty) * flt(obj.conversion_factor)
+ target.delivery_date = nowdate()
if obj.against_blanket_order:
target.against_blanket_order = obj.against_blanket_order
diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py
index 67f6518..5623a12 100644
--- a/erpnext/selling/doctype/quotation/test_quotation.py
+++ b/erpnext/selling/doctype/quotation/test_quotation.py
@@ -60,9 +60,9 @@
sales_order = make_sales_order(quotation.name)
sales_order.currency = "USD"
sales_order.conversion_rate = 20.0
- sales_order.delivery_date = "2019-01-01"
sales_order.naming_series = "_T-Quotation-"
sales_order.transaction_date = nowdate()
+ sales_order.delivery_date = nowdate()
sales_order.insert()
self.assertEqual(sales_order.currency, "USD")
@@ -644,8 +644,6 @@
},
)
- qo.delivery_date = add_days(qo.transaction_date, 10)
-
if not args.do_not_save:
qo.insert()
if not args.do_not_submit:
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 58b9df8..624dadb 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -171,7 +171,8 @@
frappe.msgprint(
_("Expected Delivery Date should be after Sales Order Date"),
indicator="orange",
- title=_("Warning"),
+ title=_("Invalid Delivery Date"),
+ raise_exception=True,
)
else:
frappe.throw(_("Please enter Delivery Date"))