[minor] map custom fields from delivery note to packing slip
diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.py b/erpnext/stock/doctype/packing_slip/packing_slip.py
index 6a7b559..25fde08 100644
--- a/erpnext/stock/doctype/packing_slip/packing_slip.py
+++ b/erpnext/stock/doctype/packing_slip/packing_slip.py
@@ -84,8 +84,15 @@
* No. of Cases of this packing slip
"""
+ # also pick custom fields from delivery note
rows = [d.item_code for d in self.get("items")]
+ custom_fields = ', '.join(['dni.`{0}`'.format(d.fieldname) for d in \
+ frappe.get_meta("Delivery Note Item").get_custom_fields()])
+
+ if custom_fields:
+ custom_fields = ', ' + custom_fields
+
condition = ""
if rows:
condition = " and item_code in (%s)" % (", ".join(["%s"]*len(rows)))
@@ -96,10 +103,10 @@
from `tabPacking Slip` ps, `tabPacking Slip Item` psi
where ps.name = psi.parent and ps.docstatus = 1
and ps.delivery_note = dni.parent and psi.item_code=dni.item_code) as packed_qty,
- stock_uom, item_name, description, dni.batch_no
+ stock_uom, item_name, description, dni.batch_no {custom_fields}
from `tabDelivery Note Item` dni
- where parent=%s %s
- group by item_code""" % ("%s", condition),
+ where parent=%s {condition}
+ group by item_code""".format(condition=condition, custom_fields=custom_fields),
tuple([self.delivery_note] + rows), as_dict=1)
ps_item_qty = dict([[d.item_code, d.qty] for d in self.get("items")])
@@ -146,6 +153,8 @@
def get_items(self):
self.set("items", [])
+ custom_fields = frappe.get_meta("Delivery Note Item").get_custom_fields()
+
dn_details = self.get_details_for_packing()[0]
for item in dn_details:
if flt(item.qty) > flt(item.packed_qty):
@@ -156,6 +165,12 @@
ch.description = item.description
ch.batch_no = item.batch_no
ch.qty = flt(item.qty) - flt(item.packed_qty)
+
+ # copy custom fields
+ for d in custom_fields:
+ if item.get(d.fieldname):
+ ch.set(d.fieldname, item.get(d.fieldname))
+
self.update_item_details()
def item_details(doctype, txt, searchfield, start, page_len, filters):