当前位置: 首页>>代码示例>>Python>>正文


Python utils.cstr函数代码示例

本文整理汇总了Python中webnotes.utils.cstr函数的典型用法代码示例。如果您正苦于以下问题:Python cstr函数的具体用法?Python cstr怎么用?Python cstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_cancel

    def on_cancel(self):
        pc_obj = get_obj(dt="Purchase Common")

        # 1.Check if PO status is stopped
        pc_obj.check_for_stopped_status(cstr(self.doc.doctype), cstr(self.doc.name))

        self.check_for_stopped_status(pc_obj)

        # 2.Check if Purchase Receipt has been submitted against current Purchase Order
        pc_obj.check_docstatus(
            check="Next", doctype="Purchase Receipt", docname=self.doc.name, detail_doctype="Purchase Receipt Item"
        )

        # 3.Check if Purchase Invoice has been submitted against current Purchase Order
        # pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Invoice', docname = self.doc.name, detail_doctype = 'Purchase Invoice Item')

        submitted = sql(
            "select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_order = '%s' and t1.docstatus = 1"
            % self.doc.name
        )
        if submitted:
            msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
            raise Exception

            # 4.Set Status as Cancelled
        webnotes.conn.set(self.doc, "status", "Cancelled")

        # 5.Update Material Requests Pending Qty and accordingly it's Status
        pc_obj.update_prevdoc_detail(self, is_submit=0)

        # 6.Update Bin
        self.update_bin(is_submit=0, is_stopped=0)

        # Step 7 :=> Update last purchase rate
        pc_obj.update_last_purchase_rate(self, is_submit=0)
开发者ID:jnarvaezp,项目名称:erpnext,代码行数:35,代码来源:purchase_order.py

示例2: make_new_invoice

def make_new_invoice(ref_wrapper, posting_date):
	from webnotes.model.bean import clone
	from accounts.utils import get_fiscal_year
	new_invoice = clone(ref_wrapper)
	
	mcount = month_map[ref_wrapper.doc.recurring_type]
	
	invoice_period_from_date = get_next_date(ref_wrapper.doc.invoice_period_from_date, mcount)
	
	# get last day of the month to maintain period if the from date is first day of its own month 
	# and to date is the last day of its own month
	if (cstr(get_first_day(ref_wrapper.doc.invoice_period_from_date)) == \
			cstr(ref_wrapper.doc.invoice_period_from_date)) and \
		(cstr(get_last_day(ref_wrapper.doc.invoice_period_to_date)) == \
			cstr(ref_wrapper.doc.invoice_period_to_date)):
		invoice_period_to_date = get_last_day(get_next_date(ref_wrapper.doc.invoice_period_to_date,
			mcount))
	else:
		invoice_period_to_date = get_next_date(ref_wrapper.doc.invoice_period_to_date, mcount)
	
	new_invoice.doc.fields.update({
		"posting_date": posting_date,
		"aging_date": posting_date,
		"due_date": add_days(posting_date, cint(date_diff(ref_wrapper.doc.due_date,
			ref_wrapper.doc.posting_date))),
		"invoice_period_from_date": invoice_period_from_date,
		"invoice_period_to_date": invoice_period_to_date,
		"fiscal_year": get_fiscal_year(posting_date)[0],
		"owner": ref_wrapper.doc.owner,
	})
	
	new_invoice.submit()
	
	return new_invoice
开发者ID:rajatkapoor,项目名称:erpnext,代码行数:34,代码来源:sales_invoice.py

