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

Python doc.Document类代码示例

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

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



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

示例1: update_warranty_amc_history

 def update_warranty_amc_history(self, submit=1):
     if self.doc.order_type in ["AMC", "OTS (One Time Service)"]:
         sr_list = []
         if submit:
             for d in getlist(self.doclist, "service_order_details"):
                 sr = Document("Serial No", d.serial_no)
                 child = addchild(sr, "warranty_amc_history", "Warranty AMC History", 0)
                 child.from_date = d.start_date
                 child.to_date = d.end_date
                 child.status = (self.doc.order_type == "AMC") and "Under AMC" or "OTS (One Time Service)"
                 child.against_doctype = self.doc.doctype
                 child.against_docname = self.doc.name
                 child.customer = self.doc.customer
                 child.territory = self.doc.territory
                 child.save()
                 sr.warranty_amc_status = (self.doc.order_type == "AMC") and "Under AMC" or "OTS (One Time Service)"
                 sr.amc_expiry_date = d.end_date
                 sr.save()
                 sr_list.append(d.serial_no)
         else:
             sql(
                 "delete from `tabWarranty AMC History` where against_doctype = %s and against_docname = %s",
                 (self.doc.doctype, self.doc.name),
             )
             for d in getlist(self.doclist, "service_order_details"):
                 sql("update `tabSerial No` set amc_expiry_date = '' where name = '%s'" % (d.serial_no))
                 sr_list.append(d.serial_no)
         self.update_serial_no_warranty_amc_status(serial_no_list=sr_list)
开发者ID:Vichagserp,项目名称:cimworks,代码行数:28,代码来源:service_order.py


示例2: create_production_order

  def create_production_order(self,company, fy, pp_detail = '', pro_detail = ''):
    pro_lbl = {'production_item': 0, 'description': 1, 'qty' : 2, 'stock_uom' : 3, 'bom_no': 4, 'consider_sa_items': 5}
           
    default_values = { 'transaction_date'            : now(),
                       'origin'          : pp_detail and 'MRP' or 'Direct',
                       'wip_warehouse'   : 'MB1-Stores',
                       'status'          : 'Draft',
                       'company'         : company,
                       'fiscal_year'     : fy }
     
    pro_list, count = pp_detail and pp_detail or pro_detail, 0

    while (count < len(pro_list)):
      pro_doc = Document('Production Order')

      for key in pro_lbl.keys():
        pro_doc.fields[key] = pro_list[count][pro_lbl[key]]
      
      for key in default_values:
        pro_doc.fields[key] = default_values[key]
      
      pro_doc.save(new = 1)
      pro_list[count] = pro_doc.name
      
      # This was for adding raw materials in pro detail and get sa items
      #sa_list = get_obj('Porduction Order', pro_doc.name, with_children = 1).get_purchase_item( get_sa_items = 1, add_child= 1)
      #for sa_item in sa_list:
      #  pro_list.append(sa_item)

      count = count + 1
    return pro_list
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:31,代码来源:production_control.py


示例3: save_entries

def save_entries(gl_map, cancel, adv_adj, update_outstanding):
	total_debit = total_credit = 0.0
	def _swap(gle):
		gle.debit, gle.credit = abs(flt(gle.credit)), abs(flt(gle.debit))
			
	for entry in gl_map:
		gle = Document('GL Entry', fielddata=entry)
		
		# toggle debit, credit if negative entry
		if flt(gle.debit) < 0 or flt(gle.credit) < 0:
			_swap(gle)

		# toggled debit/credit in two separate condition because 
		# both should be executed at the 
		# time of cancellation when there is negative amount (tax discount)
		if cancel:
			_swap(gle)

		gle_obj = webnotes.get_obj(doc=gle)
		# validate except on_cancel
		if not cancel:
			gle_obj.validate()

		# save
		gle.save(1)
		gle_obj.on_update(adv_adj, cancel, update_outstanding)

		# update total debit / credit
		total_debit += flt(gle.debit)
		total_credit += flt(gle.credit)
		
		# print gle.account, gle.debit, gle.credit, total_debit, total_credit
		
	if not cancel:
		validate_total_debit_credit(total_debit, total_credit)
