本文整理汇总了Python中webnotes.utils.get_defaults函数的典型用法代码示例。如果您正苦于以下问题:Python get_defaults函数的具体用法?Python get_defaults怎么用?Python get_defaults使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_defaults函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_auto_indent
def create_auto_indent(self, i , doc_type, doc_name, cur_qty):
""" Create indent on reaching reorder level """
indent = Document('Purchase Request')
indent.transaction_date = nowdate()
indent.naming_series = 'IDT'
indent.company = get_defaults()['company']
indent.fiscal_year = get_defaults()['fiscal_year']
indent.remark = "This is an auto generated Purchase Request. It was raised because the (actual + ordered + indented - reserved) quantity reaches re-order level when %s %s was created"%(doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Purchase Request Item',0)
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse
indent_details_child.schedule_date= add_days(nowdate(),cint(i['lead_time_days']))
indent_details_child.item_name = i['item_name']
indent_details_child.description = i['description']
indent_details_child.item_group = i['item_group']
indent_details_child.qty = i['re_order_qty'] or (flt(i['re_order_level']) - flt(cur_qty))
indent_details_child.brand = i['brand']
indent_details_child.save()
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_obj.validate()
set(indent_obj.doc,'docstatus',1)
indent_obj.on_submit()
msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Purchase Request %s raised. It was generated from %s %s"%(indent.name,doc_type, doc_name ))
if(i['email_notify']):
send_email_notification(doc_type,doc_name)
示例2: reorder_indent
def reorder_indent(self,i,item_reorder_level,doc_type,doc_name,email_notify=1):
indent = Document('Indent')
indent.transaction_date = nowdate()
indent.naming_series = 'IDT'
indent.company = get_defaults()['company']
indent.fiscal_year = get_defaults()['fiscal_year']
indent.remark = "This is an auto generated Indent. It was raised because the projected quantity has fallen below the minimum re-order level when %s %s was created"%(doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Indent',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Indent Detail',0)
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse
indent_details_child.schedule_date= add_days(nowdate(),cint(i['lead_time_days']))
indent_details_child.item_name = i['item_name']
indent_details_child.description = i['description']
indent_details_child.item_group = i['item_group']
if (i['min_order_qty'] < ( flt(item_reorder_level)-flt(self.doc.projected_qty) )):
indent_details_child.qty =flt(flt(item_reorder_level)-flt(self.doc.projected_qty))
else:
indent_details_child.qty = i['min_order_qty']
indent_details_child.brand = i['brand']
indent_details_child.save()
indent_obj = get_obj('Indent',indent.name,with_children=1)
indent_obj.validate()
set(indent_obj.doc,'docstatus',1)
indent_obj.on_submit()
msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Indent %s raised.Was generated from %s %s"%(indent.name,doc_type, doc_name ))
if(email_notify):
send_email_notification(doc_type,doc_name)
示例3: lease_installment_post
def lease_installment_post(self, args):
"""
Posts the Installment receipt into Journal Voucher
"""
next_inst = sql(
"select amount,name from `tabLease Installment` where parent=%s and ifnull(cheque_number,'')='' order by due_date limit 1",
self.doc.name,
)
data = json.loads(args)
data["voucher_type"] = "Lease Receipt"
data["naming_series"] = "JV"
data["amount"] = next_inst[0][0]
data["debit_account"] = data.get("bank_account")
data["credit_account"] = self.doc.account
data["fiscal_year"] = get_defaults()["fiscal_year"]
data["company"] = get_defaults()["company"]
jv_name = post_jv(data)
sql(
"update `tabLease Installment` set cheque_number=%s, cheque_date=%s, jv_number=%s where name=%s",
(data.get("cheque_number"), data.get("cheque_date"), jv_name, next_inst[0][1]),
)
self.doclist = [Document(d.doctype, d.name) for d in self.doclist]
示例4: validate
def validate(self):
self.validate_fiscal_year()
# Step 1:=> set status as "Draft"
set(self.doc, 'status', 'Draft')
# Step 2:=> get Purchase Common Obj
pc_obj = get_obj(dt='Purchase Common')
# Step 3:=> validate mandatory
pc_obj.validate_mandatory(self)
# Step 4:=> validate for items
pc_obj.validate_for_items(self)
# Step 5:=> validate conversion rate
pc_obj.validate_conversion_rate(self)
# Get po date
pc_obj.get_prevdoc_date(self)
# validate_doc
self.validate_doc(pc_obj)
# Check for stopped status
self.check_for_stopped_status(pc_obj)
# get total in words
self.doc.in_words = pc_obj.get_total_in_words(get_defaults().get('currency') and get_defaults()['currency'] or 'INR', self.doc.grand_total)
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
示例5: loan_post
def loan_post(self):
data['voucher_type']='Loan Issue'
data['naming_series']='JV'
data['fiscal_year'] = get_defaults()['fiscal_year'] # To be modified to take care
data['company'] = get_defaults()['company']
data['debit_account'] = self.doc['receivable_account']
data['credit_account'] = self.doc['account']
data['amount'] = self.doc.loan_amount
jv_name=post_jv(data)
示例6: set_print_format_fields
def set_print_format_fields(self):
for d in getlist(self.doclist, 'entries'):
chk_type = sql("select master_type, account_type from `tabAccount` where name='%s'" % d.account)
master_type, acc_type = chk_type and cstr(chk_type[0][0]) or '', chk_type and cstr(chk_type[0][1]) or ''
if master_type in ['Supplier', 'Customer']:
if not self.doc.pay_to_recd_from:
self.doc.pay_to_recd_from = get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name')
if acc_type == 'Bank or Cash':
amt = cint(d.debit) and d.debit or d.credit
self.doc.total_amount = get_defaults()['currency']+'. '+ cstr(amt)
self.doc.total_amount_in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], cstr(amt))
示例7: yr_wk_dates
def yr_wk_dates(self,fy):
from datetime import date
yr_st = get_defaults()['year_start_date']
yr_en = get_defaults()['year_end_date']
fy = fy.split('-')
y1 = yr_st.split('-')
date1 = date(cint(fy[0]),cint(y1[1]),cint(y1[2]))
y2 = yr_en.split('-')
date2 = date(cint(fy[1]),cint(y2[1]),cint(y2[2]))
date_lst = [[1,self.get_months(cint(y1[1]))]]
m1=cint(y1[1])+1
x_axis_lst = [[1,'Week1',cint(y1[1])]]
from datetime import date, timedelta
d =dt= date1
week=k=1
for i in range(0,53):
if dt <= date2:
if(d.weekday()>3):
d = d+timedelta(7-d.weekday())
else:
d = d - timedelta(d.weekday())
dlt = timedelta(days = (week-1)*7)
dt = d + dlt + timedelta(days=6)
m2 = cint(sql("Select month('%s')"%dt)[0][0])
if(m1 == m2):
date_lst.append([i+2,self.get_months(m2)])
x_axis_lst.append([i+2,'Week1',m2])
k=1
m1 += 1
if(m1==13): m1 =1
else:
date_lst.append([i+2,' '])
x_axis_lst.append([i+2,'Week%d'%k,m2])
week += 1
k +=1
return [date_lst,x_axis_lst]
示例8: get_att_data
def get_att_data(self):
fy = get_defaults()['fiscal_year'] #get default fiscal year
comp = get_defaults()['company'] #get default company
#get naming series of attendance
import webnotes.model.doctype
docfield = webnotes.model.doctype.get('Attendance')
series = [d.options for d in docfield if d.doctype == 'DocField' and d.fieldname == 'naming_series']
if not series:
msgprint("Please create naming series for Attendance.\nGo to Setup--> Numbering Series.")
raise Exception
else:
sr = series[0] or ''
return {'fy':fy,'comp':comp,'sr':sr}
示例9: get_appr_user_role
def get_appr_user_role(self, det, doctype_name, total, based_on, condition, item, company):
amt_list, appr_users, appr_roles = [], [], []
users, roles = '',''
if det:
for x in det:
amt_list.append(flt(x[0]))
max_amount = max(amt_list)
app_dtl = sql("select approving_user, approving_role from `tabAuthorization Rule` where transaction = '%s' and (value = '%s' or value > '%s') and docstatus != 2 and based_on = '%s' and company = '%s' %s" % (doctype_name, flt(max_amount), total, based_on, company, condition))
if not app_dtl:
app_dtl = sql("select approving_user, approving_role from `tabAuthorization Rule` where transaction = '%s' and (value = '%s' or value > '%s') and docstatus != 2 and based_on = '%s' and ifnull(company,'') = '' %s" % (doctype_name, flt(max_amount), total, based_on, condition))
for d in app_dtl:
if(d[0]): appr_users.append(d[0])
if(d[1]): appr_roles.append(d[1])
if not has_common(appr_roles, webnotes.user.get_roles()) and not has_common(appr_users, session['user']):
msg, add_msg = '',''
if max_amount:
if based_on == 'Grand Total': msg = "since Grand Total exceeds %s. %s" % (get_defaults()['currency'], flt(max_amount))
elif based_on == 'Itemwise Discount': msg = "since Discount exceeds %s for Item Code : %s" % (cstr(max_amount)+'%', item)
elif based_on == 'Average Discount' or based_on == 'Customerwise Discount': msg = "since Discount exceeds %s" % (cstr(max_amount)+'%')
if appr_users: add_msg = "Users : "+cstr(appr_users)
if appr_roles: add_msg = "Roles : "+cstr(appr_roles)
if appr_users and appr_roles: add_msg = "Users : "+cstr(appr_users)+" or "+"Roles : "+cstr(appr_roles)
msgprint("You do not have an authority to submit this %s %s. Please send for approval to %s" % (doctype_name, msg, add_msg))
raise Exception
示例10: get_year_weekwise_amount
def get_year_weekwise_amount(self,lst):
lst = lst.split(',')
yr_st = get_defaults()['year_start_date']
fy = lst[0]
m1 = cint(yr_st.split('-')[1])
cases = ' '
for i in range(1,13):
cases += self.get_week_cases(m1,fy)
m1 +=1
if(m1 == 13): m1 = 1
if not lst[1]:
query = "SELECT SUM(grand_total) AMOUNT,CASE WEEK(due_date)"+cases+"END Weekly, month(due_date) month FROM `tabSales Invoice` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY `month`,weekly ORDER BY `month`,weekly"
ret = convert_to_lists(sql(query%lst[0]))
else:
query = "SELECT SUM(t2.amount) AMOUNT,CASE WEEK(t1.due_date)" + cases + "END Weekly, month(due_date) month FROM `tabSales Invoice` t1, `tabSales Invoice Item` t2 WHERE t1.docstatus = 1 AND t1.fiscal_year = '%s' AND t1.name = t2.parent AND t2.item_group ='%s' GROUP BY Weekly ORDER BY Weekly"
ret = convert_to_lists(sql(query%(lst[0],lst[1])))
return ret and ret or ''
示例11: on_rename
def on_rename(self, newdn, olddn):
# update customer_name if not naming series
if get_defaults().get("cust_master_name") == "Customer Name":
update_fields = [
("Customer", "name"),
("Address", "customer"),
("Contact", "customer"),
("Customer Issue", "customer"),
("Delivery Note", "customer"),
("Opportunity", "customer"),
("Installation Note", "customer"),
("Maintenance Schedule", "customer"),
("Maintenance Visit", "customer"),
("Project", "customer"),
("Quotation", "customer"),
("Sales Invoice", "customer"),
("Sales Order", "customer"),
("Serial No", "customer"),
("Shipping Address", "customer"),
("Stock Entry", "customer"),
("Support Ticket", "customer"),
("Task", "customer"),
]
for rec in update_fields:
sql("update `tab%s` set customer_name = '%s' where %s = '%s'" % (rec[0], newdn, rec[1], olddn))
# update master_name in doctype account
sql(
"update `tabAccount` set master_name = '%s', master_type = 'Customer' where master_name = '%s'"
% (newdn, olddn)
)
示例12: create_production_order
def create_production_order(self, items):
"""Create production order. Called from Production Planning Tool"""
default_values = {
'posting_date' : nowdate(),
'origin' : 'MRP',
'wip_warehouse' : '',
'fg_warehouse' : '',
'status' : 'Draft',
'fiscal_year' : get_defaults()['fiscal_year']
}
pro_list = []
for item_so in items:
if item_so[1]:
self.validate_production_order_against_so(
item_so[0], item_so[1], items[item_so].get("qty"))
pro_doc = Document('Production Order')
pro_doc.production_item = item_so[0]
pro_doc.sales_order = item_so[1]
for key in items[item_so]:
pro_doc.fields[key] = items[item_so][key]
for key in default_values:
pro_doc.fields[key] = default_values[key]
pro_doc.save(new = 1)
pro_list.append(pro_doc.name)
return pro_list
示例13: on_rename
def on_rename(self, new, old):
#update customer_name if not naming series
if get_defaults().get('cust_master_name') == 'Customer Name':
update_fields = [
('Customer', 'name'),
('Address', 'customer'),
('Contact', 'customer'),
('Customer Issue', 'customer'),
('Delivery Note', 'customer'),
('Opportunity', 'customer'),
('Installation Note', 'customer'),
('Maintenance Schedule', 'customer'),
('Maintenance Visit', 'customer'),
('Project', 'customer'),
('Quotation', 'customer'),
('Sales Invoice', 'customer'),
('Sales Order', 'customer'),
('Serial No', 'customer'),
('Shipping Address', 'customer'),
('Stock Entry', 'customer'),
('Support Ticket', 'customer'),
('Task', 'customer')]
for rec in update_fields:
sql("""update `tab%s` set customer_name = %s
where `%s` = %s""" % (rec[0], "%s" ,rec[1], "%s"), (new, old))
for account in webnotes.conn.sql("""select name, account_name from
tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1):
if account.account_name != new:
webnotes.rename_doc("Account", account.name, new)
#update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
master_type = 'Customer' where master_name = %s""", (new,old))
示例14: __init__
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.defaults = get_defaults()
self.tname = 'Purchase Receipt Detail'
self.fname = 'purchase_receipt_details'
self.count = 0
示例15: create_production_order
def create_production_order(self,company, pp_items):
"""Create production order. Called from Production Planning Tool"""
default_values = {
'posting_date' : nowdate(),
'origin' : 'MRP',
'wip_warehouse' : '',
'fg_warehouse' : '',
'status' : 'Draft',
'company' : company,
'fiscal_year' : get_defaults()['fiscal_year']
}
pro_list = []
for d in pp_items:
pro_doc = Document('Production Order')
for key in d.keys():
pro_doc.fields[key] = d[key]
for key in default_values:
pro_doc.fields[key] = default_values[key]
pro_doc.save(new = 1)
pro_list.append(pro_doc.name)
return pro_list