Skip to content

Commit

Permalink
fix: disallow mulitple SO with same PO No
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Aug 11, 2023
1 parent b0c79a0 commit dbd3fdb
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,26 @@ def validate_po(self):
and customer = %s",
(self.po_no, self.name, self.customer),
)
if (
so
and so[0][0]
and not cint(
if so and so[0][0]:
if cint(
frappe.db.get_single_value("Selling Settings", "allow_against_multiple_purchase_orders")
)
):
frappe.msgprint(
_("Warning: Sales Order {0} already exists against Customer's Purchase Order {1}").format(
so[0][0], self.po_no
):
frappe.msgprint(
_("Warning: Sales Order {0} already exists against Customer's Purchase Order {1}").format(
frappe.bold(so[0][0]), frappe.bold(self.po_no)
)
)
else:
frappe.throw(
_(
"Sales Order {0} already exists against Customer's Purchase Order {1}. To allow multiple Sales Orders, Enable {2} in {3}"
).format(
frappe.bold(so[0][0]),
frappe.bold(self.po_no),
frappe.bold(_("'Allow Multiple Sales Orders Against a Customer's Purchase Order'")),
get_link_to_form("Selling Settings", "Selling Settings"),
)
)
)

def validate_for_items(self):
for d in self.get("items"):
Expand Down

0 comments on commit dbd3fdb

Please sign in to comment.