diff --git a/patches/patch.py b/patches/patch.py
index 8b7276b00d..e810268f1a 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','doctype','item')
+ reload_doc('selling','doctype','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/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js
index f21df25c47..b3dcde681a 100644
--- a/selling/doctype/quotation/quotation.js
+++ b/selling/doctype/quotation/quotation.js
@@ -11,7 +11,7 @@ $import(SMS Control)
// ONLOAD
// ===================================================================================
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.quotation_to) hide_field(['customer','customer_address','contact_person','customer_name','lead', 'lead_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
if(!doc.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
@@ -21,7 +21,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
//if(!doc.price_list_name && sys_defaults.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
-
+
if(doc.quotation_to) {
if(doc.quotation_to == 'Customer') {
hide_field(['lead', 'lead_name']);
@@ -34,7 +34,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
// load default charges
- if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length)
+ if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length)
cur_frm.cscript.load_taxes(doc, cdt, cdn);
}
@@ -46,9 +46,9 @@ cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
- else if(doc.quotation_to == 'Customer'){
+ else if(doc.quotation_to == 'Customer'){
unhide_field(['customer']);
- hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);
+ hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);
doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
//refresh_many(['lead','customer']);
@@ -56,7 +56,7 @@ cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
-//================ hide - unhide fields on basis of quotation to either lead or customer ===============================
+//================ hide - unhide fields on basis of quotation to either lead or customer ===============================
cur_frm.cscript.quotation_to = function(doc,cdt,cdn){
cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
//doc.customer_address = doc.territory = doc.contact_no = doc.email_id = "";
@@ -77,7 +77,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.add_custom_button('Set as Lost', cur_frm.cscript['Declare Order Lost']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
-
+
if (!doc.docstatus) hide_field(['Update Follow up']);
else unhide_field(['Update Follow up']);
//cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
@@ -111,7 +111,7 @@ cur_frm.cscript.customer = function(doc,dt,dn) {
var callback = function(r,rt) {
var doc = locals[cur_frm.doctype][cur_frm.docname];
cur_frm.refresh();
- }
+ }
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
@@ -123,12 +123,12 @@ cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc
cur_frm.fields_dict.customer_address.on_new = function(dn) {
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
- locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+ locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
- locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+ locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
@@ -146,7 +146,7 @@ cur_frm.fields_dict['lead'].get_query = function(doc,cdt,cdn){
cur_frm.cscript.lead = function(doc, cdt, cdn) {
if(doc.lead) get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
- if(doc.lead) unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);
+ if(doc.lead) unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);
}
@@ -166,7 +166,7 @@ cur_frm.fields_dict['enq_no'].get_query = function(doc,cdt,cdn){
cur_frm.cscript['Make Sales Order'] = function() {
var doc = cur_frm.doc;
- if (doc.docstatus == 1) {
+ if (doc.docstatus == 1) {
var n = createLocal("Sales Order");
$c('dt_map', args={
'docs':compress_doclist([locals["Sales Order"][n]]),
@@ -186,17 +186,17 @@ cur_frm.cscript['Pull Enquiry Detail'] = function(doc,cdt,cdn){
var callback = function(r,rt){
if(r.message){
doc.quotation_to = r.message;
-
+
if(doc.quotation_to == 'Lead') {
- unhide_field(['lead','lead_name','address_display','contact_mobile','contact_email','territory']);
+ unhide_field(['lead','lead_name','address_display','contact_mobile','contact_email','territory']);
}
else if(doc.quotation_to == 'Customer') {
unhide_field(['customer','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
refresh_many(['quotation_details','quotation_to','customer','customer_address','contact_person','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','order_type']);
}
- }
-
+ }
+
$c_obj(make_doclist(doc.doctype, doc.name),'pull_enq_details','',callback);
}
@@ -217,7 +217,7 @@ cur_frm.cscript['Update Follow up'] = function(doc){
//-------------------------
cur_frm.cscript['Declare Order Lost'] = function(){
var qtn_lost_dialog;
-
+
set_qtn_lost_dialog = function(doc,cdt,cdn){
qtn_lost_dialog = new Dialog(400,400,'Add Quotation Lost Reason');
qtn_lost_dialog.make_body([
@@ -226,26 +226,26 @@ cur_frm.cscript['Declare Order Lost'] = function(){
['HTML', 'Response', '
'],
['HTML', 'Add Reason', '']
]);
-
+
var add_reason_btn1 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn1.innerHTML = 'Add';
add_reason_btn1.onclick = function(){ qtn_lost_dialog.add(); }
-
+
var add_reason_btn2 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn2.innerHTML = 'Cancel';
$y(add_reason_btn2,{marginLeft:'4px'});
add_reason_btn2.onclick = function(){ qtn_lost_dialog.hide();}
-
+
qtn_lost_dialog.onshow = function() {
qtn_lost_dialog.widgets['Quotation Lost Reason'].value = '';
$i('update_quotation_dialog_response').innerHTML = '';
}
-
+
qtn_lost_dialog.add = function() {
// sending...
$i('update_quotation_dialog_response').innerHTML = 'Processing...';
var arg = strip(qtn_lost_dialog.widgets['Quotation Lost Reason'].value);
- var call_back = function(r,rt) {
+ var call_back = function(r,rt) {
if(r.message == 'true'){
$i('update_quotation_dialog_response').innerHTML = 'Done';
qtn_lost_dialog.hide();
@@ -254,11 +254,11 @@ cur_frm.cscript['Declare Order Lost'] = function(){
if(arg) $c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_order_lost',arg,call_back);
else msgprint("Please add Quotation lost reason");
}
- }
-
+ }
+
if(!qtn_lost_dialog){
set_qtn_lost_dialog(doc,cdt,cdn);
- }
+ }
qtn_lost_dialog.show();
}
@@ -284,23 +284,23 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
//===================== Quotation to validation - either customer or lead mandatory ====================
cur_frm.cscript.quot_to_validate = function(doc,cdt,cdn){
-
+
if(doc.quotation_to == 'Lead'){
-
+
if(!doc.lead){
- alert("Lead is mandatory.");
- validated = false;
+ alert("Lead is mandatory.");
+ validated = false;
}
}
else if(doc.quotation_to == 'Customer'){
-
+
if(!doc.customer){
alert("Customer is mandatory.");
validated = false;
}
-
+
}
-
+
}
//===================validation function =================================
@@ -308,3 +308,35 @@ cur_frm.cscript.quot_to_validate = function(doc,cdt,cdn){
cur_frm.cscript.validate = function(doc,cdt,cdn){
cur_frm.cscript.quot_to_validate(doc,cdt,cdn);
}
+
+//================ Last Quoted Price and Last Sold Price suggestion ======================
+cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query= function(doc, cdt, cdn) {
+ var d = locals[cdt][cdn];
+ if(doc.customer)
+ return repl("SELECT i.name,i.item_code,concat('Last quoted at - ',cast(quote_rate as char)) as quote_rate,concat('Last sold at - ',cast(sales_rate as char)) as sales_rate FROM\
+ (\
+ select item_code,name from tabItem where tabItem.%(key)s like '%s'\
+ )i\
+ left join\
+ (\
+ select q.item_code,q.quote_rate from\
+ (\
+ select q.transaction_date,qd.item_code,basic_rate as quote_rate from `tabQuotation Detail` qd, `tabQuotation` q where q.name=qd.parent and q.docstatus=1 and customer='%(cust)s'\
+ )q,\
+ (\
+ select qd.item_code,max(transaction_date) as transaction_date from `tabQuotation Detail` qd, `tabQuotation` q where q.name=qd.parent and q.docstatus=1 and customer='%(cust)s' group by qd.item_code\
+ )m where q.item_code=m.item_code and q.transaction_date=m.transaction_date\
+ )q on i.item_code=q.item_code\
+ left join\
+ (\
+ select r.item_code,r.sales_rate from\
+ (\
+ select r.voucher_date,rd.item_code,basic_rate as sales_rate from `tabRV Detail` rd, `tabReceivable Voucher` r where r.name=rd.parent and r.docstatus=1 and customer='%(cust)s'\
+ )r,\
+ (\
+ select rd.item_code,max(voucher_date) as voucher_date from `tabRV Detail` rd, `tabReceivable Voucher` r where r.name=rd.parent and r.docstatus=1 and customer='%(cust)s' group by rd.item_code\
+ )m where r.item_code=m.item_code and r.voucher_date=m.voucher_date\
+ )s on i.item_code=s.item_code ORDER BY item_code LIMIT 50",{cust:doc.customer});
+ else
+ return "SELECT name, item_code FROM tabItem WHERE `tabItem`.%(key)s LIKE '%s' ORDER BY tabItem.item_code DESC LIMIT 50";
+}
\ No newline at end of file
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 0000000000..97f57a9f89
--- /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 3534dadc9a..e5acd163a7 100644
--- a/stock/doctype/delivery_note/delivery_note.py
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -13,7 +13,7 @@ sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
-
+
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
@@ -24,7 +24,7 @@ class DocType(TransactionBase):
self.doclist = doclist
self.tname = 'Delivery Note Detail'
self.fname = 'delivery_note_details'
-
+
# Notification objects
self.notify_obj = get_obj('Notification Control')
@@ -33,7 +33,7 @@ class DocType(TransactionBase):
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
-
+
# DOCTYPE TRIGGERS FUNCTIONS
# ==============================================================================
#************Fiscal Year Validation*****************************
@@ -48,21 +48,21 @@ class DocType(TransactionBase):
# *********** Get Commission rate of Sales Partner ****************
def get_comm_rate(self, sales_partner):
return get_obj('Sales Common').get_comm_rate(sales_partner, self)
-
+
# *************** Pull Sales Order Details ************************
def pull_sales_order_details(self):
self.validate_prev_docname()
self.doc.clear_table(self.doclist,'other_charges')
-
- if self.doc.sales_order_no:
+
+ if self.doc.sales_order_no:
get_obj('DocType Mapper', 'Sales Order-Delivery Note').dt_map('Sales Order', 'Delivery Note', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Delivery Note'],['Sales Order Detail', 'Delivery Note Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]")
else:
- msgprint("Please select Sales Order No. whose details need to be pulled")
+ msgprint("Please select Sales Order No. whose details need to be pulled")
return cstr(self.doc.sales_order_no)
-
-
+
+
#-------------------set item details -uom and item group----------------
def set_item_details(self):
for d in getlist(self.doclist,'delivery_note_details'):
@@ -70,14 +70,14 @@ class DocType(TransactionBase):
if not d.stock_uom: d.stock_uom = res and cstr(res[0][0]) or ''
if not d.item_group: d.item_group = res and cstr(res[0][1]) or ''
d.save()
-
+
# ::::: Validates that Sales Order is not pulled twice :::::::
def validate_prev_docname(self):
- for d in getlist(self.doclist, 'delivery_note_details'):
+ for d in getlist(self.doclist, 'delivery_note_details'):
if self.doc.sales_order_no == d.prevdoc_docname:
msgprint(cstr(self.doc.sales_order_no) + " sales order details have already been pulled. ")
raise Exception, "Validation Error. "
-
+
#Set Actual Qty based on item code and warehouse
#------------------------------------------------------
def set_actual_qty(self):
@@ -91,14 +91,14 @@ class DocType(TransactionBase):
# -------------------------------------
def get_tc_details(self):
return get_obj('Sales Common').get_tc_details(self)
-
+
#pull project customer
#-------------------------
def pull_project_customer(self):
res = sql("select customer from `tabProject` where name = '%s'"%self.doc.project_name)
if res:
get_obj('DocType Mapper', 'Project-Delivery Note').dt_map('Project', 'Delivery Note', self.doc.project_name, self.doc, self.doclist, "[['Project', 'Delivery Note']]")
-
+
# DELIVERY NOTE DETAILS TRIGGER FUNCTIONS
# ================================================================================
@@ -119,10 +119,10 @@ class DocType(TransactionBase):
}
return ret
-
+
# OTHER CHARGES TRIGGER FUNCTIONS
# ====================================================================================
-
+
# *********** Get Tax rate if account type is TAX ********************
def get_rate(self,arg):
return get_obj('Sales Common').get_rate(arg)
@@ -137,7 +137,7 @@ class DocType(TransactionBase):
def get_other_charges(self):
return get_obj('Sales Common').get_other_charges(self)
-
+
#check in manage account if sales order required or not.
# ====================================================================================
def so_required(self):
@@ -147,9 +147,9 @@ class DocType(TransactionBase):
if not d.prevdoc_docname:
msgprint("Sales Order No. required against item %s"%d.item_code)
raise Exception
-
-
+
+
# VALIDATE
# ====================================================================================
def validate(self):
@@ -167,13 +167,16 @@ class DocType(TransactionBase):
sales_com_obj.make_packing_list(self,'delivery_note_details')
get_obj('Stock Ledger').validate_serial_no(self, 'packing_details')
sales_com_obj.validate_max_discount(self, 'delivery_note_details') #verify whether rate is not greater than max discount
- sales_com_obj.get_allocated_sum(self) # this is to verify that the allocated % of sales persons is 100%
+ sales_com_obj.get_allocated_sum(self) # this is to verify that the allocated % of sales persons is 100%
sales_com_obj.check_conversion_rate(self)
# ::::::: Get total in Words ::::::::
dcc = TransactionBase().get_company_currency(self.doc.company)
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 :::::::
@@ -181,8 +184,7 @@ class DocType(TransactionBase):
self.doc.status = 'Draft'
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 ::::::::::::::
@@ -198,20 +200,20 @@ class DocType(TransactionBase):
if not res:
msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.doc.customer,self.doc.project_name,self.doc.project_name))
raise Exception
-
+
# Validate values with reference document
#----------------------------------------
def validate_reference_value(self):
get_obj('DocType Mapper', 'Sales Order-Delivery Note', with_children = 1).validate_reference_value(self, self.doc.name)
-
-
+
+
# ******* Validate Previous Document Details ************
def validate_prevdoc_details(self):
for d in getlist(self.doclist,'delivery_note_details'):
-
+
prevdoc = d.prevdoc_doctype
prevdoc_docname = d.prevdoc_docname
-
+
if prevdoc_docname and prevdoc:
# ::::::::::: Validates Transaction Date of DN and previous doc (i.e. SO , PO, PR) *********
trans_date = sql("select transaction_date from `tab%s` where name = '%s'" %(prevdoc,prevdoc_docname))[0][0]
@@ -259,7 +261,7 @@ class DocType(TransactionBase):
ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
if d.prevdoc_doctype and d.prevdoc_detail_docname and ch and ch[0][0]=='Yes':
self.validate_items_with_prevdoc(d)
-
+
# validates whether item is not entered twice
e = [d.item_code, d.description, d.warehouse, d.prevdoc_docname or '', d.batch_no or '']
f = [d.item_code, d.description, d.prevdoc_docname or '']
@@ -297,8 +299,8 @@ class DocType(TransactionBase):
for d in getlist(self.doclist, 'packing_details'):
bin = sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
- d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
-
+ d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
+
# ON SUBMIT
# =================================================================================================
@@ -322,7 +324,7 @@ class DocType(TransactionBase):
# on submit notification
self.notify_obj.notify_contact('Delivery Note',self.doc.doctype,self.doc.name, self.doc.email_id, self.doc.contact_person)
-
+
# *********** Checks whether actual quantity is present in warehouse *************
def check_qty_in_stock(self):
for d in getlist(self.doclist, 'packing_details'):
@@ -334,7 +336,7 @@ class DocType(TransactionBase):
# ON CANCEL
-# =================================================================================================
+# =================================================================================================
def on_cancel(self):
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_stop_sales_order(self)
@@ -345,14 +347,14 @@ class DocType(TransactionBase):
# :::::: set DN status :::::::
set(self.doc, 'status', 'Cancelled')
-
+
# ******************** Check Next DocStatus **************************
def check_next_docstatus(self):
submit_rv = sql("select t1.name from `tabReceivable Voucher` t1,`tabRV Detail` t2 where t1.name = t2.parent and t2.delivery_note = '%s' and t1.docstatus = 1" % (self.doc.name))
if submit_rv:
msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted !")
raise Exception , "Validation Error."
-
+
submit_in = sql("select t1.name from `tabInstallation Note` t1, `tabInstalled Item Details` t2 where t1.name = t2.parent and t2.prevdoc_docname = '%s' and t1.docstatus = 1" % (self.doc.name))
if submit_in:
msgprint("Installation Note : "+cstr(submit_in[0][0]) +" has already been submitted !")
@@ -369,11 +371,11 @@ class DocType(TransactionBase):
if not d[0]:
msgprint("Message: Please enter Warehouse for item %s as it is stock item."% d[1])
raise Exception
- # if prevdoc_doctype = "Sales Order"
+ # if prevdoc_doctype = "Sales Order"
if d[3] < 0 :
# Reduce Reserved Qty from warehouse
bin = get_obj('Warehouse', d[0]).update_bin(0, flt(update_stock) * flt(d[3]), 0, 0, 0, d[1], self.doc.transaction_date)
-
+
# Reduce actual qty from warehouse
self.make_sl_entry(d, d[0], - flt(d[2]) , 0, update_stock)
get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
@@ -383,7 +385,7 @@ class DocType(TransactionBase):
def get_item_list(self, is_stopped):
return get_obj('Sales Common').get_item_list(self, is_stopped)
-
+
# ********************** Make Stock Entry ************************************
def make_sl_entry(self, d, wh, qty, in_value, update_stock):
self.values.append({
@@ -394,8 +396,8 @@ class DocType(TransactionBase):
'posting_time' : self.doc.posting_time,
'voucher_type' : 'Delivery Note',
'voucher_no' : self.doc.name,
- 'voucher_detail_no' : '',
- 'actual_qty' : qty,
+ 'voucher_detail_no' : '',
+ 'actual_qty' : qty,
'stock_uom' : d[4],
'incoming_rate' : in_value,
'company' : self.doc.company,
@@ -403,9 +405,9 @@ class DocType(TransactionBase):
'is_cancelled' : (update_stock==1) and 'No' or 'Yes',
'batch_no' : d[5],
'serial_no' : d[6]
- })
+ })
+
-
# SEND SMS
# ============================================================================================
def send_sms(self):
@@ -436,3 +438,44 @@ class DocType(TransactionBase):
# ===========================================
def repair_delivery_note(self):
get_obj('Sales Common', 'Sales Common').repair_curr_doctype_details(self)
+
+ # Packing Slip Related
+ # ==========================================
+ 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+='