From 0c005421feffd2883ba26bf1585107535a920370 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 18 Oct 2011 16:44:20 +0530 Subject: [PATCH] Packing slip issues fixed and modified print format --- erpnext/patches/packing_slip.py | 7 ++ .../doctype/delivery_note/delivery_note.py | 97 ++++++++++++++----- .../doctype/delivery_note/delivery_note.txt | 19 +++- .../delivery_note_detail.txt | 37 ++++++- 4 files changed, 130 insertions(+), 30 deletions(-) create mode 100644 erpnext/patches/packing_slip.py diff --git a/erpnext/patches/packing_slip.py b/erpnext/patches/packing_slip.py new file mode 100644 index 0000000000..b6c94c040f --- /dev/null +++ b/erpnext/patches/packing_slip.py @@ -0,0 +1,7 @@ +def execute(): + from webnotes.modules.module_manager import reload_doc + reload_doc('stock', 'doctype', 'delivery_note_detail') + reload_doc('stock', 'Print Format', 'Delivery Note Packing List Wise') + + webnotes.conn.sql("delete from `tabDocField` where fieldname in ('packed_by', 'packing_checked_by', 'pack_size') and parent = 'Delivery Note'") + diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index b49f80c656..ea8c648b74 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -443,33 +443,80 @@ class DocType(TransactionBase): # ========================================== def update_pack_nett_weight(self): for d in getlist(self.doclist, 'delivery_note_details'): - if d.item_code: + if d.item_code and not d.pack_nett_wt: item_wt = sql("select nett_weight from `tabItem` where name = %s", (d.item_code)) d.pack_nett_wt = item_wt and flt(item_wt[0][0]) 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 and prev_pack!=d.pack_no:#Footer goes here - html+='
CASE NO'+cstr(d.pack_no)+'NETT WT'+cstr(tot_nett_wt)+'CHECKED BY
SIZEGROSS 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.shipping_mark)+'
' - html+='' - sno=0 - tot_nett_wt,to_gross_wt=flt(d.pack_nett_wt),flt(d.pack_gross_wt) - #Body code goes here - html+='' - prev_pack=d.pack_no - tot_nett_wt+=flt(d.pack_nett_wt) - tot_gross_wt+=flt(d.pack_gross_wt) - if html!='': - html+='
S.NO.QUANTITYCS.NO.DESCRIPTIONWEIGHT
'+cstr(sno+1)+''+cstr(d.qty)+''+d.item_code+''+d.description+''+cstr(d.pack_nett_wt)+'
CASE NO'+cstr(d.pack_no)+'NETT WT'+cstr(tot_nett_wt)+'CHECKED BY'+cstr(self.doc.packing_checked_by)+'
SIZE'+cstr(self.doc.pack_size)+'GROSS WT'+cstr(tot_gross_wt)+'PACKED BY'+cstr(self.doc.packed_by)+'
' - html+='' + # ========================================== + def get_header(self, so_no, shipping_mark): + header = ''' +
[HEADER GOES HERE]
+

Packing Slip

