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


Python Document.save方法代码示例

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


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

示例1: on_update

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
	def on_update(self):
		"""
			On update, create/update a DocFormat record corresponding to DocType and Print Format Name
		"""
		if self.doc.doc_type:
			from webnotes.model.doc import Document
			res = webnotes.conn.sql("""
				SELECT * FROM `tabDocFormat`
				WHERE format=%s and docstatus<2""", self.doc.name)
			if res and res[0]:
				d = Document('DocFormat', res[0][0])
				d.parent = self.doc.doc_type
				d.parenttype = 'DocType'
				d.parentfield = 'formats'
				d.format = self.doc.name
				d.save()
			else:
				max_idx = webnotes.conn.sql("""
					SELECT MAX(idx) FROM `tabDocFormat`
					WHERE parent=%s
					AND parenttype='DocType'
					AND parentfield='formats'""", self.doc.doc_type)[0][0]
				if not max_idx: max_idx = 0
				d = Document('DocFormat')
				d.parent = self.doc.doc_type
				d.parenttype = 'DocType'
				d.parentfield = 'formats'
				d.format = self.doc.name
				d.idx = max_idx + 1
				d.save(1)
开发者ID:beliezer,项目名称:wnframework,代码行数:32,代码来源:print_format.py

示例2: create_lead_address_contact

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
	def create_lead_address_contact(self):
		if self.doc.lead_name:
			details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, phone, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1)
			d = Document('Address') 
			d.address_line1 = details[0]['address_line1'] 
			d.address_line2 = details[0]['address_line2']
			d.city = details[0]['city']
			d.country = details[0]['country']
			d.pincode = details[0]['pincode']
			d.state = details[0]['state']
			d.fax = details[0]['fax']
			d.email_id = details[0]['email_id']
			d.phone = details[0]['phone']
			d.customer = self.doc.name
			d.customer_name = self.doc.customer_name
			d.is_primary_address = 1
			d.address_type = 'Office'
			try:
				d.save(1)
			except NameError, e:
				pass
				
			c = Document('Contact') 
			c.first_name = details[0]['lead_name'] 
			c.email_id = details[0]['email_id']
			c.phone = details[0]['phone']
			c.mobile_no = details[0]['mobile_no']
			c.customer = self.doc.name
			c.customer_name = self.doc.customer_name
			c.is_primary_contact = 1
			try:
				c.save(1)
			except NameError, e:
				pass
开发者ID:antoxin,项目名称:erpnext,代码行数:36,代码来源:customer.py