开发者ID:robertbecht,项目名称:erpnext,代码行数:35,代码来源:general_ledger.py


示例4: validate_incoming

	def validate_incoming(self):
		"""
			Checks support ticket email settings
		"""
		if self.doc.sync_support_mails and self.doc.support_host:
			from webnotes.utils.email_lib.receive import POP3Mailbox
			from webnotes.model.doc import Document
			import _socket, poplib
			inc_email = Document('Incoming Email Settings')
			inc_email.host = self.doc.support_host.encode('utf-8')
			inc_email.use_ssl = self.doc.support_use_ssl
			try:
				inc_email.username = self.doc.support_username.encode('utf-8')
				inc_email.password = self.doc.support_password.encode('utf-8')
			except AttributeError, e:
				webnotes.msgprint('User Name or Support Password missing. Please enter and try again.')
				webnotes.msgprint(e)

			pop_mb = POP3Mailbox(inc_email)
			
			try:
				pop_mb.connect()
			except _socket.error, e:
				# Invalid mail server -- due to refusing connection
				webnotes.msgprint('Invalid POP3 Mail Server. Please rectify and try again.')
				webnotes.msgprint(e)
开发者ID:NorrWing,项目名称:erpnext,代码行数:26,代码来源:email_settings.py


示例5: 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


示例6: addchild

	def addchild(self, fieldname, childtype = '', doclist=None):
		"""
	      Returns a child record of the give `childtype`.
	      
	      * if local is set, it does not save the record
	      * if doclist is passed, it append the record to the doclist
		"""
		from webnotes.model.doc import Document
		d = Document()
		d.parent = self.name
		d.parenttype = self.doctype
		d.parentfield = fieldname
		d.doctype = childtype
		d.docstatus = 0;
		d.name = ''
		d.owner = webnotes.session['user']
		d.fields['__islocal'] = 1 # for Client to identify unsaved doc
		
		if doclist != None:
			doclist.append(d)
			
		if doclist:
			d.idx = max([(d.idx or 0) for d in doclist if d.doctype==childtype]) + 1
	
		return d
开发者ID:frank1638,项目名称:wnframework,代码行数:25,代码来源:doc.py


示例7: load_data

def load_data():
	test_purchase_receipt.load_data()
	
	webnotes.insert({"doctype": "Account", "account_name": "Cost for Goods Sold",
		"parent_account": "Expenses - %s" % abbr, "company": company,
		"group_or_ledger": "Ledger"})
	
	webnotes.insert({"doctype": "Account", "account_name": "Excise Duty",
		"parent_account": "_Test Tax Assets - %s" % abbr, "company": company,
		"group_or_ledger": "Ledger"})
	
	webnotes.insert({"doctype": "Account", "account_name": "Education Cess",
		"parent_account": "_Test Tax Assets - %s" % abbr, "company": company,
		"group_or_ledger": "Ledger"})
	
	webnotes.insert({"doctype": "Account", "account_name": "S&H Education Cess",
		"parent_account": "_Test Tax Assets - %s" % abbr, "company": company,
		"group_or_ledger": "Ledger"})
		
	webnotes.insert({"doctype": "Account", "account_name": "CST",
		"parent_account": "Direct Expenses - %s" % abbr, "company": company,
		"group_or_ledger": "Ledger"})
		
	webnotes.insert({"doctype": "Account", "account_name": "Discount",
		"parent_account": "Direct Expenses - %s" % abbr, "company": company,
		"group_or_ledger": "Ledger"})
		
	from webnotes.model.doc import Document
	item = Document("Item", "Home Desktop 100")
	
	# excise duty
	item_tax = item.addchild("item_tax", "Item Tax")
	item_tax.tax_type = "Excise Duty - %s" % abbr
	item_tax.tax_rate = 10
	item_tax.save()
开发者ID:robertbecht,项目名称:erpnext,代码行数:35,代码来源:test_purchase_invoice.py


示例8: save_file

