本文整理汇总了Python中webnotes.utils.get_defaults函数的典型用法代码示例。如果您正苦于以下问题:Python get_defaults函数的具体用法?Python get_defaults怎么用?Python get_defaults使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_defaults函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:NorrWing,项目名称:erpnext,代码行数:29,代码来源:bin.py
示例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)
开发者ID:calvinfroedge,项目名称:erpnext,代码行数:30,代码来源:bin.py
示例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]
开发者ID:Vichagserp,项目名称:cimworks,代码行数:25,代码来源:lease_agreement.py
示例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)
开发者ID:ravidey,项目名称:erpnext,代码行数:30,代码来源:purchase_order.py
示例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)
开发者ID:Morphnus-IT-Solutions,项目名称:cimworks,代码行数:9,代码来源:loan.py
示例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))
开发者ID:ravidey,项目名称:erpnext,代码行数:12,代码来源:journal_voucher.py
示例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]
开发者ID:NorrWing,项目名称:erpnext,代码行数:50,代码来源:plot_control.py
示例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}
开发者ID:hbkfabio,项目名称:erpnext,代码行数:15,代码来源:attendance_control_panel.py
示例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
开发者ID:ravidey,项目名称:erpnext,代码行数:27,代码来源:authorization_control.py
示例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 ''
开发者ID:NorrWing,项目名称:erpnext,代码行数:25,代码来源:plot_control.py
示例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)
)
开发者ID:nijil,项目名称:erpnext,代码行数:31,代码来源:customer.py
示例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
开发者ID:AminfiBerlin,项目名称:erpnext,代码行数:31,代码来源:production_control.py
示例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))
开发者ID:MiteshC,项目名称:erpnext,代码行数:34,代码来源:customer.py
示例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
开发者ID:calvinfroedge,项目名称:erpnext,代码行数:7,代码来源:purchase_receipt.py
示例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
开发者ID:calvinfroedge,项目名称:erpnext,代码行数:26,代码来源:production_control.py
示例16: update_cp
def update_cp(self):
def_list = [['fiscal_year',self.doc.current_fiscal_year],
['company',self.doc.default_company],
['currency',self.doc.default_currency],
['price_list_name',self.doc.default_price_list or ''],
['price_list_currency', self.doc.default_price_list_currency or ''],
['item_group',self.doc.default_item_group or ''],
['customer_group',self.doc.default_customer_group or ''],
['cust_master_name',self.doc.cust_master_name or ''],
['supplier_type',self.doc.default_supplier_type or ''],
['supp_master_name',self.doc.supp_master_name],
['territory',self.doc.default_territory or ''],
['stock_uom',self.doc.default_stock_uom or ''],
['fraction_currency',self.doc.default_currency_fraction or ''],
['valuation_method',self.doc.default_valuation_method]]
for d in def_list:
self.set_system_default(d[0],d[1])
# Update Currency Format
sql("update `tabSingles` set value = '%s' where field = 'currency_format' and doctype = 'Control Panel'" % self.doc.default_currency_format)
sql("update `tabSingles` set value = '%s' where field = 'date_format' and doctype = 'Control Panel'" %self.doc.date_format)
return get_defaults()
开发者ID:calvinfroedge,项目名称:erpnext,代码行数:25,代码来源:manage_account.py
示例17: validate
def validate(self):
self.validate_fiscal_year()
self.validate_order_type()
self.validate_mandatory()
self.validate_proj_cust()
self.validate_po_date()
#self.validate_reference_value()
self.validate_for_items()
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self)
# verify whether rate is not greater than max_discount
sales_com_obj.validate_max_discount(self,'sales_order_details')
# this is to verify that the allocated % of sales persons is 100%
sales_com_obj.get_allocated_sum(self)
sales_com_obj.make_packing_list(self,'sales_order_details')
# get total in words
self.doc.in_words = sales_com_obj.get_total_in_words(get_defaults()['currency'], 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 SO status
self.doc.status='Draft'
if not self.doc.billing_status: self.doc.billing_status = 'Not Billed'
if not self.doc.delivery_status: self.doc.delivery_status = 'Not Delivered'
开发者ID:ravidey,项目名称:erpnext,代码行数:26,代码来源:sales_order.py
示例18: get_children
def get_children():
args = webnotes.form_dict
ctype, company = args['ctype'], args['comp']
company_field = ctype=='Account' and 'company' or 'company_name'
# root
if args['parent'] == company:
acc = webnotes.conn.sql(""" select
name as value, if(group_or_ledger='Group', 1, 0) as expandable
from `tab%s`
where ifnull(parent_%s,'') = ''
and %s = %s and docstatus<2
order by name""" % (ctype, ctype.lower().replace(' ','_'), company_field, '%s'),
args['parent'], as_dict=1)
else:
# other
acc = webnotes.conn.sql("""select
name as value, if(group_or_ledger='Group', 1, 0) as expandable
from `tab%s`
where ifnull(parent_%s,'') = %s
and docstatus<2
order by name""" % (ctype, ctype.lower().replace(' ','_'), '%s'),
args['parent'], as_dict=1)
if ctype == 'Account':
currency = webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", company)[0][0]
for each in acc:
bal = webnotes.conn.sql("select balance from `tabAccount Balance` \
where account = %s and period = %s", (each.get('value'), get_defaults('fiscal_year')))[0][0]
each['balance'] = currency + ' ' + cstr(bal)
return acc
开发者ID:NorrWing,项目名称:erpnext,代码行数:33,代码来源:accounts_browser.py
示例19: 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
#sr = sql("select series_options from `tabNaming Series Options` where doc_type='Attendance'")
sr = sql("select options from `tabDocField` where parent = 'Attendance' and fieldname = 'naming_series'")
if not sr:
msgprint("Please create naming series for Attendance.\nGo to Setup--> Manage Series.")
raise Exception
else:
sr = sr and sr[0][0]
return {'fy':fy,'comp':comp,'sr':sr}
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:16,代码来源:attendance_control_panel.py
示例20: get_month_diff
def get_month_diff(self):
#end_month = get_defaults()['end_month']
month_dict = {"January" :'01', "February" :'02',"March" :'03',"April":'04',"May":'05',"June":'06',"July":'07',"August":'08',"September":'09',"October":'10',"November":'11',"December":'12'}
import datetime
start_month = getdate(get_defaults()['year_start_date']).month
end_month = cint(start_month) - 1
if end_month <= 0:
end_month = 12
str_end_month = cstr(end_month)
if len(str_end_month)==1:
str_end_month = '0'+str_end_month
to_month = datetime.date.today().strftime("%B")
to_year = datetime.date.today().strftime("%Y")
fiscal_year = self.doc.fiscal_year
str_fy =fiscal_year.split("-")
endym=int(str_fy[1]+str_end_month)
startym= int(to_year+month_dict[to_month])
month_diff =sql("SELECT PERIOD_DIFF(%d,%d);" %(endym,startym))[0][0]+1
return month_diff
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:30,代码来源:it_checklist.py
注:本文中的webnotes.utils.get_defaults函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论