示例3: sle_for_moving_avg

	def sle_for_moving_avg(self, row, previous_sle, change_in_qty, change_in_rate):
		"""Insert Stock Ledger Entries for Moving Average valuation"""
		def _get_incoming_rate(qty, valuation_rate, previous_qty, previous_valuation_rate):
			if previous_valuation_rate == 0:
				return flt(valuation_rate)
			else:
				if valuation_rate == "":
					valuation_rate = previous_valuation_rate
				return (qty * valuation_rate - previous_qty * previous_valuation_rate) \
					/ flt(qty - previous_qty)
		
		if change_in_qty:
			# if change in qty, irrespective of change in rate
			incoming_rate = _get_incoming_rate(flt(row.qty), flt(row.valuation_rate),
				flt(previous_sle.get("qty_after_transaction")),
				flt(previous_sle.get("valuation_rate")))
				
			row["voucher_detail_no"] = "Row: " + cstr(row.row_num) + "/Actual Entry"
			self.insert_entries({"actual_qty": change_in_qty, "incoming_rate": incoming_rate}, row)
			
		elif change_in_rate and flt(previous_sle.get("qty_after_transaction")) > 0:
			# if no change in qty, but change in rate 
			# and positive actual stock before this reconciliation
			incoming_rate = _get_incoming_rate(
				flt(previous_sle.get("qty_after_transaction"))+1, flt(row.valuation_rate),
				flt(previous_sle.get("qty_after_transaction")), 
				flt(previous_sle.get("valuation_rate")))
				
			# +1 entry
			row["voucher_detail_no"] = "Row: " + cstr(row.row_num) + "/Valuation Adjustment +1"
			self.insert_entries({"actual_qty": 1, "incoming_rate": incoming_rate}, row)
			
			# -1 entry
			row["voucher_detail_no"] = "Row: " + cstr(row.row_num) + "/Valuation Adjustment -1"
			self.insert_entries({"actual_qty": -1}, row)
开发者ID:PhamThoTam,项目名称:erpnext,代码行数:35,代码来源:stock_reconciliation.py

示例4: unset_as_default_bom

  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))
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:7,代码来源:bill_of_materials.py

示例5: update_stock

	def update_stock(self):
		sl_entries = []
		stock_items = self.get_stock_items()
		
		for d in getlist(self.doclist, 'purchase_receipt_details'):
			if d.item_code in stock_items and d.warehouse:
				pr_qty = flt(d.qty) * flt(d.conversion_factor)
				
				if pr_qty:
					sl_entries.append(self.get_sl_entries(d, {
						"actual_qty": flt(pr_qty),
						"serial_no": cstr(d.serial_no).strip(),
						"incoming_rate": d.valuation_rate
					}))
				
				if flt(d.rejected_qty) > 0:
					sl_entries.append(self.get_sl_entries(d, {
						"warehouse": d.rejected_warehouse,
						"actual_qty": flt(d.rejected_qty) * flt(d.conversion_factor),
						"serial_no": cstr(d.rejected_serial_no).strip(),
						"incoming_rate": d.valuation_rate
					}))
						
		self.bk_flush_supp_wh(sl_entries)
		self.make_sl_entries(sl_entries)
开发者ID:rohitw1991,项目名称:innoworth-app,代码行数:25,代码来源:purchase_receipt.py

示例6: get_tds

	def get_tds(self):
		if cstr(self.doc.is_opening) != 'Yes':
			if not self.doc.credit_to:
				msgprint("Please Enter Credit To account first")
				raise Exception
			else:
				tds_applicable = sql("select tds_applicable from tabAccount where name = '%s'" % self.doc.credit_to)
				if tds_applicable and cstr(tds_applicable[0][0]) == 'Yes':
					if not self.doc.tds_applicable:
						msgprint("Please enter whether TDS Applicable or not")
						raise Exception
					if self.doc.tds_applicable == 'Yes':
						if not self.doc.tds_category:
							msgprint("Please select TDS Category")
							raise Exception
						else:
							get_obj('TDS Control').get_tds_amount(self)
							self.doc.total_tds_on_voucher = self.doc.ded_amount
							self.doc.total_amount_to_pay=flt(self.doc.grand_total) - flt(self.doc.ded_amount) - self.doc.write_off_amount
							self.doc.outstanding_amount = self.doc.total_amount_to_pay - flt(self.doc.total_advance)
					elif self.doc.tds_applicable == 'No':
						self.doc.tds_category = ''
						self.doc.tax_code = ''
						self.doc.rate = 0
						self.doc.ded_amount = 0
						self.doc.total_tds_on_voucher = 0
开发者ID:trycatcher,项目名称:erpnext,代码行数:26,代码来源:purchase_invoice.py