def save_file(fname, content, module=None):
	from webnotes.model.doc import Document
	from filecmp import cmp

	check_max_file_size(content)
	new_fname = write_file(content)

	# some browsers return the full path
	if '\\' in fname:
		fname = fname.split('\\')[-1]
	if '/' in fname:
		fname = fname.split('/')[-1]
		
	# we use - for versions, so remove them from the name!
	fname = fname.replace('-', '')

	fpath = os.path.join(get_files_path(), fname)
	if os.path.exists(fpath) and cmp(fpath, new_fname):
		# remove new file, already exists!
		os.remove(new_fname)
		return fname
	else:
		# generate the ID (?)
		f = Document('File Data')
		f.file_name = fname
		f.save(1)
		# rename new file
		os.rename(new_fname, os.path.join(get_files_path(), f.name))
		return f.name
开发者ID:gowrav-vishwakarma,项目名称:wnframework,代码行数:29,代码来源:file_manager.py


示例9: make_single_entry

	def make_single_entry(self,parent,d,le_map,cancel, merge_entries):
		if self.get_val(le_map['account'], d, parent) and \
				(self.get_val(le_map['debit'], d, parent) \
				or self.get_val(le_map['credit'], d, parent)):
			flist = ['account', 'cost_center', 'against', 'debit', 'credit', 'remarks',
			 	'voucher_type', 'voucher_no', 'posting_date', 'fiscal_year', 'against_voucher',
			 	'against_voucher_type', 'company', 'is_opening', 'aging_date']

			# Check budget before gl entry
			#check budget only if account is expense account
			is_expense_acct = webnotes.conn.sql("""select name from tabAccount 
				where is_pl_account='Yes' and debit_or_credit='Debit' 
				and name=%s""",self.get_val(le_map['account'], d, parent))
				
			if is_expense_acct and self.get_val(le_map['cost_center'], d, parent):
				get_obj('Budget Control').check_budget([self.get_val(le_map[k], d, parent) 
					for k in flist if k in ['account', 'cost_center', 'debit', 
					'credit', 'posting_date', 'fiscal_year', 'company']],cancel)

			# Create new GL entry object and map values
			le = Document('GL Entry')
			for k in flist:
				le.fields[k] = self.get_val(le_map[k], d, parent)
			# if there is already an entry in this account then just add it to that entry
			same_head = self.check_if_in_list(le)
			if same_head and merge_entries:
				same_head = same_head[0]
				same_head.debit	= flt(same_head.debit)	+ flt(le.debit)
				same_head.credit = flt(same_head.credit) + flt(le.credit)
			else:
				self.entries.append(le)
开发者ID:MiteshC,项目名称:erpnext,代码行数:31,代码来源:gl_control.py


示例10: import_docs

def import_docs(docs = []):
	from webnotes.model.doc import Document
	import webnotes.model.code

	doc_list = {}
	created_docs = []
	already_exists = []

	out, tmp ="", ""

	for d in docs:
		cur_doc = Document(fielddata = d)
		if not cur_doc.parent in already_exists: # parent should not exist
			try:
				cur_doc.save(1)
				out += "Created: " + cur_doc.name + "\n"
				created_docs.append(cur_doc)

				# make in groups
				if cur_doc.parent:
					if not doc_list.has_key(cur_doc.parent):
						doc_list[cur_doc.parent] = []
					doc_list[cur_doc.parent].append(cur_doc)

			except Exception, e:
				out += "Creation Warning/Error: " + cur_doc.name + " :"+ str(e) + "\n"
				already_exists.append(cur_doc.name)
开发者ID:cmrajan,项目名称:wnframework,代码行数:27,代码来源:import_docs.py


