diff --git a/patches/patch.py b/patches/patch.py
index 8b7276b00dc..f6cf28889e1 100644
--- a/patches/patch.py
+++ b/patches/patch.py
@@ -1,7 +1,7 @@
# REMEMBER to update this
# ========================
-last_patch = 340
+last_patch = 341
#-------------------------------------------
@@ -1409,3 +1409,15 @@ def execute(patch_no):
reload_doc('production','doctype','bill_of_materials')
elif patch_no == 340:
sql("update `tabDocField` set permlevel = 0 where (fieldname in ('process', 'production_order', 'fg_completed_qty') or label = 'Get Items') and parent = 'Stock Entry'")
+ elif patch_no == 341:
+ reload_doc('stock','doctype','delivery_note')
+ reload_doc('stock','doc_type','item')
+ reload_doc('selling','doc_type','quotation')
+ reload_doc('stock','Print Format','Delivery Note Packing List Wise')
+
+ if not sql("select format from `tabDocFormat` where name = 'Delivery Note Packing List Wise' and parent = 'Delivery Note'"):
+ from webnotes.model.doc import addchild
+ dt_obj = get_obj('DocType', 'Delivery Note', with_children = 1)
+ ch = addchild(dt_obj.doc, 'formats', 'DocFormat', 1)
+ ch.format = 'Delivery Note Packing List Wise'
+ ch.save(1)
diff --git a/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.txt b/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.txt
new file mode 100644
index 00000000000..97f57a9f890
--- /dev/null
+++ b/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.txt
@@ -0,0 +1,27 @@
+# Print Format, Delivery Note Packing List Wise
+[
+
+ # These values are common in all dictionaries
+ {
+ 'creation': '2011-08-18 16:29:14',
+ 'docstatus': 0,
+ 'modified': '2011-08-23 13:24:12',
+ 'modified_by': 'Administrator',
+ 'owner': 'Administrator'
+ },
+
+ # These values are common for all Print Format
+ {
+ 'doctype': 'Print Format',
+ 'html': "\n
\n\n\n\n\n\n\n\n\n",
+ 'module': 'Stock',
+ 'name': '__common__',
+ 'standard': 'Yes'
+ },
+
+ # Print Format, Delivery Note Packing List Wise
+ {
+ 'doctype': 'Print Format',
+ 'name': 'Delivery Note Packing List Wise'
+ }
+]
\ No newline at end of file
diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py
index 2a2900fccf4..e5acd163a75 100644
--- a/stock/doctype/delivery_note/delivery_note.py
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -174,6 +174,9 @@ class DocType(TransactionBase):
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
+ # ::::::: Set Net Weight of each Packing
+ self.update_pack_nett_weight()
+ self.print_packing_slip()
# ::::::: Set actual qty for each item in selected warehouse :::::::
self.update_current_stock()
# :::::: set DN status :::::::
@@ -182,7 +185,6 @@ class DocType(TransactionBase):
if not self.doc.billing_status: self.doc.billing_status = 'Not Billed'
if not self.doc.installation_status: self.doc.installation_status = 'Not Installed'
-
# ************** Validate Mandatory *************************
def validate_mandatory(self):
# :::::::::: Amendment Date ::::::::::::::
@@ -439,4 +441,41 @@ class DocType(TransactionBase):
# Packing Slip Related
# ==========================================
- #def get
\ No newline at end of file
+ def update_pack_nett_weight(self):
+ for d in getlist(self.doclist, 'delivery_note_details'):
+ if d.item_name:
+ item_wt = sql("select nett_weight from `tabItem` where item_name = '%s'" % (d.item_name))
+ d.pack_nett_wt = item_wt and flt(item_wt[0][0])*flt(d.qty) or 0
+
+ # ==========================================
+ def print_packing_slip(self):
+ prev_pack='0'
+ sno=0
+ html=''
+ tot_nett_wt,tot_gross_wt=0,0
+ for d in getlist(self.doclist, 'delivery_note_details'):
+ sno=sno+1
+ if sno!=1:#Footer goes here
+ html+='| CASE NO | '+cstr(d.pack_no)+' | NETT WT | '+cstr(tot_nett_wt)+' | CHECKED BY | |
| SIZE | | GROSS WT | '+cstr(tot_gross_wt)+' | PACKED BY | |
'
+ if prev_pack!=d.pack_no: #Prepare Header Here
+ #Header code goes here
+ html+='[HEADER GOES HERE]
Packing Slip
| Order No. | '+cstr(self.doc.sales_order_no)+' | Shipping Marks | '+cstr(d.pack_no)+' |
'
+ html+='| S.NO. | QUANTITY | CS.NO. | DESCRIPTION | WEIGHT |
'
+ sno=0
+ tot_nett_wt,to_gross_wt=flt(d.pack_nett_wt),flt(d.pack_gross_wt)
+ #Body code goes here
+ html+='
| '+cstr(sno+1)+' | '+cstr(d.qty)+' | | '+d.item_code+' | '+cstr(d.pack_nett_wt)+' |
'
+ prev_pack=d.pack_no
+ tot_nett_wt+=flt(d.pack_nett_wt)
+ tot_gross_wt+=flt(d.pack_gross_wt)
+ html+='