Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
0a55a35452
@ -155,7 +155,7 @@ class DocType(TransactionBase):
|
|||||||
#do not allow sales item in maintenance quotation and service item in sales quotation
|
#do not allow sales item in maintenance quotation and service item in sales quotation
|
||||||
#-----------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------
|
||||||
def validate_order_type(self):
|
def validate_order_type(self):
|
||||||
if self.doc.order_type == 'Maintenance':
|
if self.doc.order_type in ['Maintenance', 'Service']:
|
||||||
for d in getlist(self.doclist, 'quotation_details'):
|
for d in getlist(self.doclist, 'quotation_details'):
|
||||||
is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)
|
is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)
|
||||||
is_service_item = is_service_item and is_service_item[0][0] or 'No'
|
is_service_item = is_service_item and is_service_item[0][0] or 'No'
|
||||||
|
@ -222,7 +222,7 @@ cur_frm.cscript.price_list_name = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
// ******************** ITEM CODE ********************************
|
// ******************** ITEM CODE ********************************
|
||||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
|
cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
|
||||||
if (doc.order_type == 'Maintenance')
|
if (inList(['Maintenance', 'Service'], doc.order_type))
|
||||||
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description \
|
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description \
|
||||||
FROM tabItem WHERE tabItem.is_service_item="Yes" \
|
FROM tabItem WHERE tabItem.is_service_item="Yes" \
|
||||||
AND tabItem.docstatus != 2 \
|
AND tabItem.docstatus != 2 \
|
||||||
|
@ -54,8 +54,6 @@ cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Refresh
|
|
||||||
//==================
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
cur_frm.clear_custom_buttons();
|
cur_frm.clear_custom_buttons();
|
||||||
erpnext.hide_naming_series();
|
erpnext.hide_naming_series();
|
||||||
@ -69,17 +67,17 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
if(doc.status != 'Stopped') {
|
if(doc.status != 'Stopped') {
|
||||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||||
// delivery note
|
// delivery note
|
||||||
if(doc.per_delivered < 100 && doc.order_type!='Maintenance')
|
if(doc.per_delivered < 100 && doc.order_type=='Sales')
|
||||||
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
|
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
|
||||||
|
|
||||||
// maintenance
|
// maintenance
|
||||||
if(doc.per_delivered < 100 && doc.order_type=='Maintenance') {
|
if(doc.per_delivered < 100 && (doc.order_type !='Sales')) {
|
||||||
cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript.make_maintenance_visit);
|
cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript.make_maintenance_visit);
|
||||||
cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
|
cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// indent
|
// indent
|
||||||
if(doc.order_type != 'Maintenance')
|
if(!doc.order_type || (doc.order_type == 'Sales'))
|
||||||
cur_frm.add_custom_button('Make ' + get_doctype_label('Purchase Request'), cur_frm.cscript['Make Purchase Request']);
|
cur_frm.add_custom_button('Make ' + get_doctype_label('Purchase Request'), cur_frm.cscript['Make Purchase Request']);
|
||||||
|
|
||||||
// sales invoice
|
// sales invoice
|
||||||
|
@ -242,43 +242,16 @@ class DocType(TransactionBase):
|
|||||||
msgprint("There are no items of the quotation selected.")
|
msgprint("There are no items of the quotation selected.")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
# validate sales/ service item against order type
|
|
||||||
#----------------------------------------------------
|
|
||||||
def validate_sales_mntc_item(self):
|
|
||||||
if self.doc.order_type == 'Maintenance':
|
|
||||||
item_field = 'is_service_item'
|
|
||||||
order_type = 'Maintenance Order'
|
|
||||||
item_type = 'service item'
|
|
||||||
else :
|
|
||||||
item_field = 'is_sales_item'
|
|
||||||
order_type = 'Sales Order'
|
|
||||||
item_type = 'sales item'
|
|
||||||
|
|
||||||
for d in getlist(self.doclist, 'sales_order_details'):
|
|
||||||
res = sql("select %s from `tabItem` where name='%s'"% (item_field,d.item_code))
|
|
||||||
res = res and res[0][0] or 'No'
|
|
||||||
|
|
||||||
if res == 'No':
|
|
||||||
msgprint("You can not select non "+item_type+" "+d.item_code+" in "+order_type)
|
|
||||||
raise Exception
|
|
||||||
|
|
||||||
# validate sales/ maintenance quotation against order type
|
# validate sales/ maintenance quotation against order type
|
||||||
#------------------------------------------------------------------
|
#------------------------------------------------------------------
|
||||||
def validate_sales_mntc_quotation(self):
|
def validate_sales_mntc_quotation(self):
|
||||||
for d in getlist(self.doclist, 'sales_order_details'):
|
for d in getlist(self.doclist, 'sales_order_details'):
|
||||||
if d.prevdoc_docname:
|
if d.prevdoc_docname:
|
||||||
res = sql("select order_type from `tabQuotation` where name=%s", (d.prevdoc_docname))
|
res = sql("select name from `tabQuotation` where name=%s and order_type = %s", (d.prevdoc_docname, self.doc.order_type))
|
||||||
res = res and res[0][0] or ''
|
if not res:
|
||||||
|
msgprint("""Order Type (%s) should be same in Quotation: %s \
|
||||||
if self.doc.order_type== 'Maintenance' and res != 'Maintenance':
|
and current Sales Order""" % (self.doc.order_type, d.prevdoc_docname))
|
||||||
msgprint("You can not select non Maintenance Quotation against Maintenance Order")
|
|
||||||
raise Exception
|
|
||||||
elif self.doc.order_type != 'Maintenance' and res == 'Maintenance':
|
|
||||||
msgprint("You can not select non Sales Quotation against Sales Order")
|
|
||||||
raise Exception
|
|
||||||
|
|
||||||
#do not allow sales item/quotation in maintenance order and service item/quotation in sales order
|
|
||||||
#-----------------------------------------------------------------------------------------------
|
|
||||||
def validate_order_type(self):
|
def validate_order_type(self):
|
||||||
#validate delivery date
|
#validate delivery date
|
||||||
if self.doc.order_type == 'Sales' and not self.doc.delivery_date:
|
if self.doc.order_type == 'Sales' and not self.doc.delivery_date:
|
||||||
@ -286,7 +259,6 @@ class DocType(TransactionBase):
|
|||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
self.validate_sales_mntc_quotation()
|
self.validate_sales_mntc_quotation()
|
||||||
self.validate_sales_mntc_item()
|
|
||||||
|
|
||||||
#check for does customer belong to same project as entered..
|
#check for does customer belong to same project as entered..
|
||||||
#-------------------------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user