added is_item_table_empty validation in submit event of purchase common
This commit is contained in:
parent
f04fa4664d
commit
b62c4edf02
@ -482,6 +482,9 @@ class DocType(TransactionBase):
|
||||
|
||||
|
||||
def on_submit(self):
|
||||
purchase_controller = webnotes.get_obj("Purchase Common")
|
||||
purchase_controller.is_item_table_empty(self)
|
||||
|
||||
self.check_prev_docstatus()
|
||||
|
||||
# Check for Approving Authority
|
||||
@ -492,8 +495,7 @@ class DocType(TransactionBase):
|
||||
self.make_gl_entries()
|
||||
|
||||
self.update_against_document_in_jv()
|
||||
|
||||
get_obj(dt = 'Purchase Common').update_prevdoc_detail(self, is_submit = 1)
|
||||
purchase_controller.update_prevdoc_detail(self, is_submit = 1)
|
||||
|
||||
|
||||
def make_gl_entries(self, is_cancel = 0):
|
||||
|
@ -280,21 +280,8 @@ cur_frm.cscript.import_ref_rate = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.calc_amount(doc, 5);
|
||||
}
|
||||
|
||||
//==================== check if item table is blank ==============================================
|
||||
var is_item_table = function(doc,cdt,cdn) {
|
||||
// Step 1 :=>Get all childrens/ rows from Detail Table
|
||||
var cl = getchildren(tname, doc.name, fname);
|
||||
// Step 2 :=> If there are no rows then set validated = false, this will stop further execution of code.
|
||||
if (cl.length == 0) {
|
||||
alert("There is no item in table"); validated = false;
|
||||
}
|
||||
}
|
||||
|
||||
//==================== Validate ====================================================================
|
||||
cur_frm.cscript.validate = function(doc, cdt, cdn) {
|
||||
// Step 1:=> check if item table is blank
|
||||
is_item_table(doc,cdt,cdn);
|
||||
// Step 2:=> Calculate Amount
|
||||
cur_frm.cscript.calc_amount(doc, 1);
|
||||
|
||||
// calculate advances if pv
|
||||
|
@ -22,14 +22,14 @@ from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import form, msgprint
|
||||
from webnotes import form, msgprint, _
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType(TransactionBase):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
def __init__(self, doc, doclist=None):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
@ -64,6 +64,11 @@ class DocType(TransactionBase):
|
||||
|
||||
self.msg = []
|
||||
|
||||
def is_item_table_empty(self, obj):
|
||||
if not len(obj.doclist.get({"parentfield": obj.fname})):
|
||||
msgprint(_("Hey there! You need to put at least one item in \
|
||||
the item table."), raise_exception=True)
|
||||
|
||||
|
||||
def get_default_schedule_date( self, obj):
|
||||
for d in getlist( obj.doclist, obj.fname):
|
||||
|
@ -220,10 +220,11 @@ class DocType(TransactionBase):
|
||||
|
||||
# On Submit
|
||||
def on_submit(self):
|
||||
pc_obj = get_obj(dt ='Purchase Common')
|
||||
purchase_controller = webnotes.get_obj("Purchase Common")
|
||||
purchase_controller.is_item_table_empty(self)
|
||||
|
||||
# Step 1 :=> Update Previous Doc i.e. update pending_qty and Status accordingly
|
||||
pc_obj.update_prevdoc_detail(self, is_submit = 1)
|
||||
purchase_controller.update_prevdoc_detail(self, is_submit = 1)
|
||||
|
||||
# Step 2 :=> Update Bin
|
||||
self.update_bin(is_submit = 1, is_stopped = 0)
|
||||
@ -236,7 +237,7 @@ class DocType(TransactionBase):
|
||||
"last_purchase_order", self.doc.name)
|
||||
|
||||
# Step 5 :=> Update last purchase rate
|
||||
pc_obj.update_last_purchase_rate(self, is_submit = 1)
|
||||
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
|
||||
|
||||
# Step 6 :=> Set Status
|
||||
webnotes.conn.set(self.doc,'status','Submitted')
|
||||
|
@ -50,22 +50,19 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation);
|
||||
if(flt(doc.per_ordered, 2) < 100) {
|
||||
cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order']);
|
||||
cur_frm.add_custom_button('Stop Purchase Request', cur_frm.cscript['Stop Purchase Request']);
|
||||
}
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||
cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation);
|
||||
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Request', cur_frm.cscript['Unstop Purchase Request'])
|
||||
}
|
||||
|
||||
//======================= validation ===================================
|
||||
cur_frm.cscript.validate = function(doc,cdt,cdn){
|
||||
is_item_table(doc,cdt,cdn);
|
||||
}
|
||||
//======================= transaction date =============================
|
||||
cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
|
||||
if(doc.__islocal){
|
||||
|
@ -178,6 +178,9 @@ class DocType:
|
||||
get_obj('Warehouse', d.warehouse).update_bin(args)
|
||||
|
||||
def on_submit(self):
|
||||
purchase_controller = webnotes.get_obj("Purchase Common")
|
||||
purchase_controller.is_item_table_empty(self)
|
||||
|
||||
webnotes.conn.set(self.doc,'status','Submitted')
|
||||
self.update_bin(is_submit = 1, is_stopped = 0)
|
||||
|
||||
|
@ -36,6 +36,9 @@ class DocType(TransactionBase):
|
||||
self.doc.status = "Draft"
|
||||
|
||||
def on_submit(self):
|
||||
purchase_controller = webnotes.get_obj("Purchase Common")
|
||||
purchase_controller.is_item_table_empty(self)
|
||||
|
||||
webnotes.conn.set(self.doc, "status", "Submitted")
|
||||
|
||||
def on_cancel(self):
|
||||
|
@ -284,15 +284,17 @@ class DocType(TransactionBase):
|
||||
|
||||
# on submit
|
||||
def on_submit(self):
|
||||
purchase_controller = webnotes.get_obj("Purchase Common")
|
||||
purchase_controller.is_item_table_empty(self)
|
||||
|
||||
# Check for Approving Authority
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total)
|
||||
|
||||
# Set status as Submitted
|
||||
webnotes.conn.set(self.doc,'status', 'Submitted')
|
||||
pc_obj = get_obj('Purchase Common')
|
||||
|
||||
# Update Previous Doc i.e. update pending_qty and Status accordingly
|
||||
pc_obj.update_prevdoc_detail(self, is_submit = 1)
|
||||
purchase_controller.update_prevdoc_detail(self, is_submit = 1)
|
||||
|
||||
# Update Serial Record
|
||||
get_obj('Stock Ledger').update_serial_record(self, 'purchase_receipt_details', is_submit = 1, is_incoming = 1)
|
||||
@ -301,7 +303,7 @@ class DocType(TransactionBase):
|
||||
self.update_stock(is_submit = 1)
|
||||
|
||||
# Update last purchase rate
|
||||
pc_obj.update_last_purchase_rate(self, 1)
|
||||
purchase_controller.update_last_purchase_rate(self, 1)
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user