Do not make packing list after submission

This commit is contained in:
Nabin Hait 2014-06-17 16:13:15 +05:30
parent 69641ddc36
commit b73d3f925d
2 changed files with 13 additions and 12 deletions

View File

@ -102,7 +102,6 @@ class SalesOrder(SellingController):
self.validate_warehouse()
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
make_packing_list(self,'sales_order_details')
self.validate_with_previous_doc()

View File

@ -12,18 +12,18 @@ from frappe.model.document import Document
class PackedItem(Document):
pass
def get_sales_bom_items(item_code):
return frappe.db.sql("""select t1.item_code, t1.qty, t1.uom
from `tabSales BOM Item` t1, `tabSales BOM` t2
return frappe.db.sql("""select t1.item_code, t1.qty, t1.uom
from `tabSales BOM Item` t1, `tabSales BOM` t2
where t2.new_item_code=%s and t1.parent = t2.name""", item_code, as_dict=1)
def get_packing_item_details(item):
return frappe.db.sql("""select item_name, description, stock_uom from `tabItem`
return frappe.db.sql("""select item_name, description, stock_uom from `tabItem`
where name = %s""", item, as_dict = 1)[0]
def get_bin_qty(item, warehouse):
det = frappe.db.sql("""select actual_qty, projected_qty from `tabBin`
det = frappe.db.sql("""select actual_qty, projected_qty from `tabBin`
where item_code = %s and warehouse = %s""", (item, warehouse), as_dict = 1)
return det and det[0] or ''
@ -55,12 +55,15 @@ def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packi
if not pi.batch_no:
pi.batch_no = cstr(line.get("batch_no"))
pi.idx = packing_list_idx
packing_list_idx += 1
def make_packing_list(obj, item_table_fieldname):
"""make packing list for sales bom item"""
if obj._action == "update_after_submit": return
packing_list_idx = 0
parent_items = []
for d in obj.get(item_table_fieldname):
@ -68,14 +71,14 @@ def make_packing_list(obj, item_table_fieldname):
and d.warehouse or d.warehouse
if frappe.db.get_value("Sales BOM", {"new_item_code": d.item_code}):
for i in get_sales_bom_items(d.item_code):
update_packing_list_item(obj, i['item_code'], flt(i['qty'])*flt(d.qty),
update_packing_list_item(obj, i['item_code'], flt(i['qty'])*flt(d.qty),
warehouse, d, packing_list_idx)
if [d.item_code, d.name] not in parent_items:
parent_items.append([d.item_code, d.name])
cleanup_packing_list(obj, parent_items)
def cleanup_packing_list(obj, parent_items):
"""Remove all those child items which are no longer present in main item table"""
delete_list = []
@ -86,10 +89,9 @@ def cleanup_packing_list(obj, parent_items):
if not delete_list:
return obj
packing_details = obj.get("packing_details")
obj.set("packing_details", [])
for d in packing_details:
if d not in delete_list:
obj.append("packing_details", d)