示例11: create_child

        def create_child(self):
                from datetime import datetime
                # date_a=cstr(datetime.combine(datetime.strptime(self.doc.encounter_date,'%Y-%m-%d').date(),datetime.strptime(self.doc.start_time,'%H:%M').time()))
                # date_b=cstr(datetime.combine(datetime.strptime(self.doc.encounter_date,'%Y-%m-%d').date(),datetime.strptime(self.doc.end_time,'%H:%M').time()))
                if self.doc.appointment_slot:
                        webnotes.errprint([self.doc.start_time])
                        check_confirmed=webnotes.conn.sql("select true from `tabSlot Child` where slot='"+self.doc.appointment_slot+"' and modality='"+self.doc.encounter+"' and study='"+self.doc.study+"' and date_format(start_time,'%Y-%m-%d %H:%M')=date_format('"+date_a+"','%Y-%m-%d %H:%M') and date_format(end_time,'%Y-%m-%d %H:%M')=date_format('"+date_b+"','%Y-%m-%d %H:%M') and status='Confirm'",debug=1)
                        webnotes.errprint(check_confirmed)
                        if not check_confirmed:

                                check_status=webnotes.conn.sql("select case when count(*)<2 then true else false end  from `tabSlot Child` where slot='"+self.doc.appointment_slot+"' and modality='"+self.doc.encounter+"' and study='"+self.doc.study+"' and date_format(start_time,'%Y-%m-%d %H:%M')=date_format('"+date_a+"','%Y-%m-%d %H:%M') and date_format(end_time,'%Y-%m-%d %H:%M')=date_format('"+date_b+"','%Y-%m-%d %H:%M') and status<>'Cancel'",as_list=1)
                                webnotes.errprint(check_status[0][0])
                                if check_status[0][0]==1:

                                        d=Document("Slot Child")
                                        d.slot=self.doc.appointment_slot
                                        d.modality=self.doc.encounter
                                        d.study=self.doc.study
                                        d.status='Waiting'
                                        d.encounter=self.doc.name
                                        d.start_time=date_a
                                        d.end_time=date_b
                                        d.save()
                                        self.make_event(d.name)
                                        self.doc.slot=d.name
                                else:
                                        webnotes.msgprint("Selected slot is not available",raise_exception=1)
                        else:
                                webnotes.msgprint("Selected slot is not available",raise_exception=1)
开发者ID:saurabh6790,项目名称:alert-med-app,代码行数:29,代码来源:patient_encounter_entry.py


示例12: update_warranty_amc_history

 def update_warranty_amc_history(self, submit = 1):
   if self.doc.order_type in ['AMC', 'OTS (One Time Service)']:
     sr_list = []
     if submit:
       for d in getlist(self.doclist, 'service_order_details'):
         sr = Document('Serial No', d.serial_no)
         child = addchild(sr, 'warranty_amc_history', 'Warranty AMC History', 0)
         child.from_date = d.start_date
         child.to_date = d.end_date
         child.status = (self.doc.order_type == 'AMC') and 'Under AMC' or 'OTS (One Time Service)'
         child.against_doctype = self.doc.doctype
         child.against_docname = self.doc.name
         child.customer = self.doc.customer
         child.territory = self.doc.territory
         child.save()
         sr.warranty_amc_status = (self.doc.order_type == 'AMC') and 'Under AMC' or 'OTS (One Time Service)'
         sr.amc_expiry_date = d.end_date
         sr.save()
         sr_list.append(d.serial_no)
     else:
       sql("delete from `tabWarranty AMC History` where against_doctype = %s and against_docname = %s", (self.doc.doctype, self.doc.name))
       for d in getlist(self.doclist, 'service_order_details'):
         sql("update `tabSerial No` set amc_expiry_date = '' where name = '%s'" % (d.serial_no))
         sr_list.append(d.serial_no)
     self.update_serial_no_warranty_amc_status(serial_no_list = sr_list)
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:25,代码来源:service_order.py


示例13: add

def add():
	"""add in someone's to do list"""
	if webnotes.conn.sql("""select owner from `tabToDo Item`
		where reference_type=%(doctype)s and reference_name=%(name)s
		and owner=%(assign_to)s""", webnotes.form_dict):
		webnotes.msgprint("Already in todo")
		return
	else:
		from webnotes.model.doc import Document
		from webnotes.utils import nowdate
		
		d = Document("ToDo Item")
		d.owner = webnotes.form_dict['assign_to']
		d.reference_type = webnotes.form_dict['doctype']
		d.reference_name = webnotes.form_dict['name']
		d.description = webnotes.form_dict['description']
		d.priority = webnotes.form_dict.get('priority', 'Medium')
		d.date = webnotes.form_dict.get('date', nowdate())
		d.assigned_by = webnotes.user.name
		d.save(1)

	# notify
	notify_assignment(d.assigned_by, d.owner, d.reference_type, d.reference_name, action='ASSIGN', notify=webnotes.form_dict.get('notify'))
		
	# update feeed
	try:
		import home
		from webnotes.utils import get_fullname
		home.make_feed('Assignment', d.reference_type, d.reference_name, webnotes.session['user'],
			'[%s] Assigned to %s' % (d.priority, get_fullname(d.owner)), '#C78F58')
	except ImportError, e:
		pass
