Skip to content

Commit

Permalink
fix: Validation for delivery date in Sales Order (#35597)
Browse files Browse the repository at this point in the history
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

(cherry picked from commit 984f89d)

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
  • Loading branch information
mergify[bot] and deepeshgarg007 committed Jun 14, 2023
1 parent 6f59fa9 commit 4a8ce22
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions erpnext/selling/doctype/quotation/quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,15 @@ def set_missing_values(source, target):
)

target.flags.ignore_permissions = ignore_permissions
target.delivery_date = nowdate()
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")

def update_item(obj, target, source_parent):
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
Expand Down
4 changes: 1 addition & 3 deletions erpnext/selling/doctype/quotation/test_quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def test_make_sales_order_with_different_currency(self):
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")
Expand Down Expand Up @@ -644,8 +644,6 @@ def make_quotation(**args):
},
)

qo.delivery_date = add_days(qo.transaction_date, 10)

if not args.do_not_save:
qo.insert()
if not args.do_not_submit:
Expand Down
3 changes: 2 additions & 1 deletion erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def validate_delivery_date(self):
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"))
Expand Down

0 comments on commit 4a8ce22

Please sign in to comment.