+ + + + + + + +
ORDER NO.'''+cstr(so_no)+'''SHIPPING MARKS'''+cstr(shipping_mark)+'''
'''; + + return header + + def get_footer(self, row, tot_nett, tot_gross): + footer = ''' + + + + + + + + + + + +
CASE NO'''+cstr(row.pack_no)+'''NETT WT'''+cstr(tot_nett)+'''CHECKED BY'''+cstr(row.packing_checked_by)+'''
SIZE'''+cstr(row.pack_size)+'''GROSS WT'''+cstr(tot_gross)+'''PACKED BY'''+cstr(row.packed_by)+'''
''' + + return footer + + def print_packing_slip(self): + plist = {} + for d in getlist(self.doclist, 'delivery_note_details'): + if not plist.has_key(cstr(d.pack_no)): + plist[cstr(d.pack_no)] = [d] + else: + plist.get(cstr(d.pack_no)).append(d) + + html='' + + for d in sorted(plist.keys()): + tot_nett_wt,tot_gross_wt=0,0 + + # header + html += self.get_header(self.doc.sales_order_no, self.doc.shipping_mark) + + # item table header + html += ''' + + + + + ''' + + # item table data + sr_no = 1 + for r in plist.get(d): + html += '' + + tot_nett_wt += flt(r.pack_nett_wt) + tot_gross_wt += flt(r.pack_gross_wt) + + sr_no += 1 + + html += '
SR.NO.CS.NO.DESCRIPTIONQUANTITYWEIGHT
'+cstr(sr_no)+''+r.item_code+''+r.description+''+cstr(r.qty)+''+cstr(r.pack_nett_wt)+'
' + + # footer + html += self.get_footer(r, tot_nett_wt, tot_gross_wt) self.doc.print_packing_slip=html diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.txt b/erpnext/stock/doctype/delivery_note/delivery_note.txt index 9fe13e4c71..8109af5c4e 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.txt +++ b/erpnext/stock/doctype/delivery_note/delivery_note.txt @@ -5,7 +5,7 @@ { 'creation': '2011-04-18 15:58:20', 'docstatus': 0, - 'modified': '2011-09-20 18:50:41', + 'modified': '2011-10-18 13:57:23', 'modified_by': 'Administrator', 'owner': 'Administrator' }, @@ -21,7 +21,7 @@ # These values are common for all DocType { - '_last_update': '1315560377', + '_last_update': '1318321312', 'colour': 'White:FFF', 'default_print_format': 'Standard', 'doctype': 'DocType', @@ -37,7 +37,7 @@ 'show_in_menu': 0, 'subject': 'To %(customer_name)s on %(transaction_date)s | %(per_billed)s% billed', 'tag_fields': 'billing_status', - 'version': 453 + 'version': 454 }, # These values are common for all DocFormat @@ -114,6 +114,18 @@ 'write': 1 }, + # DocPerm + { + 'amend': 1, + 'cancel': 1, + 'create': 1, + 'doctype': 'DocPerm', + 'permlevel': 0, + 'role': 'Sales Manager', + 'submit': 1, + 'write': 1 + }, + # DocPerm { 'doctype': 'DocPerm', @@ -622,6 +634,7 @@ # DocField { + 'allow_on_submit': 1, 'doctype': 'DocField', 'fieldname': 'delivery_note_details', 'fieldtype': 'Table', diff --git a/erpnext/stock/doctype/delivery_note_detail/delivery_note_detail.txt b/erpnext/stock/doctype/delivery_note_detail/delivery_note_detail.txt index be7b98f771..806803f73a 100644 --- a/erpnext/stock/doctype/delivery_note_detail/delivery_note_detail.txt +++ b/erpnext/stock/doctype/delivery_note_detail/delivery_note_detail.txt @@ -5,15 +5,17 @@ { 'creation': '2010-08-08 17:08:58', 'docstatus': 0, - 'modified': '2011-09-07 17:34:13', + 'modified': '2011-10-18 16:32:44', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { + '_last_update': '1311621379', 'autoname': 'DND/.#######', 'colour': 'White:FFF', + 'default_print_format': 'Standard', 'doctype': 'DocType', 'istable': 1, 'module': 'Stock', @@ -21,7 +23,7 @@ 'section_style': 'Tray', 'server_code_error': ' ', 'show_in_menu': 0, - 'version': 40 + 'version': 43 }, # These values are common for all DocField @@ -354,6 +356,37 @@ 'width': '100px' }, + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'pack_size', + 'fieldtype': 'Data', + 'label': 'Pack Size', + 'no_copy': 0, + 'permlevel': 0, + 'print_hide': 1 + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'packed_by', + 'fieldtype': 'Data', + 'label': 'Packed By', + 'permlevel': 0, + 'print_hide': 1 + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'packing_checked_by', + 'fieldtype': 'Data', + 'label': 'Packing Checked By', + 'permlevel': 0, + 'print_hide': 1 + }, + # DocField { 'doctype': 'DocField',