示例7: create_remarks

	def create_remarks(self):
		r = []
		if self.doc.cheque_no :
			if self.doc.cheque_date:
				r.append('Via Reference #%s dated %s' % (self.doc.cheque_no, formatdate(self.doc.cheque_date)))
			else :
				msgprint("Please enter Reference date")
				raise Exception
		
		for d in getlist(self.doclist, 'entries'):
			if d.against_invoice and d.credit:
				currency = sql("select currency from `tabSales Invoice` where name = '%s'" % d.against_invoice)
				currency = currency and currency[0][0] or ''
				r.append('%s %s against Invoice: %s' % (cstr(currency), fmt_money(flt(d.credit)), d.against_invoice))
			if d.against_voucher and d.debit:
				bill_no = sql("select bill_no, bill_date, currency from `tabPurchase Invoice` where name=%s", d.against_voucher)
				if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() not in ['na', 'not applicable', 'none']:
					bill_no = bill_no and bill_no[0]
					r.append('%s %s against Bill %s dated %s' % (bill_no[2] and cstr(bill_no[2]) or '', fmt_money(flt(d.debit)), bill_no[0], bill_no[1] and formatdate(bill_no[1].strftime('%Y-%m-%d')) or ''))
	
		if self.doc.user_remark:
			r.append("User Remark : %s"%self.doc.user_remark)

		if r:
			self.doc.remark = ("\n").join(r)
开发者ID:arunemmanuel,项目名称:erpnext,代码行数:25,代码来源:journal_voucher.py

示例8: update_packing_list_item

	def update_packing_list_item(self,obj, packing_item_code, qty, warehouse, line):
		bin = self.get_bin_qty(packing_item_code, warehouse)
		item = self.get_packing_item_details(packing_item_code)

		# check if exists
		exists = 0
		for d in getlist(obj.doclist, 'packing_details'):
			if d.parent_item == line.item_code and d.item_code == packing_item_code and d.parent_detail_docname == line.name:
				pi, exists = d, 1
				break

		if not exists:
			pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Item', 1, obj.doclist)

		pi.parent_item = line.item_code
		pi.item_code = packing_item_code
		pi.item_name = item['item_name']
		pi.parent_detail_docname = line.name
		pi.description = item['description']
		pi.uom = item['stock_uom']
		pi.qty = flt(qty)
		pi.actual_qty = bin and flt(bin['actual_qty']) or 0
		pi.projected_qty = bin and flt(bin['projected_qty']) or 0
		pi.warehouse = warehouse
		pi.prevdoc_doctype = line.prevdoc_doctype
		if packing_item_code == line.item_code:
			pi.serial_no = cstr(line.serial_no)
			pi.batch_no = cstr(line.batch_no)
		pi.idx = self.packing_list_idx
		
		# has to be saved, since this function is called on_update of delivery note
		pi.save()
		
		self.packing_list_idx += 1
开发者ID:aarohan,项目名称:erpnext,代码行数:34,代码来源:sales_common.py

示例9: get_outstanding

 def get_outstanding(self, args):
   args = eval(args)
   o_s = sql("select outstanding_amount from `tab%s` where name = '%s'" % (args['doctype'],args['docname']))
   if args['doctype'] == 'Payable Voucher':
     return cstr({'debit': o_s and flt(o_s[0][0]) or 0})
   if args['doctype'] == 'Receivable Voucher':
     return cstr({'credit': o_s and flt(o_s[0][0]) or 0})
开发者ID:tassadaque,项目名称:erpnext,代码行数:7,代码来源:journal_voucher.py

示例10: validate_existing_appraisal

	def validate_existing_appraisal(self):
		chk = sql("select name from `tabAppraisal` where employee=%s and (status='Submitted' or status='Completed') and ((start_date>=%s and start_date<=%s) or (end_date>=%s and end_date<=%s))",(self.doc.employee,self.doc.start_date,self.doc.end_date,self.doc.start_date,self.doc.end_date))
		if chk:
			msgprint("You have already created Appraisal "\
				+cstr(chk[0][0])+" in the current date range for employee "\
				+cstr(self.doc.employee_name))
			raise Exception
开发者ID:AminfiBerlin,项目名称:erpnext,代码行数:7,代码来源:appraisal.py

示例11: get_density_details

	def get_density_details(self,args):
		dic=eval(args)
		sub=cstr(flt(dic['syringe'])-flt(dic['weight']))
		density=cstr(flt(sub)/flt(dic['volume']))
		return{
			"density":density
		}
开发者ID:saurabh6790,项目名称:trufil_app,代码行数:7,代码来源:physical_condition_and_density.py

示例12: post_comment

