Merge branch 'master' into stable
This commit is contained in:
commit
594821e2eb
@ -31,7 +31,7 @@ class DocType:
|
||||
def get_address(self):
|
||||
add=sql("Select address from `tab%s` where name='%s'"%(self.doc.master_type,self.doc.master_name))
|
||||
ret={'address':add[0][0]}
|
||||
return cstr(ret)
|
||||
return ret
|
||||
|
||||
|
||||
# check whether master name entered for supplier/customer
|
||||
|
@ -56,7 +56,7 @@ class DocType(TransactionBase):
|
||||
'party_address': cstr(address_display)
|
||||
}
|
||||
|
||||
return cstr(ret)
|
||||
return ret
|
||||
|
||||
# Get TDS Return acknowledgement
|
||||
#-------------------------------
|
||||
|
@ -19,9 +19,9 @@ $.extend(cur_frm.cscript, {
|
||||
},
|
||||
hide_show_buttons: function(doc) {
|
||||
if(doc.docstatus==0) {
|
||||
hide_field('Installment Reciept'); show_field('Generate');
|
||||
hide_field('Installment Reciept'); unhide_field('Generate');
|
||||
} else if (doc.docstatus==1) {
|
||||
show_field('Installment Reciept');hide_field('Generate');
|
||||
unhide_field('Installment Reciept');hide_field('Generate');
|
||||
}
|
||||
},
|
||||
clear_installments: function(doc) {
|
||||
|
@ -345,7 +345,7 @@ class DocType(TransactionBase):
|
||||
# get tds rate
|
||||
# -------------
|
||||
def get_tds_rate(self):
|
||||
return str({'rate' : flt(get_value('Account', self.doc.tax_code, 'tax_rate'))})
|
||||
return {'rate' : flt(get_value('Account', self.doc.tax_code, 'tax_rate'))}
|
||||
|
||||
# set aging date
|
||||
#-------------------
|
||||
|
@ -90,12 +90,12 @@ class DocType:
|
||||
# get item details
|
||||
# ---------------------------------
|
||||
def get_item_details(self, arg =''):
|
||||
return cstr( get_obj(dt='Purchase Common').get_item_details(self,arg) )
|
||||
return get_obj(dt='Purchase Common').get_item_details(self,arg)
|
||||
|
||||
# Get UOM Details
|
||||
# ---------------------------------
|
||||
def get_uom_details(self, arg = ''):
|
||||
return cstr(get_obj(dt='Purchase Common').get_uom_details(arg))
|
||||
return get_obj(dt='Purchase Common').get_uom_details(arg)
|
||||
|
||||
# GET TERMS & CONDITIONS
|
||||
#-----------------------------
|
||||
|
@ -33,7 +33,7 @@ class DocType:
|
||||
leave_app = sql("select total_leave_days from `tabLeave Application` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
|
||||
leave_app = leave_app and flt(leave_app[0][0]) or 0
|
||||
ret = {'leave_balance':leave_all - leave_app}
|
||||
return str(ret)
|
||||
return ret
|
||||
|
||||
|
||||
# ************************************************ utilities *************************************************
|
||||
@ -55,7 +55,7 @@ class DocType:
|
||||
tot_days = date_diff(self.doc.to_date, self.doc.from_date) + 1
|
||||
holidays = self.get_holidays()
|
||||
ret = {'total_leave_days':flt(tot_days)-flt(holidays)}
|
||||
return str(ret)
|
||||
return ret
|
||||
|
||||
|
||||
# ************************************************ validate *************************************************
|
||||
|
@ -1,7 +1,7 @@
|
||||
# REMEMBER to update this
|
||||
# ========================
|
||||
|
||||
last_patch = 338
|
||||
last_patch = 339
|
||||
|
||||
#-------------------------------------------
|
||||
|
||||
@ -1405,3 +1405,5 @@ def execute(patch_no):
|
||||
# update name of questions page
|
||||
sql("update tabPage set name='questions' where name='Questions'")
|
||||
sql("update tabPage set name='question-view' where name='Question View'")
|
||||
elif patch_no == 339:
|
||||
reload_doc('production','doctype','bill_of_materials')
|
||||
|
@ -1,4 +1,4 @@
|
||||
$import(Production Tips Common)
|
||||
//$import(Production Tips Common)
|
||||
|
||||
// ONLOAD
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
@ -14,6 +14,8 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
// Hide - Un Hide Buttons
|
||||
if (!doc.is_default && doc.__islocal!=1) unhide_field('Set as Default BOM');
|
||||
else hide_field('Set as Default BOM');
|
||||
if (doc.is_default && doc.__islocal!=1) unhide_field('Unset as Default BOM');
|
||||
else hide_field('Unset as Default BOM');
|
||||
|
||||
if(doc.__islocal!=1){
|
||||
set_field_permlevel('item',1);
|
||||
@ -76,12 +78,23 @@ cur_frm.cscript['Set as Default BOM'] = function(doc,cdt,cdn) {
|
||||
if (check) {
|
||||
$c('runserverobj', args={'method':'set_as_default_bom', 'docs': compress_doclist([doc])}, function(r,rt) {
|
||||
refresh_field('is_default');
|
||||
hide_field('Set as Default BOM');
|
||||
hide_field('Set as Default BOM');unhide_field('Unset as Default BOM');
|
||||
refresh_field('Set as Default BOM');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Unset as Default BOM'] = function(doc,cdt,cdn) {
|
||||
var check = confirm("Do you Really want to Unset BOM " + doc.name + " as default for Item " + doc.item);
|
||||
if (check) {
|
||||
$c('runserverobj', args={'method':'unset_as_default_bom', 'docs': compress_doclist([doc])}, function(r,rt) {
|
||||
refresh_field('is_default');
|
||||
hide_field('Unset as Default BOM');unhide_field('Set as Default BOM');
|
||||
refresh_field('Unset as Default BOM');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Activate BOM'] = function(doc,cdt,cdn) {
|
||||
var check = confirm("DO YOU REALLY WANT TO ACTIVATE BOM : " + doc.name);
|
||||
|
||||
@ -92,6 +105,13 @@ cur_frm.cscript['Activate BOM'] = function(doc,cdt,cdn) {
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Test Flat BOM'] = function(doc,cdt,cdn) {
|
||||
|
||||
$c('runserverobj', args={'method':'get_current_flat_bom_items', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript['Inactivate BOM'] = function(doc,cdt,cdn) {
|
||||
var check = confirm("DO YOU REALLY WANT TO INACTIVATE BOM : " + doc.name);
|
||||
|
||||
|
@ -124,6 +124,14 @@ class DocType:
|
||||
sql("update `tabItem` set default_bom = '%s' where name = '%s'" % (self.doc.name,self.doc.item))
|
||||
msgprint(cstr(self.doc.name) + "has been set as Default BOM for Item "+cstr(self.doc.item))
|
||||
|
||||
def unset_as_default_bom(self):
|
||||
# set Is Default as 1
|
||||
set(self.doc,'is_default', flt(0))
|
||||
|
||||
# update current BOM as default bom in Item Master
|
||||
sql("update `tabItem` set default_bom = null where name = '%s'" % (self.doc.item))
|
||||
msgprint(cstr(self.doc.name) + "has been unset as Default BOM for Item "+cstr(self.doc.item))
|
||||
|
||||
def check_active_parent_boms(self):
|
||||
act_pbom = sql("select distinct t1.parent from `tabBOM Material` t1, `tabBill Of Materials` t2 where t1.bom_no ='%s' and t2.name = t1.parent and t2.is_active = 'Yes' and t2.docstatus = 1 and t1.docstatus =1 " % self.doc.name )
|
||||
if act_pbom and act_pbom[0][0]:
|
||||
@ -248,6 +256,7 @@ class DocType:
|
||||
o.operating_cost = flt(flt(o.time_in_mins)/60) * flt(o.hour_rate)
|
||||
if validate != 1:
|
||||
o.save()
|
||||
msgprint('Operation saved')
|
||||
|
||||
op_cost = flt(op_cost) + flt(o.operating_cost)
|
||||
|
||||
@ -443,6 +452,7 @@ class DocType:
|
||||
|
||||
#----- Document on Save function------
|
||||
def validate(self):
|
||||
#msgprint(len(getlist(self.doclist, 'bom_materials')))
|
||||
self.validate_main_item()
|
||||
self.validate_duplicate_items()
|
||||
self.calculate_cost(validate = 1)
|
||||
@ -487,8 +497,10 @@ class DocType:
|
||||
#Get Child Flat BOM Items
|
||||
#----------------------------------------
|
||||
def get_child_flat_bom_items(self, item, d):
|
||||
|
||||
child_flat_bom_items=[]
|
||||
if item and (item[0]['is_sub_contracted_item'] == 'Yes' or item[0]['is_pro_applicable'] == 'Yes'):
|
||||
|
||||
child_flat_bom_items = sql("select item_code, description, qty_consumed_per_unit, stock_uom, moving_avg_rate, last_purchase_rate, standard_rate, '%s' as parent_bom, bom_mat_no, 'No' as is_pro_applicable from `tabFlat BOM Detail` where parent = '%s' and is_pro_applicable = 'No' and docstatus = 1" % ( d.bom_no, cstr(d.bom_no)))
|
||||
self.cur_flat_bom_items.append([d.item_code, d.description, flt(d.qty), d.stock_uom, flt(d.moving_avg_rate), flt(d.amount_as_per_mar), flt(d.last_purchase_rate), flt(d.amount_as_per_lpr), flt(d.standard_rate), flt(d.amount_as_per_sr), flt(d.qty_consumed_per_unit), (item[0]['is_sub_contracted_item'] == 'Yes') and d.parent or d.bom_no, d.name, (item[0]['is_sub_contracted_item'] == 'Yes') and 'No' or 'Yes'])
|
||||
|
||||
@ -505,11 +517,13 @@ class DocType:
|
||||
# Get Current Flat BOM Items
|
||||
# -----------------------------
|
||||
def get_current_flat_bom_items(self):
|
||||
|
||||
self.cur_flat_bom_items = []
|
||||
|
||||
cfb_lbl = {'item_code': 0, 'description': 1, 'qty_consumed_per_unit': 2, 'stock_uom': 3, 'moving_avg_rate': 4, 'last_purchase_rate': 5, 'standard_rate': 6, 'parent_bom': 7, 'bom_mat_no': 8, 'is_pro_applicable': 9}
|
||||
|
||||
for d in getlist(self.doclist, 'bom_materials'):
|
||||
|
||||
if d.bom_no:
|
||||
item = sql("select is_sub_contracted_item, is_pro_applicable from `tabItem` where name = '%s'" % d.item_code, as_dict = 1)
|
||||
child_flat_bom_items = self.get_child_flat_bom_items(item,d)
|
||||
@ -533,7 +547,7 @@ class DocType:
|
||||
# On Submit
|
||||
# -----------
|
||||
def on_submit(self):
|
||||
self.update_flat_bom_engine()
|
||||
self.update_flat_bom_engine(1)
|
||||
|
||||
|
||||
def get_parent_bom_list(self, bom_no):
|
||||
|
@ -34,7 +34,7 @@
|
||||
'section_style': 'Tabbed',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': '%(item_code)s',
|
||||
'subject': '%(item)s',
|
||||
'version': 170
|
||||
},
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.utils import cint, flt
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
@ -44,18 +44,20 @@ class DocType:
|
||||
def get_operations(self,bom_no):
|
||||
# reply = [ 'Operation',operation_no, opn_description,BOM NO , workstation, hour_rate, time_in_minutes, Total Direct Material, Total Operating Cost, Cost]
|
||||
# reply = [ 0 , 1 , 2 ,3 , 4 , 5 , 6 , 7 , 8 ,9 , 10 , 11 ]
|
||||
|
||||
ret = sql("select operation_no,opn_description,workstation,hour_rate,time_in_mins from `tabBOM Operation` where parent = %s", bom_no, as_dict = 1)
|
||||
cost = sql("select dir_mat_as_per_mar , operating_cost , cost_as_per_mar from `tabBill Of Materials` where name = %s", bom_no, as_dict = 1)
|
||||
|
||||
# Validate the BOM ENTRIES
|
||||
#check = get_obj('Bill Of Materials', bom_no, with_children =1).validate()
|
||||
reply = []
|
||||
|
||||
if ret:
|
||||
for r in ret:
|
||||
reply.append(['operation',cint(r['operation_no']), r['opn_description'] or '','%s'% bom_no,r['workstation'],flt(r['hour_rate']),flt(r['time_in_mins']),0,0,0])
|
||||
|
||||
reply[0][7]= flt(cost[0]['dir_mat_as_per_mar'])
|
||||
reply[0][8]=flt(cost[0]['operating_cost'])
|
||||
reply[0][9]=flt(cost[0]['cost_as_per_mar'])
|
||||
#msgprint(bom_no)
|
||||
return reply
|
||||
|
||||
def get_item_bom(self,data):
|
||||
@ -78,7 +80,6 @@ class DocType:
|
||||
return reply
|
||||
|
||||
|
||||
|
||||
#------------- Wrapper Code --------------
|
||||
# BOM TREE
|
||||
def calculate_cost( self, bom_no):
|
||||
|
@ -34,7 +34,7 @@ class DocType:
|
||||
'stock_uom' : item and item[0]['stock_uom'] or '',
|
||||
'default_bom' : item and item[0]['default_bom'] or ''
|
||||
}
|
||||
return cstr(ret)
|
||||
return ret
|
||||
|
||||
def validate(self):
|
||||
if not self.doc.production_item :
|
||||
|
@ -52,7 +52,7 @@ class DocType:
|
||||
'contact_no' : contact and contact[0]['contact_no'] or '',
|
||||
'email_id' : contact and contact[0]['email_id'] or ''
|
||||
}
|
||||
return str(ret)
|
||||
return ret
|
||||
else:
|
||||
msgprint("Contact Person : %s does not exist in the system." % (self.doc,contact_person))
|
||||
raise Exception
|
||||
|
@ -169,7 +169,7 @@ Total Available Qty: %s
|
||||
'description' : file and file[0]['description'] or ''
|
||||
|
||||
}
|
||||
return str(ret)
|
||||
return ret
|
||||
|
||||
def check_if_sle_exists(self):
|
||||
"""
|
||||
|
@ -55,10 +55,12 @@ class DocType:
|
||||
serial_nos = self.get_sr_no_list(d.serial_no)
|
||||
for s in serial_nos:
|
||||
s = s.strip()
|
||||
sr_war = sql("select warehouse from `tabSerial No` where name = '%s'" % (s))
|
||||
sr_war = sql("select warehouse,name from `tabSerial No` where name = '%s'" % (s))
|
||||
if not sr_war:
|
||||
msgprint("Serial No %s does not exists",s, raise_exception = 1)
|
||||
elif not sr_war[0][0]:
|
||||
msgprint("Please set a warehouse in the Serial No <b>%s</b>" % s, raise_exception = 1)
|
||||
if sr_war[0][0] != d.warehouse:
|
||||
elif sr_war[0][0] != d.warehouse:
|
||||
msgprint("Serial No : %s for Item : %s doesn't exists in Warehouse : %s" % (s, d.item_code, d.warehouse), raise_exception = 1)
|
||||
|
||||
|
||||
|
@ -69,7 +69,7 @@ class DocType:
|
||||
'name' : f_obj.doc.name,
|
||||
'label' : f_obj.doc.file_name
|
||||
}
|
||||
return cstr(ret)
|
||||
return ret
|
||||
|
||||
# Update changes done to selected file group.
|
||||
def update_grp(self,arg):
|
||||
@ -160,7 +160,7 @@ class DocType:
|
||||
'file_name' : f.file_name
|
||||
}
|
||||
|
||||
return cstr(ret)
|
||||
return ret
|
||||
else:
|
||||
return 'No file found.'
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user