Merge branch 'latest' of github.com:webnotes/erpnext into latest
diff --git a/erpnext/buying/doctype/supplier_quotation/__init__.py b/erpnext/buying/doctype/supplier_quotation/__init__.py
deleted file mode 100755
index e69de29..0000000
--- a/erpnext/buying/doctype/supplier_quotation/__init__.py
+++ /dev/null
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
deleted file mode 100755
index bf9bdc1..0000000
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
+++ /dev/null
@@ -1,82 +0,0 @@
-cur_frm.cscript.tname = "Supplier Quotation Detail";
-cur_frm.cscript.fname = "supplier_quotation_details";
-
-$import(Purchase Common)
-
-// ======================= OnLoad =============================================
-cur_frm.cscript.onload = function(doc,cdt,cdn){
-
-
- if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
- if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
- if(!doc.conversion_rate) set_multiple(cdt,cdn,{conversion_rate:'1'});
- if(!doc.currency) set_multiple(cdt,cdn,{currency:sys_defaults.currency});
-
- if(doc.__islocal && has_common(user_roles,['Partner','Supplier'])){
- get_server_fields('get_contact_details','','',doc,cdt,cdn,1);
- }
- else if(doc.__islocal && doc.supplier){
- get_server_fields('get_supplier_details',doc.supplier,'',doc,cdt,cdn,1);
- }
-
-}
-
-//======================= Refresh ==============================================
-cur_frm.cscript.refresh = function(doc,cdt,cdn){
-
- if(has_common(user_roles,['Purchase User','Purchase Manager'])){
- unhide_field(['Approve / Unapprove']);
- if(doc.approval_status == 'Approved' && doc.status == 'Submitted') { unhide_field(['Create PO']);}
- else { hide_field(['Create PO']);}
- }
- else{
- hide_field(['Create PO']);
- hide_field(['Approve / Unapprove']);
- }
-}
-
-//======================= RFQ NO Get Query ===============================================
-cur_frm.fields_dict['rfq_no'].get_query = function(doc){
- return 'SELECT DISTINCT `tabRFQ`.name FROM `tabRFQ` WHERE `tabRFQ`.docstatus = 1 AND `tabRFQ`.name LIKE "%s"';
-}
-
-// ***************** Get Contact Person based on supplier selected *****************
-cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
- return 'SELECT `tabContact`.contact_name FROM `tabContact` WHERE `tabContact`.is_supplier = 1 AND `tabContact`.supplier = "'+ doc.supplier+'" AND `tabContact`.docstatus != 2 AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
-}
-
-//=================== On Button Click Functions =====================
-
-//======================== Create Purchase Order =========================================
-cur_frm.cscript['Create PO'] = function(doc,cdt,cdn){
- n = createLocal("Purchase Order");
- $c('dt_map', args={
- 'docs':compress_doclist([locals["Purchase Order"][n]]),
- 'from_doctype':'Supplier Quotation',
- 'to_doctype':'Purchase Order',
- 'from_docname':doc.name,
- 'from_to_list':"[['Supplier Quotation', 'Purchase Order'], ['Supplier Quotation Detail', 'PO Detail']]"
- }
- , function(r,rt) {
- loaddoc("Purchase Order", n);
- }
- );
-}
-
-//======================== Get Report ===================================================
-cur_frm.cscript['Get Report'] = function(doc,cdt,cdn) {
- var callback = function(report){
- report.set_filter('PO Detail', 'Ref Doc',doc.name)
- }
- loadreport('PO Detail','Itemwise Purchase Details', callback);
-}
-
-cur_frm.cscript['Approve / Unapprove'] = function(doc, cdt, cdn){
- var d = locals[cdt][cdn];
-
- $c_obj(make_doclist(doc.doctype, doc.name),'update_approval_status','', function(r,rt){
- refresh_field('approval_status');
- doc.approval_status = r.message;
- cur_frm.cscript.refresh(d, d.cdt, d.cdn);
- });
-}
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
deleted file mode 100755
index ac59430..0000000
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
+++ /dev/null
@@ -1,104 +0,0 @@
-class DocType:
- def __init__(self,doc,doclist=[]):
- self.doc = doc
- self.doclist = doclist
- self.fname = 'supplier_quotation_details'
- self.tname = 'Supplier Quotation Detail'
-
- def autoname(self):
- self.doc.name = make_autoname(self.doc.naming_series+'.#####')
-
- def get_contact_details(self):
- cd = sql("select concat_ws(' ',t2.first_name,t2.last_name),t2.contact_no, t2.email_id, t2.supplier, t2.supplier_name, t2.supplier_address from `tabProfile` t1, `tabContact` t2 where t1.email=t2.email_id and t1.name=%s", session['user'])
- ret = {
- 'contact_person' : cd and cd[0][0] or '',
- 'contact_no' : cd and cd[0][1] or '',
- 'email' : cd and cd[0][2] or '',
- 'supplier' : cd and cd[0][3] or '',
- 'supplier_name' : cd and cd[0][4] or '',
- 'supplier_address': cd and cd[0][5] or ''
- }
- return ret
-
- def get_rfq_details(self):
- self.doc.clear_table(self.doclist, 'supplier_quotation_details')
- get_obj('DocType Mapper','RFQ-Supplier Quotation').dt_map('RFQ','Supplier Quotation',self.doc.rfq_no, self.doc, self.doclist, "[['RFQ Detail', 'Supplier Quotation Detail']]")
-
- #update approval status
- def update_approval_status(self):
- if not self.doc.approval_status or self.doc.approval_status == 'Not Approved':
- set(self.doc, 'approval_status','Approved')
- return self.doc.approval_status
- elif self.doc.approval_status == 'Approved':
- pc_obj = get_obj('Purchase Common')
- pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Order', docname = self.doc.name, detail_doctype = 'PO Detail')
- set(self.doc, 'approval_status', 'Not Approved')
- return self.doc.approval_status
-
- def validate_item_list(self):
- if not getlist(self.doclist, 'supplier_quotation_details'):
- msgprint("Please fetch RFQ details against which this quotation is prapared")
- raise Exception
-
- # On Validate
- #---------------------------------------------------------------------------------------------------------
- def validate(self):
- self.validate_item_list()
- pc_obj = get_obj(dt='Purchase Common')
- pc_obj.validate_for_items(self)
- pc_obj.validate_conversion_rate(self)
- pc_obj.validate_doc(obj = self, prevdoc_doctype = 'RFQ', prevdoc_docname = self.doc.rfq_no)
-
- def on_update(self):
- set(self.doc, 'status', 'Draft')
-
- # checks whether previous documents doctstatus is submitted.
- def check_previous_docstatus(self):
- pc_obj = get_obj(dt = 'Purchase Common')
- for d in getlist(self.doclist, 'rfq_details'):
- if d.prevdoc_docname:
- pc_obj.check_docstatus(check = 'Previous', doctype = 'Indent', docname = d.prevdoc_docname)
-
- #update rfq
- def update_rfq(self, status):
- prevdoc=''
- for d in getlist(self.doclist, 'supplier_quotation_details'):
- if d.prevdoc_docname:
- prevdoc = d.prevdoc_docname
-
- if status == 'Submitted':
- sql("update `tabRFQ` set status = 'Quotation Received' where name=%s", prevdoc)
- elif status == 'Cancelled':
- sql("update `tabRFQ` set status = 'Submitted' where name=%s", prevdoc)
-
- # On Submit
- def on_submit(self):
- # checks whether previous documents doctstatus is submitted.
- self.check_previous_docstatus()
- set(self.doc, 'status', 'Submitted')
- self.update_rfq('Submitted')
-
- # On Cancel
- #---------------------------------------------------------------------------------------------------------
- #def check_next_docstatus(self):
- # submitted = sql("selct name from `tabPurchase Order` where ref_sq = '%s' and docstatus = 1" % self.doc.name)
- # if submitted:
- # msgprint("Purchase Order : " + cstr(submitted[0][0]) + " has already been submitted !")
- # raise Exception
-
- def on_cancel(self):
- pc_obj = get_obj('Purchase Common')
- pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Order', docname = self.doc.name, detail_doctype = 'PO Detail')
- #self.check_next_docstatus()
- set(self.doc, 'status', 'Cancelled')
- self.update_rfq('Cancelled')
-
- # GET TERMS & CONDITIONS
- # =====================================================================================
- def get_tc_details(self):
- return get_obj('Purchase Common').get_tc_details(self)
-
- # Get Supplier Details
- # --------------------
- def get_supplier_details(self, name = ''):
- return get_obj('Purchase Common').get_supplier_details(name)
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.txt b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.txt
deleted file mode 100755
index 1297246..0000000
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.txt
+++ /dev/null
@@ -1,607 +0,0 @@
-# DocType, Supplier Quotation
-[
-
- # These values are common in all dictionaries
- {
- 'creation': '2010-10-27 12:55:42',
- 'docstatus': 0,
- 'modified': '2011-01-28 11:41:36',
- 'modified_by': 'rakesh@iwebnotes.com',
- 'owner': 'Administrator'
- },
-
- # These values are common for all DocType
- {
- 'autoname': 'SQ.#####',
- 'colour': 'White:FFF',
- 'doctype': 'DocType',
- 'in_create': 1,
- 'module': 'Buying',
- 'name': '__common__',
- 'read_only': 1,
- 'section_style': 'Tabbed',
- 'server_code_error': ' ',
- 'show_in_menu': 0,
- 'version': 241
- },
-
- # These values are common for all DocField
- {
- 'doctype': 'DocField',
- 'name': '__common__',
- 'parent': 'Supplier Quotation',
- 'parentfield': 'fields',
- 'parenttype': 'DocType'
- },
-
- # These values are common for all DocPerm
- {
- 'doctype': 'DocPerm',
- 'name': '__common__',
- 'parent': 'Supplier Quotation',
- 'parentfield': 'permissions',
- 'parenttype': 'DocType',
- 'read': 1
- },
-
- # DocType, Supplier Quotation
- {
- 'doctype': 'DocType',
- 'name': 'Supplier Quotation'
- },
-
- # DocPerm
- {
- 'amend': 1,
- 'cancel': 1,
- 'create': 1,
- 'doctype': 'DocPerm',
- 'idx': 1,
- 'permlevel': 0,
- 'role': 'System Manager',
- 'submit': 1,
- 'write': 1
- },
-
- # DocPerm
- {
- 'amend': 1,
- 'cancel': 1,
- 'create': 1,
- 'doctype': 'DocPerm',
- 'idx': 2,
- 'permlevel': 0,
- 'role': 'Supplier',
- 'submit': 1,
- 'write': 1
- },
-
- # DocPerm
- {
- 'amend': 1,
- 'cancel': 1,
- 'create': 1,
- 'doctype': 'DocPerm',
- 'idx': 3,
- 'permlevel': 0,
- 'role': 'Purchase User',
- 'submit': 1,
- 'write': 1
- },
-
- # DocPerm
- {
- 'doctype': 'DocPerm',
- 'idx': 4,
- 'permlevel': 0,
- 'role': 'Purchase Manager'
- },
-
- # DocPerm
- {
- 'doctype': 'DocPerm',
- 'idx': 5,
- 'permlevel': 1,
- 'role': 'All'
- },
-
- # DocPerm
- {
- 'cancel': 0,
- 'doctype': 'DocPerm',
- 'idx': 6,
- 'permlevel': 2,
- 'role': 'Purchase User',
- 'submit': 0,
- 'write': 1
- },
-
- # DocPerm
- {
- 'cancel': 0,
- 'doctype': 'DocPerm',
- 'idx': 7,
- 'permlevel': 2,
- 'role': 'Purchase Manager',
- 'submit': 0,
- 'write': 1
- },
-
- # DocField
- {
- 'allow_on_submit': 1,
- 'doctype': 'DocField',
- 'fieldtype': 'Button',
- 'idx': 1,
- 'label': 'Create PO',
- 'oldfieldtype': 'Button',
- 'permlevel': 2,
- 'trigger': 'Client'
- },
-
- # DocField
- {
- 'colour': 'White:FFF',
- 'description': 'Enter item rates and details of supplier who is providing quotation',
- 'doctype': 'DocField',
- 'fieldtype': 'Section Break',
- 'idx': 2,
- 'label': 'Basic Info',
- 'oldfieldtype': 'Section Break',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldtype': 'Column Break',
- 'idx': 3,
- 'oldfieldtype': 'Column Break',
- 'permlevel': 0,
- 'width': '50%'
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'naming_series',
- 'fieldtype': 'Select',
- 'idx': 4,
- 'in_filter': 1,
- 'label': 'Series',
- 'no_copy': 1,
- 'oldfieldname': 'naming_series',
- 'oldfieldtype': 'Select',
- 'options': '\nSQTN',
- 'permlevel': 0,
- 'reqd': 1
- },
-
- # DocField
- {
- 'colour': 'White:FFF',
- 'default': 'Draft',
- 'doctype': 'DocField',
- 'fieldname': 'status',
- 'fieldtype': 'Select',
- 'idx': 5,
- 'in_filter': 1,
- 'label': 'Status',
- 'oldfieldname': 'status',
- 'oldfieldtype': 'Select',
- 'options': '\nDraft\nQuotation Sent\nOrder Confirmed\nCancelled',
- 'permlevel': 1,
- 'reqd': 1,
- 'search_index': 1
- },
-
- # DocField
- {
- 'default': 'Today',
- 'description': 'The date at which current entry is made in system.',
- 'doctype': 'DocField',
- 'fieldname': 'transaction_date',
- 'fieldtype': 'Date',
- 'idx': 6,
- 'in_filter': 1,
- 'label': 'Quotation Date',
- 'oldfieldname': 'transaction_date',
- 'oldfieldtype': 'Date',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'activity_log_text',
- 'fieldtype': 'Text',
- 'idx': 7,
- 'label': 'Activity Log Text',
- 'oldfieldname': 'activity_log_text',
- 'oldfieldtype': 'Text',
- 'permlevel': 2
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'company',
- 'fieldtype': 'Link',
- 'idx': 8,
- 'in_filter': 1,
- 'label': 'For Company',
- 'oldfieldname': 'company',
- 'oldfieldtype': 'Link',
- 'options': 'Company',
- 'permlevel': 0,
- 'reqd': 1
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'fiscal_year',
- 'fieldtype': 'Select',
- 'idx': 9,
- 'in_filter': 1,
- 'label': 'Fiscal Year',
- 'oldfieldname': 'fiscal_year',
- 'oldfieldtype': 'Select',
- 'options': 'link:Fiscal Year',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'amended_from',
- 'fieldtype': 'Data',
- 'hidden': 1,
- 'idx': 10,
- 'label': 'Amended From',
- 'no_copy': 1,
- 'oldfieldname': 'amended_from',
- 'oldfieldtype': 'Data',
- 'permlevel': 1,
- 'print_hide': 1
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'amendment_date',
- 'fieldtype': 'Date',
- 'hidden': 1,
- 'idx': 11,
- 'label': 'Amendment Date',
- 'no_copy': 1,
- 'oldfieldname': 'amendment_date',
- 'oldfieldtype': 'Date',
- 'permlevel': 1,
- 'print_hide': 1
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldtype': 'Column Break',
- 'idx': 12,
- 'oldfieldtype': 'Column Break',
- 'permlevel': 0,
- 'width': '50%'
- },
-
- # DocField
- {
- 'allow_on_submit': 0,
- 'description': 'You can create PO when quotation gets approved.',
- 'doctype': 'DocField',
- 'fieldname': 'approval_status',
- 'fieldtype': 'Select',
- 'idx': 13,
- 'label': 'Approval Status',
- 'oldfieldname': 'approval_status',
- 'oldfieldtype': 'Select',
- 'options': '\nApproved\nNot Approved',
- 'permlevel': 2
- },
-
- # DocField
- {
- 'allow_on_submit': 1,
- 'colour': 'White:FFF',
- 'doctype': 'DocField',
- 'fieldtype': 'Button',
- 'idx': 14,
- 'label': 'Approve / Unapprove',
- 'oldfieldtype': 'Button',
- 'permlevel': 2,
- 'trigger': 'Client'
- },
-
- # DocField
- {
- 'colour': 'White:FFF',
- 'doctype': 'DocField',
- 'fieldname': 'supplier',
- 'fieldtype': 'Link',
- 'idx': 15,
- 'in_filter': 1,
- 'label': 'Supplier',
- 'oldfieldname': 'supplier',
- 'oldfieldtype': 'Link',
- 'options': 'Supplier',
- 'permlevel': 0,
- 'reqd': 1,
- 'trigger': 'Client'
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'supplier_name',
- 'fieldtype': 'Data',
- 'idx': 16,
- 'in_filter': 1,
- 'label': 'Supplier Name',
- 'oldfieldname': 'supplier_name',
- 'oldfieldtype': 'Data',
- 'permlevel': 1
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'supplier_address',
- 'fieldtype': 'Text',
- 'idx': 17,
- 'label': 'Supplier Address',
- 'oldfieldname': 'supplier_address',
- 'oldfieldtype': 'Text',
- 'permlevel': 1
- },
-
- # DocField
- {
- 'colour': 'White:FFF',
- 'doctype': 'DocField',
- 'fieldname': 'contact_person',
- 'fieldtype': 'Link',
- 'idx': 18,
- 'in_filter': 0,
- 'label': 'Contact Person',
- 'oldfieldname': 'contact_person',
- 'oldfieldtype': 'Link',
- 'permlevel': 0,
- 'trigger': 'Client'
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'contact_no',
- 'fieldtype': 'Data',
- 'idx': 19,
- 'label': 'Contact No',
- 'oldfieldname': 'contact_no',
- 'oldfieldtype': 'Data',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'email',
- 'fieldtype': 'Data',
- 'idx': 20,
- 'label': 'Email',
- 'oldfieldname': 'email',
- 'oldfieldtype': 'Data',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldtype': 'Section Break',
- 'idx': 21,
- 'label': 'Item Details',
- 'oldfieldtype': 'Section Break',
- 'options': 'Simple',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'rfq_no',
- 'fieldtype': 'Link',
- 'hidden': 1,
- 'idx': 22,
- 'label': 'RFQ No',
- 'oldfieldname': 'rfq_no',
- 'oldfieldtype': 'Link',
- 'options': 'RFQ',
- 'permlevel': 0,
- 'print_hide': 1,
- 'report_hide': 1,
- 'trigger': 'Client'
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldtype': 'Button',
- 'idx': 23,
- 'label': 'Get Items',
- 'oldfieldtype': 'Button',
- 'options': 'get_rfq_details',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldtype': 'Column Break',
- 'idx': 24,
- 'oldfieldtype': 'Column Break',
- 'permlevel': 0,
- 'width': '50%'
- },
-
- # DocField
- {
- 'colour': 'White:FFF',
- 'description': "Supplier's currency",
- 'doctype': 'DocField',
- 'fieldname': 'currency',
- 'fieldtype': 'Select',
- 'idx': 25,
- 'label': 'Currency',
- 'oldfieldname': 'currency',
- 'oldfieldtype': 'Select',
- 'options': 'link:Currency',
- 'permlevel': 0,
- 'reqd': 1
- },
-
- # DocField
- {
- 'colour': 'White:FFF',
- 'default': '1',
- 'description': "Rate at which supplier's currency is converted to your currency",
- 'doctype': 'DocField',
- 'fieldname': 'conversion_rate',
- 'fieldtype': 'Currency',
- 'idx': 26,
- 'label': 'Conversion Rate',
- 'no_copy': 1,
- 'oldfieldname': 'conversion_rate',
- 'oldfieldtype': 'Currency',
- 'permlevel': 0,
- 'print_hide': 1,
- 'reqd': 1,
- 'trigger': 'Client'
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldtype': 'Section Break',
- 'idx': 27,
- 'oldfieldtype': 'Section Break',
- 'options': 'Simple',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'supplier_quotation_details',
- 'fieldtype': 'Table',
- 'idx': 28,
- 'label': 'Quotation Details1',
- 'oldfieldname': 'supplier_quotation_details',
- 'oldfieldtype': 'Table',
- 'options': 'Supplier Quotation Detail',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'net_total',
- 'fieldtype': 'Currency',
- 'idx': 29,
- 'label': 'Net Total',
- 'oldfieldname': 'net_total',
- 'oldfieldtype': 'Currency',
- 'permlevel': 1
- },
-
- # DocField
- {
- 'colour': 'White:FFF',
- 'description': 'Enter terms and conditions which you want to include',
- 'doctype': 'DocField',
- 'fieldtype': 'Section Break',
- 'idx': 30,
- 'label': 'Terms',
- 'oldfieldtype': 'Section Break',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'tc_name',
- 'fieldtype': 'Link',
- 'idx': 31,
- 'label': 'Select Terms',
- 'oldfieldname': 'tc_name',
- 'oldfieldtype': 'Link',
- 'options': 'Term',
- 'permlevel': 0,
- 'print_hide': 1,
- 'report_hide': 1
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldtype': 'Button',
- 'idx': 32,
- 'label': 'Get Terms',
- 'oldfieldtype': 'Button',
- 'options': 'get_tc_details',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldtype': 'HTML',
- 'idx': 33,
- 'label': 'Terms HTML',
- 'oldfieldtype': 'HTML',
- 'options': 'You can add Terms and Notes that will be printed in the Transaction',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': 'DocField',
- 'fieldname': 'terms',
- 'fieldtype': 'Text Editor',
- 'idx': 34,
- 'label': 'Terms and Conditions',
- 'oldfieldname': 'terms',
- 'oldfieldtype': 'Text Editor',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'colour': 'White:FFF',
- 'description': "Next steps will be visible when you submit the supplier quotation and approval status is 'Approved'",
- 'doctype': 'DocField',
- 'fieldtype': 'Section Break',
- 'idx': 35,
- 'label': 'Next Steps',
- 'oldfieldtype': 'Section Break',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'allow_on_submit': 1,
- 'colour': 'White:FFF',
- 'doctype': 'DocField',
- 'fieldtype': 'Button',
- 'idx': 36,
- 'label': 'Get Report',
- 'oldfieldtype': 'Button',
- 'permlevel': 0,
- 'trigger': 'Client'
- }
-]
\ No newline at end of file
diff --git a/erpnext/stock/DocType Mapper/Delivery Note-Packing Slip/Delivery Note-Packing Slip.txt b/erpnext/stock/DocType Mapper/Delivery Note-Packing Slip/Delivery Note-Packing Slip.txt
index baf2b74..f59ab73 100644
--- a/erpnext/stock/DocType Mapper/Delivery Note-Packing Slip/Delivery Note-Packing Slip.txt
+++ b/erpnext/stock/DocType Mapper/Delivery Note-Packing Slip/Delivery Note-Packing Slip.txt
@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
- 'creation': '2012-02-13 11:28:48',
+ 'creation': '2012-02-02 11:50:33',
'docstatus': 0,
- 'modified': '2012-02-13 11:28:48',
+ 'modified': '2012-02-21 16:11:29',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -34,7 +34,7 @@
'from_doctype': u'Delivery Note',
'module': u'Stock',
'name': '__common__',
- 'ref_doc_submitted': 1,
+ 'ref_doc_submitted': 0,
'to_doctype': u'Packing Slip'
},
@@ -77,7 +77,7 @@
'from_table': u'Delivery Note',
'match_id': 0,
'to_table': u'Packing Slip',
- 'validation_logic': u'docstatus=1'
+ 'validation_logic': u'docstatus=0'
},
# Table Mapper Detail
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index d9f4795..10297dd 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -52,7 +52,7 @@
unhide_field(['SMS','Send SMS', 'message', 'customer_mobile_no', 'Repair Delivery Note']);
}
- if(doc.docstatus==1) {
+ if(doc.docstatus==0 && !doc.__islocal) {
cur_frm.add_custom_button('Make Packing Slip', cur_frm.cscript['Make Packing Slip']);
}
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index 60aee13..40fdc94 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -309,6 +309,7 @@
# ON SUBMIT
# =================================================================================================
def on_submit(self):
+ self.validate_packed_qty()
set(self.doc, 'message', 'Items against your Order #%s have been delivered. Delivery #%s: ' % (self.doc.po_no, self.doc.name))
self.check_qty_in_stock()
# Check for Approving Authority
@@ -326,6 +327,28 @@
set(self.doc, 'status', 'Submitted')
+ def validate_packed_qty(self):
+ """
+ Validate that if packed qty exists, it should be equal to qty
+ """
+ if not any([d.fields.get('packed_qty') for d in self.doclist]):
+ return
+ packing_error_list = []
+ for d in self.doclist:
+ if d.doctype != 'Delivery Note Detail': continue
+ if d.fields.get('qty') != d.fields.get('packed_qty'):
+ packing_error_list.append([
+ d.fields.get('item_code', ''),
+ d.fields.get('qty', ''),
+ d.fields.get('packed_qty', '')
+ ])
+ if packing_error_list:
+ from webnotes.utils import cstr
+ err_msg = "\n".join([("Item: " + d[0] + ", Qty: " + cstr(d[1]) \
+ + ", Packed: " + cstr(d[2])) for d in packing_error_list])
+ webnotes.msgprint("Packing Error:\n" + err_msg, raise_exception=1)
+
+
# *********** Checks whether actual quantity is present in warehouse *************
def check_qty_in_stock(self):
for d in getlist(self.doclist, 'packing_details'):
diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.js b/erpnext/stock/doctype/packing_slip/packing_slip.js
index 2e728f6..7359ffa 100644
--- a/erpnext/stock/doctype/packing_slip/packing_slip.js
+++ b/erpnext/stock/doctype/packing_slip/packing_slip.js
@@ -1,12 +1,12 @@
cur_frm.fields_dict['delivery_note'].get_query = function(doc, cdt, cdn) {
- return 'SELECT name FROM `tabDelivery Note` WHERE docstatus=1 AND %(key)s LIKE "%s"';
+ return 'SELECT name FROM `tabDelivery Note` WHERE docstatus=0 AND %(key)s LIKE "%s"';
}
cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
return 'SELECT name, description FROM `tabItem` WHERE name IN ( \
- SELECT item_code FROM `tabDelivery Note Detail` \
- WHERE parent="' + doc.delivery_note + '") AND %(key)s LIKE "%s" LIMIT 50';
+ SELECT item_code FROM `tabDelivery Note Detail` dnd \
+ WHERE parent="' + doc.delivery_note + '" AND qty > packed_qty) AND %(key)s LIKE "%s" LIMIT 50';
}
@@ -39,8 +39,7 @@
if(r.exc) {
msgprint(r.exc);
} else {
- refresh_field('item_details');
- refresh_field('naming_series');
+ refresh_many(['item_details', 'naming_series', 'from_case_no', 'to_case_no'])
}
});
}
diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.py b/erpnext/stock/doctype/packing_slip/packing_slip.py
index 33ec2b5..23367c7 100644
--- a/erpnext/stock/doctype/packing_slip/packing_slip.py
+++ b/erpnext/stock/doctype/packing_slip/packing_slip.py
@@ -28,9 +28,10 @@
WHERE name=%(delivery_note)s
""", self.doc.fields)
- if not(res and res[0][0]==1):
+ if not(res and res[0][0]==0):
webnotes.msgprint("""Invalid Delivery Note. Delivery Note should exist
- and should be submitted. Please rectify and try again.""", raise_exception=1)
+ and should be in draft state. Please rectify and try again.""",
+ raise_exception=1)
def validate_case_nos(self):
@@ -46,12 +47,8 @@
""", self.doc.fields)
if res:
- recommended_case_no = webnotes.conn.sql("""\
- SELECT MAX(to_case_no) FROM `tabPacking Slip`
- WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.doc.fields)
-
webnotes.msgprint("""Case No(s). already in use. Please rectify and try again.
- Recommended <b>From Case No. = %s</b>""" % (cint(recommended_case_no[0][0]) + 1),
+ Recommended <b>From Case No. = %s</b>""" % self.get_recommended_case_no(),
raise_exception=1)
@@ -75,13 +72,18 @@
* Item Quantity dict of current packing slip doc
* No. of Cases of this packing slip
"""
- item_codes = ", ".join([('"' + d.item_code + '"') for d in self.doclist])
+ item_codes = ", ".join([('"' + d.item_code + '"') for d in
+ self.doclist])
+
+ if not item_codes: webnotes.msgprint("No Items to Pack",
+ raise_exception=1)
res = webnotes.conn.sql("""\
SELECT item_code, IFNULL(SUM(qty), 0) as qty, IFNULL(packed_qty, 0) as packed_qty, stock_uom
FROM `tabDelivery Note Detail`
WHERE parent = "%s" AND item_code IN (%s)
- GROUP BY item_code""" % (self.doc.delivery_note, item_codes), as_dict=1)
+ GROUP BY item_code""" % (self.doc.delivery_note, item_codes),
+ as_dict=1)
ps_item_qty = dict([[d.item_code, d.qty] for d in self.doclist])
@@ -150,7 +152,23 @@
"""
Fill empty columns in Packing Slip Detail
"""
+ self.doc.from_case_no = self.get_recommended_case_no()
+
from webnotes.model.code import get_obj
for d in self.doclist:
psd_obj = get_obj(doc=d)
psd_obj.get_item_details(self.doc.delivery_note)
+
+
+ def get_recommended_case_no(self):
+ """
+ Returns the next case no. for a new packing slip for a delivery
+ note
+ """
+ recommended_case_no = webnotes.conn.sql("""\
+ SELECT MAX(to_case_no) FROM `tabPacking Slip`
+ WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.doc.fields)
+
+ return cint(recommended_case_no[0][0]) + 1
+
+