示例3: create_account_balances

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
	def create_account_balances(self):
		# get periods
		period_list = self.get_period_list()
		cnt = 0
		
		# get accounts
		al = sql("select name from tabAccount")
		
		for a in al:
			# check
			if sql("select count(*) from `tabAccount Balance` where fiscal_year=%s and account=%s", (self.doc.name, a[0]))[0][0] < 13:
				for p in period_list:
					# check if missing
					if not sql("select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.name)):
						d = Document('Account Balance')
						d.account = a[0]
						d.period = p[0]
						d.start_date = p[1].strftime('%Y-%m-%d')
						d.end_date = p[2].strftime('%Y-%m-%d')
						d.fiscal_year = p[3]
						d.debit = 0
						d.credit = 0
						d.opening = 0
						d.balance = 0
						d.save(1)
						cnt += 1
				if cnt % 100 == 0:
					sql("commit")
					sql("start transaction")
		return cnt
开发者ID:ravidey,项目名称:erpnext,代码行数:32,代码来源:fiscal_year.py

示例4: update_item

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
    def update_item(self):
        i = Document("Item", self.doc.new_item_code)

        # update fields
        i.brand = self.doc.new_item_brand
        i.stock_uom = self.doc.stock_uom
        i.item_group = self.doc.item_group

        i.item_name = self.doc.new_item_name
        i.description = self.doc.description

        # set default as 'No' or 0
        i.is_sample_item = "No"
        i.is_asset_item = "No"
        i.is_purchase_item = "No"
        i.is_manufactured_item = "No"
        i.is_sub_contracted_item = "No"
        i.is_service_item = "No"
        i.inspection_required = "No"
        i.has_serial_no = "No"
        i.lead_time_days = flt(0)
        # update rates
        self.update_ref_rate(i)
        i.save()
        msgprint(
            "Items: %s updated successfully. To update more details open and edit item master" % self.doc.new_item_code
        )
开发者ID:nijil,项目名称:erpnext,代码行数:29,代码来源:sales_bom.py

示例5: create_production_order

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
	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,代码行数:28,代码来源:production_control.py

示例6: import_docs

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
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,代码行数:29,代码来源:import_docs.py

示例7: add_profile

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
def add_profile(email):
	from webnotes.utils import validate_email_add
	from webnotes.model.doc import Document
			
	sql = webnotes.conn.sql
	
	if not email:
		email = webnotes.form_dict.get('user')
	if not validate_email_add(email):
		raise Exception
		return 'Invalid Email Id'
	
	if sql("select name from tabProfile where name = %s", email):
		# exists, enable it
		sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
		webnotes.msgprint('Profile exists, enabled it')
	else:
		# does not exist, create it!
		pr = Document('Profile')
		pr.name = email
		pr.email = email
		pr.enabled=1
		pr.user_type='System User'
		pr.save(1)
		from webnotes.model.code import get_obj
		pr_obj = get_obj(doc=pr)
		pr_obj.on_update()
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:29,代码来源:my_company.py

示例8: copy_doclist

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
def copy_doclist(doclist, no_copy=[]):
    from webnotes.model.doc import Document

    cl = []

    # main doc
    c = Document(fielddata=doclist[0].fields.copy())

    # clear no_copy fields
    for f in no_copy:
        if c.fields.has_key(f):
            c.fields[f] = None

    c.name = None
    c.save(1)
    cl.append(c)

    # new parent name
    parent = c.name

    # children
    for d in doclist[1:]:
        c = Document(fielddata=d.fields.copy())
        c.name = None

        # clear no_copy fields
        for f in no_copy:
            if c.fields.has_key(f):
                c.fields[f] = None

        c.parent = parent
        c.save(1)
        cl.append(c)

    return cl
开发者ID:ranjithtenz,项目名称:stable,代码行数:37,代码来源:doclist.py

示例9: clone

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
def clone(source_doclist):
	""" Copy previous invoice and change dates"""
	from webnotes.model.doc import Document
	new_doclist = []
	new_parent = Document(fielddata = source_doclist.doc.fields.copy())
	new_parent.name = 'Temp/001'
	new_parent.fields['__islocal'] = 1
	new_parent.fields['docstatus'] = 0

	if new_parent.fields.has_key('amended_from'):
		new_parent.fields['amended_from'] = None
		new_parent.fields['amendment_date'] = None

	new_parent.save(1)

	new_doclist.append(new_parent)

	for d in source_doclist.doclist[1:]:
		newd = Document(fielddata = d.fields.copy())
		newd.name = None
		newd.fields['__islocal'] = 1
		newd.fields['docstatus'] = 0
		newd.parent = new_parent.name
		new_doclist.append(newd)
	
	doclistobj = DocList()
	doclistobj.docs = new_doclist
	doclistobj.doc = new_doclist[0]
	doclistobj.doclist = new_doclist
	doclistobj.children = new_doclist[1:]
	doclistobj.save()
	return doclistobj
开发者ID:beliezer,项目名称:wnframework,代码行数:34,代码来源:doclist.py

示例10: create_sal_slip

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
	def create_sal_slip(self):
		"""
			Creates salary slip for selected employees if already not created
		
		"""
		
		emp_list = self.get_emp_list()
		ss_list = []
		for emp in emp_list:
			if not sql("""select name from `tabSalary Slip` 
					where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s
					""", (emp[0], self.doc.month, self.doc.fiscal_year, self.doc.company)):
				ss = Document('Salary Slip')
				ss.fiscal_year = self.doc.fiscal_year
				ss.employee = emp[0]
				ss.month = self.doc.month
				ss.email_check = self.doc.send_email
				ss.company = self.doc.company
				ss.save(1)
			
				ss_obj = get_obj('Salary Slip', ss.name, with_children=1)
				ss_obj.get_emp_and_leave_details()
				ss_obj.calculate_net_pay()
				ss_obj.validate()
				ss_obj.doc.save()
			
				for d in getlist(ss_obj.doclist, 'earning_details'):
					d.save()
				for d in getlist(ss_obj.doclist, 'deduction_details'):
					d.save()
					
				ss_list.append(ss.name)
		
		return self.create_log(ss_list)
开发者ID:BillTheBest,项目名称:erpnext,代码行数:36,代码来源:salary_manager.py

示例11: add_profile

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
def add_profile(args):
	from webnotes.utils import validate_email_add
	from webnotes.model.doc import Document
	email = args['user']
			
	sql = webnotes.conn.sql
	
	if not email:
		email = webnotes.form_dict.get('user')
	if not validate_email_add(email):
		raise Exception
		return 'Invalid Email Id'
	
	if sql("select name from tabProfile where name = %s", email):
		# exists, enable it
		sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
		webnotes.msgprint('Profile exists, enabled it')
	else:
		# does not exist, create it!
		pr = Document('Profile')
		pr.name = email
		pr.email = email
		pr.first_name = args.get('first_name')
		pr.last_name = args.get('last_name')
		pr.enabled = 1
		pr.user_type = 'System User'
		pr.save(1)

		if args.get('password'):
			sql("""
				UPDATE tabProfile 
				SET password = PASSWORD(%s)
				WHERE name = %s""", (args.get('password'), email))
开发者ID:calvinfroedge,项目名称:erpnext,代码行数:35,代码来源:my_company.py

示例12: process_payroll

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
    def process_payroll(self):
        sal_slip_str = ""
        if self.doc.month and self.doc.fiscal_year and self.doc.year:
            e = self.get_employee()
            if e:
                self.doc.emp_lst = e
                sal_slip_str += "Sucessfully created following salary slips:"
            for i in e:
                ss = Document("Salary Slip")
                ss.fiscal_year = self.doc.fiscal_year
                ss.employee = i
                ss.month = self.doc.month
                ss.year = self.doc.year
                ss.arrear_amount = self.doc.arrear_amount
                ss.email_check = self.doc.email_check
                ss.save(1)
                salary_obj = get_obj("Salary Slip", ss.name, with_children=1)
                salary_obj.process_payroll_all()
                sal_slip_str += "<br/>" + ss.name

        else:

            msgprint("For Process Payroll Fiscal Year, Month, Year fields are mandatory.")
        if not sal_slip_str:

            sal_slip_str = "No record found."
        return cstr(sal_slip_str)
开发者ID:Vichagserp,项目名称:cimworks,代码行数:29,代码来源:salary_slip_control_panel.py

示例13: attach_file_test

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
def attach_file_test(html_,path_data):
	import easywebdav
	a=webnotes.conn.sql("select value from `tabSingles` where doctype='LDAP Settings' and field='dms_server'",as_list=1)
        if a:
                webdav = easywebdav.connect(a[0][0],username='swapnil',password='swapnil')
		import io
                name=path_data[0]
                path=cstr(path_data[0]).replace("/","")
                f = io.open("files/"+path+".html", 'w', encoding='utf8')
                f.write(html_)
                f.close()

                s=auth()
                if s[0]=="Done":
                        dms_path=webnotes.conn.sql("select value from `tabSingles` where doctype='LDAP Settings' and field='dms_path'",as_list=1)
                        check_status=webnotes.conn.sql("select file_url from `tabFile Data` where file_url='"+dms_path[0][0]+path_data[1]+"/"+path+".html"+"'",as_list=1)
                        if not check_status:
				webdav.upload("files/"+path+".html",'/doxbox/OwlWebDav/index.php/'+path_data[1]+"/"+path+".html")
                                file_attach=Document("File Data")
                                file_attach.file_name="files/"+path+".html"
                                file_attach.attached_to_doctype=path_data[2]
                                file_attach.file_url=dms_path[0][0]+path_data[1]+"/"+path+".html"
                                file_attach.attached_to_name=name
                                file_attach.save()
                                os.remove("files/"+path+".html")
                                return "File Save Sucessfully"
                        else:
                                return "File Already Exist"
                else:
                        return s[1]
        else:
                return ["Error","Server is not defined"]
开发者ID:rohitw1991,项目名称:innoworth-app,代码行数:34,代码来源:journal_voucher.py

示例14: activate_deactivate

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
def activate_deactivate(site_name , is_active, _type='POST'):
	# return "hi"
	from webnotes.model.doc import Document
	from webnotes.utils import now
	site_details = webnotes.conn.sql("select database_name, database_password from `tabSite Details` where name = '%s'"%(site_name))
	# return site_details
	if site_details:
		import MySQLdb
		try:
			myDB = MySQLdb.connect(user="%s"%site_details[0][0], passwd="%s"%site_details[0][1], db="%s"%site_details[0][0])
			cHandler = myDB.cursor()
			cHandler.execute("update  tabSingles set value = '%s' where field='is_active' and doctype = 'Global Defaults'"%is_active)
			cHandler.execute("commit")
			myDB.close()

			d = Document("Site Log")
			d.site_name =site_name
			d.is_active = is_active
			d.date_time = now()
			d.save()
			webnotes.conn.sql("commit")
			return {"status":"200", 'name':d.name}

		except Exception as inst: 
			return {"status":"417", "error":inst}
	else:
		return{"status":"404", "Error":"Site Not Fount"}
开发者ID:saurabh6790,项目名称:omn-lib,代码行数:29,代码来源:site_details.py

示例15: create_child

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import save [as 别名]
        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,代码行数:31,代码来源:patient_encounter_entry.py


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