• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python doclist.DocList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getchildren

def getchildren(name, childtype, field='', parenttype='', from_doctype=0, prefix='tab'):
	import webnotes
	from webnotes.model.doclist import DocList
	
	condition = ""
	values = []
	
	if field: 
		condition += ' and parentfield=%s '
		values.append(field)
	if parenttype:
		condition += ' and parenttype=%s '
		values.append(parenttype)

	dataset = webnotes.conn.sql("""select * from `%s%s` where parent=%s %s order by idx""" \
		% (prefix, childtype, "%s", condition), tuple([name]+values))
	desc = webnotes.conn.get_description()

	l = DocList()
	
	for i in dataset:
		d = Document()
		d.doctype = childtype
		d._load_values(i, desc)
		l.append(d)
	
	return l
开发者ID:appost,项目名称:wnframework,代码行数:27,代码来源:doc.py


示例2: savedocs

def savedocs():
	"""save / submit / cancel / update doclist"""
	try:
		from webnotes.model.doclist import DocList
		form = webnotes.form_dict

		doclist = DocList()
		doclist.from_compressed(form.get('docs'), form.get('docname'))

		# action
		action = form.get('action')

		if action=='Update': action='update_after_submit'

		getattr(doclist, action.lower())()

		# update recent documents
		webnotes.user.update_recent(doclist.doc.doctype, doclist.doc.name)

		# send updated docs
		webnotes.response['saved'] = '1'
		webnotes.response['main_doc_name'] = doclist.doc.name
		webnotes.response['docname'] = doclist.doc.name
		webnotes.response['docs'] = [doclist.doc] + doclist.children

	except Exception, e:
		webnotes.msgprint('Did not save')
		webnotes.errprint(webnotes.utils.getTraceback())
		raise e
开发者ID:NorrWing,项目名称:wnframework,代码行数:29,代码来源:save.py


示例3: testFailAssert

	def testFailAssert(self):
		if docnotok:
			with self.assertRaises(Exception) as context:
				d = DocList()
				d.doc = docnotok[0]
				d.children = None
				d.doc.fields['__islocal']=1
				d.save(1)
开发者ID:NorrWing,项目名称:erpnext,代码行数:8,代码来源:test_item.py


示例4: testInsert

	def testInsert(self):
		d = DocList()

		count_before =  flt(sql("select count(*) from tab"+_doctype)[0][0])
		if docok:
			for i in docok:
				d.doc = i
				d.children = None
				d.doc.fields['__islocal']=1
				d.save(1)
		count_after = flt(sql("select count(*) from tab"+_doctype)[0][0])
		self.assertTrue(count_before+len(docok)==count_after)
开发者ID:NorrWing,项目名称:erpnext,代码行数:12,代码来源:test_item.py


示例5: cancel_packing_slips

	def cancel_packing_slips(self):
		"""
			Cancel submitted packing slips related to this delivery note
		"""
		res = webnotes.conn.sql("""\
			SELECT name, count(*) FROM `tabPacking Slip`
			WHERE delivery_note = %s AND docstatus = 1
			""", self.doc.name)

		if res and res[0][1]>0:
			from webnotes.model.doclist import DocList
			for r in res:
				ps = DocList(dt='Packing Slip', dn=r[0])
				ps.cancel()
			webnotes.msgprint("%s Packing Slip(s) Cancelled" % res[0][1])
开发者ID:prakashhodage,项目名称:erpnext,代码行数:15,代码来源:delivery_note.py


示例6: sort_fields

def sort_fields(doclist):
	"""sort on basis of previous_field"""
	from webnotes.model.doclist import DocList
	newlist = DocList([])
	pending = filter(lambda d: d.doctype=='DocField', doclist)
	
	maxloops = 20
	while (pending and maxloops>0):
		maxloops -= 1
		for d in pending[:]:
			if d.previous_field:
				# field already added
				for n in newlist:
					if n.fieldname==d.previous_field:
						newlist.insert(newlist.index(n)+1, d)
						pending.remove(d)
						break
			else:
				newlist.append(d)
				pending.remove(d)

	# recurring at end	
	if pending:
		newlist += pending

	# renum
	idx = 1
	for d in newlist:
		d.idx = idx
		idx += 1

	doclist.get({"doctype":["!=", "DocField"]}).extend(newlist)