def post_comment(arg):
	arg = load_json(arg)
	
	from webnotes.model.doc import Document
	d = Document('Comment Widget Record')
	d.comment_doctype = 'My Company'
	d.comment_docname = arg['uid'] # to
	d.owner = webnotes.user.name
	d.comment = arg['comment']
	d.save(1)
	
	if cint(arg['notify']):
		fn = webnotes.conn.sql('select first_name, last_name from tabProfile where name=%s', webnotes.user.name)[0]
		if fn[0] or f[1]:
			fn = cstr(fn[0]) + (fn[0] and ' ' or '') + cstr(fn[1])
		else:
			fn = webnotes.user.name

		from webnotes.utils.email_lib import sendmail
		from setup.doctype.notification_control.notification_control import get_formatted_message
		
		message = '''A new comment has been posted on your page by %s:
		
		<b>Comment:</b> %s
		
		To answer, please login to your erpnext account!
		''' % (fn, arg['comment'])
		
		sendmail([arg['uid']], webnotes.user.name, get_formatted_message('New Comment', message), fn + ' has posted a new comment')
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:29,代码来源:my_company.py

示例13: on_cancel

	def on_cancel(self):
		pc_obj = get_obj(dt = 'Purchase Common')
		
		# 1.Check if PO status is stopped
		pc_obj.check_for_stopped_status(cstr(self.doc.doctype), cstr(self.doc.name))
		
		self.check_for_stopped_status(pc_obj)
		
		# 2.Check if Purchase Receipt has been submitted against current Purchase Order
		pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.doc.name, detail_doctype = 'Purchase Receipt Detail')

		# 3.Check if Payable Voucher has been submitted against current Purchase Order
		#pc_obj.check_docstatus(check = 'Next', doctype = 'Payable Voucher', docname = self.doc.name, detail_doctype = 'PV Detail')
		
		submitted = sql("select t1.name from `tabPayable Voucher` t1,`tabPV Detail` t2 where t1.name = t2.parent and t2.purchase_order = '%s' and t1.docstatus = 1" % self.doc.name)
		if submitted:
			msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
			raise Exception

		# 4.Set Status as Cancelled
		set(self.doc,'status','Cancelled')

		# 5.Update Indents Pending Qty and accordingly it's Status 
		pc_obj.update_prevdoc_detail(self,is_submit = 0)
		
		# 6.Update Bin	
		self.update_bin( is_submit = 0, is_stopped = 0)
		
		# Step 7 :=> Update last purchase rate 
		pc_obj.update_last_purchase_rate(self, is_submit = 0)
开发者ID:antoxin,项目名称:erpnext,代码行数:30,代码来源:purchase_order.py

示例14: validate_receiver_nos

	def validate_receiver_nos(self,receiver_list):
		validated_receiver_list = []
		for d in receiver_list:
			# remove invalid character
			invalid_char_list = [' ', '+', '-', '(', ')']
			for x in invalid_char_list:
				d = d.replace(x, '')

			# mobile no validation for erpnext gateway
			if get_value('SMS Settings', None, 'sms_gateway_url'):
				mob_no = d
			else:
				if not d.startswith("0") and len(d) == 10:
					mob_no = "91" + d
				elif d.startswith("0") and len(d) == 11:
					mob_no = "91" + d[1:]
				elif len(d) == 12:
					mob_no = d
				else:
					msgprint("Invalid mobile no : " + cstr(d))
					raise Exception

				if not mob_no.isdigit():
					msgprint("Invalid mobile no : " + cstr(mob_no))
					raise Exception

			validated_receiver_list.append(mob_no)

		if not validated_receiver_list:
			msgprint("Please enter valid mobile nos")
			raise Exception

		return validated_receiver_list
开发者ID:calvinfroedge,项目名称:erpnext,代码行数:33,代码来源:sms_control.py

示例15: 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" % ('%s', '%s', '%s', '%s', '%s', condition), (doctype_name, flt(max_amount), total, based_on, company))
			
			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" % ('%s', '%s', '%s', '%s', condition), (doctype_name, flt(max_amount), total, based_on)) 
			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:
					dcc = get_company_currency(self.doc.company)
					if based_on == 'Grand Total': msg = "since Grand Total exceeds %s. %s" % (dcc, 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 are not authorize to submit this %s %s. Please send for approval to %s" % (doctype_name, msg, add_msg))
				raise Exception
开发者ID:MiteshC,项目名称:erpnext,代码行数:29,代码来源:authorization_control.py


注:本文中的webnotes.utils.cstr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。