commit
693d1b2b2c
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt, cstr
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
from erpnext.stock.doctype.item.item import get_last_purchase_details
|
from erpnext.stock.doctype.item.item import get_last_purchase_details
|
||||||
@ -64,7 +64,7 @@ class PurchaseCommon(BuyingController):
|
|||||||
= d.rate = item_last_purchase_rate
|
= d.rate = item_last_purchase_rate
|
||||||
|
|
||||||
def validate_for_items(self, obj):
|
def validate_for_items(self, obj):
|
||||||
check_list, chk_dupl_itm=[],[]
|
items = []
|
||||||
for d in obj.get(obj.fname):
|
for d in obj.get(obj.fname):
|
||||||
# validation for valid qty
|
# validation for valid qty
|
||||||
if flt(d.qty) < 0 or (d.parenttype != 'Purchase Receipt' and not flt(d.qty)):
|
if flt(d.qty) < 0 or (d.parenttype != 'Purchase Receipt' and not flt(d.qty)):
|
||||||
@ -96,30 +96,10 @@ class PurchaseCommon(BuyingController):
|
|||||||
if item[0][1] != 'Yes' and item[0][2] != 'Yes':
|
if item[0][1] != 'Yes' and item[0][2] != 'Yes':
|
||||||
frappe.throw(_("{0} must be a Purchased or Sub-Contracted Item in row {1}").format(d.item_code, d.idx))
|
frappe.throw(_("{0} must be a Purchased or Sub-Contracted Item in row {1}").format(d.item_code, d.idx))
|
||||||
|
|
||||||
# list criteria that should not repeat if item is stock item
|
items.append(cstr(d.item_code))
|
||||||
e = [getattr(d, "schedule_date", None), d.item_code, d.description, d.warehouse, d.uom,
|
if items and len(items) != len(set(items)):
|
||||||
d.meta.get_field('prevdoc_docname') and d.prevdoc_docname or d.meta.get_field('sales_order_no') and d.sales_order_no or '',
|
frappe.msgprint(_("Warning: Same item has been entered multiple times."))
|
||||||
d.meta.get_field('prevdoc_detail_docname') and d.prevdoc_detail_docname or '',
|
|
||||||
d.meta.get_field('batch_no') and d.batch_no or '']
|
|
||||||
|
|
||||||
# if is not stock item
|
|
||||||
f = [getattr(d, "schedule_date", None), d.item_code, d.description]
|
|
||||||
|
|
||||||
ch = frappe.db.sql("""select is_stock_item from `tabItem` where name = %s""", d.item_code)
|
|
||||||
|
|
||||||
if ch and ch[0][0] == 'Yes':
|
|
||||||
# check for same items
|
|
||||||
if e in check_list:
|
|
||||||
frappe.throw(_("Item {0} has been entered multiple times with same description or date or warehouse").format(d.item_code))
|
|
||||||
else:
|
|
||||||
check_list.append(e)
|
|
||||||
|
|
||||||
elif ch and ch[0][0] == 'No':
|
|
||||||
# check for same items
|
|
||||||
if f in chk_dupl_itm:
|
|
||||||
frappe.throw(_("Item {0} has been entered multiple times with same description or date").format(d.item_code))
|
|
||||||
else:
|
|
||||||
chk_dupl_itm.append(f)
|
|
||||||
|
|
||||||
def check_for_stopped_status(self, doctype, docname):
|
def check_for_stopped_status(self, doctype, docname):
|
||||||
stopped = frappe.db.sql("""select name from `tab%s` where name = %s and
|
stopped = frappe.db.sql("""select name from `tab%s` where name = %s and
|
||||||
|
|||||||
@ -254,8 +254,10 @@ class ProductionPlanningTool(Document):
|
|||||||
ifnull(sum(ifnull(fb.qty, 0)/ifnull(bom.quantity, 1)), 0) as qty,
|
ifnull(sum(ifnull(fb.qty, 0)/ifnull(bom.quantity, 1)), 0) as qty,
|
||||||
fb.description, fb.stock_uom, it.min_order_qty
|
fb.description, fb.stock_uom, it.min_order_qty
|
||||||
from `tabBOM Explosion Item` fb, `tabBOM` bom, `tabItem` it
|
from `tabBOM Explosion Item` fb, `tabBOM` bom, `tabItem` it
|
||||||
where bom.name = fb.parent and it.name = fb.item_code and ifnull(it.is_pro_applicable, 'No') = 'No'
|
where bom.name = fb.parent and it.name = fb.item_code
|
||||||
|
and ifnull(it.is_pro_applicable, 'No') = 'No'
|
||||||
and ifnull(it.is_sub_contracted_item, 'No') = 'No'
|
and ifnull(it.is_sub_contracted_item, 'No') = 'No'
|
||||||
|
and ifnull(it.is_stock_item, 'No') = 'Yes'
|
||||||
and fb.docstatus<2 and bom.name=%s
|
and fb.docstatus<2 and bom.name=%s
|
||||||
group by item_code, stock_uom""", bom, as_dict=1):
|
group by item_code, stock_uom""", bom, as_dict=1):
|
||||||
bom_wise_item_details.setdefault(d.item_code, d)
|
bom_wise_item_details.setdefault(d.item_code, d)
|
||||||
@ -268,6 +270,7 @@ class ProductionPlanningTool(Document):
|
|||||||
from `tabBOM Item` bom_item, `tabBOM` bom, tabItem item
|
from `tabBOM Item` bom_item, `tabBOM` bom, tabItem item
|
||||||
where bom.name = bom_item.parent and bom.name = %s and bom_item.docstatus < 2
|
where bom.name = bom_item.parent and bom.name = %s and bom_item.docstatus < 2
|
||||||
and bom_item.item_code = item.name
|
and bom_item.item_code = item.name
|
||||||
|
and ifnull(item.is_stock_item, 'No') = 'Yes'
|
||||||
group by item_code""", bom, as_dict=1):
|
group by item_code""", bom, as_dict=1):
|
||||||
bom_wise_item_details.setdefault(d.item_code, d)
|
bom_wise_item_details.setdefault(d.item_code, d)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user