开发者ID:beliezer,项目名称:wnframework,代码行数:32,代码来源:assign_to.py


示例14: make_item_group_active

	def make_item_group_active(self):
		"""show item group in website"""
		if self.doc.published:
			from webnotes.model.doc import Document
			ig = Document('Item Group', self.doc.item_group)
			ig.show_in_website = 1
			ig.save()
开发者ID:antoxin,项目名称:erpnext,代码行数:7,代码来源:product.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_warranty_amc_history

 def update_warranty_amc_history(self, submit = 1):
   if submit:
     for d in getlist(self.doclist, 'delivery_note_details'):
       if d.serial_no:
         serial_nos = self.get_sr_no_list(d.serial_no)
         for s in serial_nos:
           sr = Document('Serial No', s)
           child = addchild(sr, 'warranty_amc_history', 'Warranty AMC History', 0)
           child.from_date = self.doc.transaction_date
           child.to_date = d.warranty_expiry_date
           child.status = 'Under Warranty'
           child.against_doctype = self.doc.doctype
           child.against_docname = self.doc.name
           child.customer = self.doc.customer
           child.territory = self.doc.territory
           child.save()
           sr.warranty_amc_status = 'Under Warranty'
           sr.warranty_expiry_date = d.warranty_expiry_date
           sr.save()
   else:
     sql("delete from `tabWarranty AMC History` where against_doctype = %s and against_docname = %s", (self.doc.doctype, self.doc.name))
     sr_list = []
     for d in getlist(self.doclist, 'service_order_details'):
       if d.serial_no:
         serial_nos = self.get_sr_no_list(d.serial_no)
         for s in serial_nos:
           sql("update `tabSerial No` set warranty_expiry_date = '' where name = '%s'" % (s))
           sr_list.append(s)
     self.update_serial_no_warranty_amc_status(serial_no_list = sr_list) 
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:29,代码来源:delivery_note.py


示例17: close_session

def close_session(session_id):
	from webnotes.model.doc import Document
	d = Document('Session',session_id)
	d.status = 'Close'
	d.save()
	return{
		'session_id':''
	}
开发者ID:saurabh6790,项目名称:tru_app_back,代码行数:8,代码来源:neutralization_value.py


示例18: naming_series

	def naming_series(self):
		ns = [['TDS Payment', 'TDSP'], ['Payable Voucher', 'BILL'], ['Journal Voucher', 'JV'], ['Receivable Voucher', 'INV'], ['Lead', 'Lead'], ['Indent', 'IDT'], ['Enquiry', 'Enquiry'], ['Purchase Order', 'PO'], ['Quotation', 'QTN'], ['Purchase Receipt', 'GRN'], ['Stock Entry', 'STE'], ['Sales Order', 'SO'], ['Delivery Note', 'DN'], ['Employee', 'EMP/']]
		for r in ns: 
			rec = Document('Naming Series')
			rec.select_doc_for_series = r[0]
			rec.new_series = r[1]
			rec_obj = get_obj(doc=rec)
			rec_obj.add_series()
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:8,代码来源:setup_control.py


示例19: execute

def execute():
	companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)
	for company in companies_list:
		if company and company[0]:
			edigest = Document('Email Digest', "Default Weekly Digest - " + company[0])
			if edigest:
				edigest.income_year_to_date = 1
				edigest.save()
开发者ID:calvinfroedge,项目名称:erpnext,代码行数:8,代码来源:edigest_enable_income_year_to_date.py


示例20: add_guest_access_to_page

def add_guest_access_to_page(page):
	"""add Guest in Page Role"""
	if not webnotes.conn.sql("""select parent from `tabPage Role`
		where role='Guest' and parent=%s""", page):
		d = Document('Page Role')
		d.parent = page
		d.role = 'Guest'
		d.save()
开发者ID:antoxin,项目名称:erpnext,代码行数:8,代码来源:utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python doclist.getlist函数代码示例发布时间:2022-05-26
下一篇:
Python doc.make_autoname函数代码示例发布时间: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