Check duplicate SO entry for same po no and customer
This commit is contained in:
parent
981446c7cc
commit
388e09834c
@ -181,19 +181,28 @@ class DocType(TransactionBase):
|
|||||||
if getdate(self.doc.transaction_date) > getdate(self.doc.delivery_date):
|
if getdate(self.doc.transaction_date) > getdate(self.doc.delivery_date):
|
||||||
msgprint("Expected Delivery Date cannot be before Sales Order Date")
|
msgprint("Expected Delivery Date cannot be before Sales Order Date")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
# Validate P.O Date
|
|
||||||
# ------------------
|
|
||||||
def validate_po_date(self):
|
|
||||||
# validate p.o date v/s delivery date
|
|
||||||
if self.doc.po_date and self.doc.delivery_date and getdate(self.doc.po_date) > getdate(self.doc.delivery_date):
|
|
||||||
msgprint("Expected Delivery Date cannot be before Purchase Order Date")
|
|
||||||
raise Exception
|
|
||||||
# amendment date is necessary if document is amended
|
# amendment date is necessary if document is amended
|
||||||
if self.doc.amended_from and not self.doc.amendment_date:
|
if self.doc.amended_from and not self.doc.amendment_date:
|
||||||
msgprint("Please Enter Amendment Date")
|
msgprint("Please Enter Amendment Date")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
|
||||||
|
# Validate P.O Date
|
||||||
|
# ------------------
|
||||||
|
def validate_po(self):
|
||||||
|
# validate p.o date v/s delivery date
|
||||||
|
if self.doc.po_date and self.doc.delivery_date and getdate(self.doc.po_date) > getdate(self.doc.delivery_date):
|
||||||
|
msgprint("Expected Delivery Date cannot be before Purchase Order Date")
|
||||||
|
raise Exception
|
||||||
|
|
||||||
|
if self.doc.po_no and self.doc.customer:
|
||||||
|
so = webnotes.conn.sql("select name from `tabSales Order` \
|
||||||
|
where ifnull(po_no, '') = %s and name != %s and docstatus < 2\
|
||||||
|
and customer = %s", (self.doc.po_no, self.doc.name, self.doc.customer))
|
||||||
|
if so and so[0][0]:
|
||||||
|
msgprint("""Another Sales Order (%s) exists against same PO No and Customer.
|
||||||
|
Please be sure, you are not making duplicate entry.""" % so[0][0])
|
||||||
|
|
||||||
# Validations of Details Table
|
# Validations of Details Table
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def validate_for_items(self):
|
def validate_for_items(self):
|
||||||
@ -305,7 +314,7 @@ class DocType(TransactionBase):
|
|||||||
self.validate_order_type()
|
self.validate_order_type()
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
self.validate_proj_cust()
|
self.validate_proj_cust()
|
||||||
self.validate_po_date()
|
self.validate_po()
|
||||||
#self.validate_reference_value()
|
#self.validate_reference_value()
|
||||||
self.validate_for_items()
|
self.validate_for_items()
|
||||||
sales_com_obj = get_obj(dt = 'Sales Common')
|
sales_com_obj = get_obj(dt = 'Sales Common')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user