开发者ID:ricardomomm,项目名称:wnframework,代码行数:32,代码来源:doctype.py


示例7: runserverobj

def runserverobj():
	"""
		Run server objects
	"""
	import webnotes.model.code
	from webnotes.model.doclist import DocList
	from webnotes.utils import cint

	form = webnotes.form

	doclist = None
	method = form.getvalue('method')
	arg = form.getvalue('arg')
	dt = form.getvalue('doctype')
	dn = form.getvalue('docname')

	if dt: # not called from a doctype (from a page)
		if not dn: dn = dt # single
		so = webnotes.model.code.get_obj(dt, dn)

	else:
		doclist = DocList()
		doclist.from_compressed(form.getvalue('docs'), dn)
		so = doclist.make_obj()
		
	check_guest_access(so.doc)
	
	if so:
		r = webnotes.model.code.run_server_obj(so, method, arg)
		if r:
			#build output as csv
			if cint(webnotes.form.getvalue('as_csv')):
				make_csv_output(r, so.doc.doctype)
			else:
				webnotes.response['message'] = r
		
		webnotes.response['docs'] =[so.doc] + so.doclist
开发者ID:umairsy,项目名称:wnframework,代码行数:37,代码来源:form.py


示例8: getchildren

def getchildren(name, childtype, field='', parenttype='', from_doctype=0, prefix='tab'):
	import webnotes
	from webnotes.model.doclist import DocList
	
	tmp = ''
	
	if field: 
		tmp = ' and parentfield="%s" ' % field
	if parenttype:
		tmp = ' and parenttype="%s" ' % parenttype

	dataset = webnotes.conn.sql("select * from `%s%s` where parent='%s' %s order by idx" \
		% (prefix, childtype, name, tmp))
	desc = webnotes.conn.get_description()

	l = DocList()
	
	for i in dataset:
		d = Document()
		d.doctype = childtype
		d._load_values(i, desc)
		l.append(d)
	
	return l
开发者ID:gowrav-vishwakarma,项目名称:wnframework,代码行数:24,代码来源:doc.py


示例9: sort_fields

def sort_fields(doclist):
	"""sort on basis of previous_field"""

	from webnotes.model.doclist import DocList
	newlist = DocList([])
	pending = doclist.get({"doctype":"DocField"})

	if doclist[0].get("_idx"):
		for fieldname in json.loads(doclist[0].get("_idx")):
			d = doclist.get({"fieldname": fieldname})
			if d:
				newlist.append(d[0])
				pending.remove(d[0])
	else:
		maxloops = 20
		while (pending and maxloops>0):
			maxloops -= 1
			for d in pending[:]:
				if d.previous_field:
					# field already added
					for n in newlist:
						if n.fieldname==d.previous_field:
							newlist.insert(newlist.index(n)+1, d)
							pending.remove(d)
							break
				else:
					newlist.append(d)
					pending.remove(d)

	# recurring at end	
	if pending:
		newlist += pending

	# renum
	idx = 1
	for d in newlist:
		d.idx = idx
		idx += 1

	doclist.get({"doctype":["!=", "DocField"]}).extend(newlist)
开发者ID:bindscha,项目名称:wnframework_old,代码行数:40,代码来源:doctype.py


示例10: import_vouchers

