mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 19:19:17 +00:00
[fix] [mapper] add rows only table is blank, allow multiple time pull and validation if same item pulled twice
This commit is contained in:
@@ -136,22 +136,19 @@ class DocType(SellingController):
|
||||
def validate_for_items(self):
|
||||
check_list, chk_dupl_itm = [], []
|
||||
for d in getlist(self.doclist,'delivery_note_details'):
|
||||
ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
|
||||
if d.prevdoc_doctype and d.prevdoc_detail_docname and ch and ch[0][0]=='Yes':
|
||||
self.validate_items_with_prevdoc(d)
|
||||
|
||||
# validates whether item is not entered twice
|
||||
e = [d.item_code, d.description, d.warehouse, d.prevdoc_docname or '', d.batch_no or '']
|
||||
f = [d.item_code, d.description, d.prevdoc_docname or '']
|
||||
|
||||
if ch and ch[0][0] == 'Yes':
|
||||
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
|
||||
if e in check_list:
|
||||
msgprint("Please check whether item %s has been entered twice wrongly." % d.item_code)
|
||||
msgprint("Please check whether item %s has been entered twice wrongly."
|
||||
% d.item_code)
|
||||
else:
|
||||
check_list.append(e)
|
||||
elif ch and ch[0][0] == 'No':
|
||||
else:
|
||||
if f in chk_dupl_itm:
|
||||
msgprint("Please check whether item %s has been entered twice wrongly." % d.item_code)
|
||||
msgprint("Please check whether item %s has been entered twice wrongly."
|
||||
% d.item_code)
|
||||
else:
|
||||
chk_dupl_itm.append(f)
|
||||
|
||||
@@ -162,16 +159,6 @@ class DocType(SellingController):
|
||||
msgprint("Please enter Warehouse for item %s as it is stock item"
|
||||
% d['item_code'], raise_exception=1)
|
||||
|
||||
def validate_items_with_prevdoc(self, d):
|
||||
"""check if same item, warehouse present in prevdoc"""
|
||||
prev_item_dt = (d.prevdoc_doctype == 'Sales Order') and 'Sales Order Item' or 'Purchase Receipt Item'
|
||||
data = sql("select item_code from `tab%s` where parent = '%s' and name = '%s'"\
|
||||
% (prev_item_dt, d.prevdoc_docname, d.prevdoc_detail_docname))
|
||||
if not data or data[0][0] != d.item_code:
|
||||
msgprint("Item: %s is not matching with Sales Order: %s. Sales Order might be modified after \
|
||||
fetching data from it. Please delete items and fetch again." \
|
||||
% (d.item_code, d.prevdoc_docname), raise_exception=1)
|
||||
|
||||
|
||||
def update_current_stock(self):
|
||||
for d in getlist(self.doclist, 'delivery_note_details'):
|
||||
@@ -375,7 +362,7 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
|
||||
def update_accounts(source, target):
|
||||
si = webnotes.bean(target)
|
||||
si.run_method("update_accounts")
|
||||
si.run_method("onload_post_render")
|
||||
|
||||
doclist = get_mapped_doclist("Delivery Note", source_name, {
|
||||
"Delivery Note": {
|
||||
@@ -397,12 +384,14 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
},
|
||||
"Sales Taxes and Charges": {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
},
|
||||
"Sales Team": {
|
||||
"doctype": "Sales Team",
|
||||
"field_map": {
|
||||
"incentives": "incentives"
|
||||
}
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, update_accounts)
|
||||
|
||||
|
||||
@@ -49,12 +49,6 @@ class DocType(BuyingController):
|
||||
def get_bin_details(self, arg = ''):
|
||||
return get_obj(dt='Purchase Common').get_bin_details(arg)
|
||||
|
||||
# validate if PO has been pulled twice
|
||||
def validate_prev_docname(self):
|
||||
for d in getlist(self.doclist, 'purchase_receipt_details'):
|
||||
if self.doc.purchase_order_no and d.prevdoc_docname and self.doc.purchase_order_no == d.prevdoc_docname:
|
||||
msgprint(cstr(self.doc.purchase_order_no) + " Purchase Order details have already been pulled. ")
|
||||
raise Exception
|
||||
|
||||
# validate accepted and rejected qty
|
||||
def validate_accepted_rejected_qty(self):
|
||||
@@ -383,6 +377,7 @@ def make_purchase_invoice(source_name, target_doclist=None):
|
||||
},
|
||||
"Purchase Taxes and Charges": {
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
"add_if_empty": True
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user