def import_vouchers(common_values, data, start_idx, import_type):
	from webnotes.model.doc import Document
	from webnotes.model.doclist import DocList
	from webnotes.model.code import get_obj
	from accounts.utils import get_fiscal_year
	from webnotes.utils.dateutils import parse_date

	messages = []
		
	def get_account_details(account):
		acc_details = webnotes.conn.sql("""select is_pl_account, 
			master_name from tabAccount where name=%s""", account, as_dict=1)
		if not acc_details:
			webnotes.msgprint("%s is not an Account" % account, raise_exception=1)
		return acc_details[0]

	def apply_cost_center_and_against_invoice(detail, d):
		account = get_account_details(detail.account)

		if account.is_pl_account=="Yes":
			detail.cost_center = d.cost_center
		
		if account.master_name:
			map_fields(["against_sales_invoice:against_invoice", 
				"against_purhase_invoice:against_voucher", 
				"against_journal_voucher:against_jv"], d, detail.fields)
	
	webnotes.conn.commit()
	for i in xrange(len(data)):
		d = data[i][0]
		jv = webnotes.DictObj()

		try:
			d.posting_date = parse_date(d.posting_date)
			d.due_date = d.due_date and parse_date(d.due_date) or None
			
			if d.ref_number:
				if not d.ref_date:
					raise webnotes.ValidationError, \
						"""Ref Date is Mandatory if Ref Number is specified"""
				d.ref_date = parse_date(d.ref_date)
				
			d.company = common_values.company
						
			jv = Document("Journal Voucher")
			map_fields(["voucher_type", "posting_date", "naming_series", "remarks:user_remark",
				"ref_number:cheque_no", "ref_date:cheque_date", "is_opening",
				"amount:total_debit", "amount:total_credit", "due_date", "company"], d, jv.fields)

			jv.fiscal_year = get_fiscal_year(jv.posting_date)[0]

			details = []
			if import_type == "Voucher Import: Two Accounts":
				detail1 = Document("Journal Voucher Detail")
				detail1.parent = True
				detail1.parentfield = "entries"
				map_fields(["debit_account:account","amount:debit"], d, detail1.fields)
				apply_cost_center_and_against_invoice(detail1, d)
		

				detail2 = Document("Journal Voucher Detail")
				detail2.parent = True
				detail2.parentfield = "entries"
				map_fields(["credit_account:account","amount:credit"], d, detail2.fields)
				apply_cost_center_and_against_invoice(detail2, d)
				
				details = [detail1, detail2]
			elif import_type == "Voucher Import: Multiple Accounts":
				accounts = data[i][1]
				for acc in accounts:
					detail = Document("Journal Voucher Detail")
					detail.parent = True
					detail.parentfield = "entries"
					detail.account = acc
					detail.debit = flt(accounts[acc]) > 0 and flt(accounts[acc]) or 0
					detail.credit = flt(accounts[acc]) < 0 and -1*flt(accounts[acc]) or 0
					apply_cost_center_and_against_invoice(detail, d)
					details.append(detail)
								
			if not details:
				messages.append("""<p style='color: red'>No accounts found. 
					If you entered accounts correctly, please check template once</p>""")
				return
			webnotes.conn.begin()
			doclist = DocList([jv]+details)
			doclist.submit()
			webnotes.conn.commit()
			
			messages.append("""<p style='color: green'>[row #%s] 
				<a href=\"#Form/Journal Voucher/%s\">%s</a> imported</p>""" \
				% ((start_idx + 1) + i, jv.name, jv.name))
			
		except Exception, e:
			webnotes.conn.rollback()
			err_msg = webnotes.message_log and webnotes.message_log[0] or unicode(e)
			messages.append("<p style='color: red'>[row #%s] %s failed: %s</p>" \
				% ((start_idx + 1) + i, jv.name or "", err_msg or "No message"))
			webnotes.errprint(webnotes.getTraceback())

		webnotes.message_log = []
开发者ID:trycatcher,项目名称:erpnext,代码行数:100,代码来源:voucher_import_tool.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python doctype.get函数代码示例发布时间:2022-05-26
下一篇:
Python doclist.getlist函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap