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


Python webnotes.doc函数代码示例

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


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

示例1: build_sitemap_options

def build_sitemap_options(page_name):
	sitemap_options = webnotes.doc("Website Sitemap", page_name).fields
	
	# only non default fields
	for fieldname in default_fields:
		if fieldname in sitemap_options:
			del sitemap_options[fieldname]
	
	sitemap_config = webnotes.doc("Website Sitemap Config", 
		sitemap_options.get("website_sitemap_config")).fields
	
	# get sitemap config fields too
	for fieldname in ("base_template_path", "template_path", "controller", "no_cache", "no_sitemap", 
		"page_name_field", "condition_field"):
		sitemap_options[fieldname] = sitemap_config.get(fieldname)
	
	# establish hierarchy
	sitemap_options.parents = webnotes.conn.sql("""select name, page_title from `tabWebsite Sitemap`
		where lft < %s and rgt > %s order by lft asc""", (sitemap_options.lft, sitemap_options.rgt), as_dict=True)

	sitemap_options.children = webnotes.conn.sql("""select * from `tabWebsite Sitemap`
		where parent_website_sitemap=%s""", (sitemap_options.page_name,), as_dict=True)
	
	# determine templates to be used
	if not sitemap_options.base_template_path:
		sitemap_options.base_template_path = "templates/base.html"
		
	return sitemap_options
开发者ID:bindscha,项目名称:wnframework_old,代码行数:28,代码来源:webutils.py

示例2: import_country_and_currency

def import_country_and_currency():
    from webnotes.country_info import get_all

    data = get_all()

    for name in data:
        country = webnotes._dict(data[name])
        webnotes.doc(
            {
                "doctype": "Country",
                "country_name": name,
                "date_format": country.date_format or "dd-mm-yyyy",
                "time_zones": "\n".join(country.timezones or []),
            }
        ).insert()

        if country.currency and not webnotes.conn.exists("Currency", country.currency):
            webnotes.doc(
                {
                    "doctype": "Currency",
                    "currency_name": country.currency,
                    "fraction": country.currency_fraction,
                    "symbol": country.currency_symbol,
                    "fraction_units": country.currency_fraction_units,
                    "number_format": country.number_format,
                }
            ).insert()
开发者ID:Jdfkat,项目名称:erpnext,代码行数:27,代码来源:install.py

示例3: update_patch_log

def update_patch_log(patchmodule):
	"""update patch_file in patch log"""	
	if webnotes.conn.table_exists("__PatchLog"):
		webnotes.conn.sql("""INSERT INTO `__PatchLog` VALUES (%s, now())""", \
			patchmodule)
	else:
		webnotes.doc({"doctype": "Patch Log", "patch": patchmodule}).insert()
开发者ID:IPenuelas,项目名称:wnframework,代码行数:7,代码来源:patch_handler.py

示例4: execute

def execute():
	webnotes.reload_doc("core", "doctype", "patch_log")
	if webnotes.conn.table_exists("__PatchLog"):
		for d in webnotes.conn.sql("""select patch from __PatchLog"""):
			webnotes.doc({
				"doctype": "Patch Log",
				"patch": d[0]
			}).insert()
	
		webnotes.conn.commit()
		webnotes.conn.sql("drop table __PatchLog")
开发者ID:BANSALJEE,项目名称:erpnext,代码行数:11,代码来源:change_patch_structure.py

示例5: add

def add(parent, role, permlevel):
	webnotes.doc(fielddata={
		"doctype":"DocPerm",
		"__islocal": 1,
		"parent": parent,
		"parenttype": "DocType",
		"parentfield": "permissions",
		"role": role,
		"permlevel": permlevel,
		"read": 1
	}).save()
	
	validate_and_reset(parent)
开发者ID:chrmorais,项目名称:wnframework,代码行数:13,代码来源:permission_manager.py

示例6: build_page

def build_page(page_name):
	if not webnotes.conn:
		webnotes.connect()

	sitemap_options = webnotes.doc("Website Sitemap", page_name).fields
	
	page_options = webnotes.doc("Website Sitemap Config", 
		sitemap_options.get("website_sitemap_config")).fields.update({
			"page_name":sitemap_options.page_name,
			"docname":sitemap_options.docname
		})
		
	if not page_options:
		raise PageNotFoundError
	else:
		page_options["page_name"] = page_name
	
	basepath = webnotes.utils.get_base_path()
	no_cache = page_options.get("no_cache")
	

	# if generator, then load bean, pass arguments
	if page_options.get("page_or_generator")=="Generator":
		doctype = page_options.get("ref_doctype")
		obj = webnotes.get_obj(doctype, page_options["docname"], with_children=True)

		if hasattr(obj, 'get_context'):
			obj.get_context()

		context = webnotes._dict(obj.doc.fields)
		context["obj"] = obj
	else:
		# page
		context = webnotes._dict({ 'name': page_name })
		if page_options.get("controller"):
			module = webnotes.get_module(page_options.get("controller"))
			if module and hasattr(module, "get_context"):
				context.update(module.get_context())
	
	context.update(get_website_settings())

	jenv = webnotes.get_jenv()
	context["base_template"] = jenv.get_template(webnotes.get_config().get("base_template"))
	
	template_name = page_options['template_path']	
	html = jenv.get_template(template_name).render(context)
	
	if not no_cache:
		webnotes.cache().set_value("page:" + page_name, html)
	return html
开发者ID:Halfnhav,项目名称:wnframework,代码行数:50,代码来源:webutils.py

示例7: add

def add(parent, role, permlevel):
	webnotes.only_for(("System Manager", "Administrator"))
	webnotes.doc(fielddata={
		"doctype":"DocPerm",
		"__islocal": 1,
		"parent": parent,
		"parenttype": "DocType",
		"parentfield": "permissions",
		"role": role,
		"permlevel": permlevel,
		"read": 1
	}).save()
	
	validate_and_reset(parent)
开发者ID:Halfnhav,项目名称:wnframework,代码行数:14,代码来源:permission_manager.py

示例8: get_context

	def get_context(self):
		import webnotes.utils
		import markdown2
		
		# this is for double precaution. usually it wont reach this code if not published
		if not webnotes.utils.cint(self.doc.published):
			raise Exception, "This blog has not been published yet!"
		
		# temp fields
		from webnotes.utils import global_date_format, get_fullname
		self.doc.full_name = get_fullname(self.doc.owner)
		self.doc.updated = global_date_format(self.doc.published_on)
		
		if self.doc.blogger:
			self.doc.blogger_info = webnotes.doc("Blogger", self.doc.blogger).fields
		
		self.doc.description = self.doc.blog_intro or self.doc.content[:140]
		self.doc.meta_description = self.doc.description
		
		self.doc.categories = webnotes.conn.sql_list("select name from `tabBlog Category` order by name")
		
		self.doc.comment_list = webnotes.conn.sql("""\
			select comment, comment_by_fullname, creation
			from `tabComment` where comment_doctype="Blog Post"
			and comment_docname=%s order by creation""", self.doc.name, as_dict=1) or []
开发者ID:Halfnhav,项目名称:wnframework,代码行数:25,代码来源:blog_post.py

示例9: make_lead

def make_lead(d, real_name, email_id):
	lead = webnotes.doc("Lead")
	lead.lead_name = real_name or email_id
	lead.email_id = email_id
	lead.source = "Email"
	lead.save(1)
	return lead.name
开发者ID:v2gods,项目名称:wnframework,代码行数:7,代码来源:communication.py

示例10: validate_item

	def validate_item(self, item_code, row_num):
		from stock.utils import validate_end_of_life, validate_is_stock_item, \
			validate_cancelled_item

		# using try except to catch all validation msgs and display together

		try:
			item = webnotes.doc("Item", item_code)
			if not item:
				raise webnotes.ValidationError, (_("Item: {0} not found in the system").format(item_code))

			# end of life and stock item
			validate_end_of_life(item_code, item.end_of_life, verbose=0)
			validate_is_stock_item(item_code, item.is_stock_item, verbose=0)

			# item should not be serialized
			if item.has_serial_no == "Yes":
				raise webnotes.ValidationError, (_("Serialized item: {0} can not be managed \
					using Stock Reconciliation, use Stock Entry instead").format(item_code))

			# item managed batch-wise not allowed
			if item.has_batch_no == "Yes":
				raise webnotes.ValidationError, (_("Item: {0} managed batch-wise, can not be \
					reconciled using Stock Reconciliation, instead use Stock Entry").format(item_code))

			# docstatus should be < 2
			validate_cancelled_item(item_code, item.docstatus, verbose=0)

		except Exception, e:
			self.validation_messages.append(_("Row # ") + ("%d: " % (row_num)) + cstr(e))
开发者ID:aproxp,项目名称:erpnext,代码行数:30,代码来源:stock_reconciliation.py

示例11: boot_session

def boot_session(bootinfo):
	"""boot session - send website info if guest"""
	import webnotes
	import webnotes.model.doc
	
	bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
	bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings')

	if webnotes.session['user']=='Guest':
		bootinfo['website_menus'] = webnotes.conn.sql("""select label, url, custom_page, 
			parent_label, parentfield
			from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1)
		bootinfo['startup_code'] = \
			webnotes.conn.get_value('Website Settings', None, 'startup_code')
	else:	
		bootinfo['letter_heads'] = get_letter_heads()

		import webnotes.model.doctype
		bootinfo['notification_settings'] = webnotes.doc("Notification Control", 
			"Notification Control").get_values()
		
		bootinfo['modules_list'] = webnotes.conn.get_global('modules_list')
		
		# if no company, show a dialog box to create a new company
		bootinfo['setup_complete'] = webnotes.conn.sql("""select name from 
			tabCompany limit 1""") and 'Yes' or 'No'
		
		# load subscription info
		import conf
		for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
			if hasattr(conf, key): bootinfo[key] = getattr(conf, key)

		bootinfo['docs'] += webnotes.conn.sql("select name, default_currency from `tabCompany`", 
			as_dict=1, update={"doctype":":Company"})
开发者ID:hfeeki,项目名称:erpnext,代码行数:34,代码来源:event_handlers.py

示例12: prepare_template_args

	def prepare_template_args(self):
		import webnotes.utils
		
		# this is for double precaution. usually it wont reach this code if not published
		if not webnotes.utils.cint(self.doc.published):
			raise Exception, "This blog has not been published yet!"
		
		# temp fields
		from webnotes.utils import global_date_format, get_fullname
		self.doc.full_name = get_fullname(self.doc.owner)
		self.doc.updated = global_date_format(self.doc.published_on)
		self.doc.content_html = self.doc.content
		if self.doc.blogger:
			self.doc.blogger_info = webnotes.doc("Blogger", self.doc.blogger).fields
		
		self.doc.description = self.doc.blog_intro or self.doc.content[:140]
		
		self.doc.categories = webnotes.conn.sql_list("select name from `tabBlog Category` order by name")
		
		self.doc.texts = {
			"comments": _("Comments"),
			"first_comment": _("Be the first one to comment"),
			"add_comment": _("Add Comment"),
			"submit": _("Submit"),
			"all_posts_by": _("All posts by"),
		}

		comment_list = webnotes.conn.sql("""\
			select comment, comment_by_fullname, creation
			from `tabComment` where comment_doctype="Blog Post"
			and comment_docname=%s order by creation""", self.doc.name, as_dict=1)
		
		self.doc.comment_list = comment_list or []
		for comment in self.doc.comment_list:
			comment['comment_date'] = webnotes.utils.global_date_format(comment['creation'])
开发者ID:BillTheBest,项目名称:erpnext,代码行数:35,代码来源:blog_post.py

示例13: __init__

	def __init__(self, login=None, password=None, server=None, port=None, use_ssl=None):
		# get defaults from control panel
		try:
			es = webnotes.doc('Email Settings','Email Settings')
		except webnotes.DoesNotExistError:
			es = None
		
		self._sess = None
		if server:
			self.server = server
			self.port = port
			self.use_ssl = cint(use_ssl)
			self.login = login
			self.password = password
		elif es and es.outgoing_mail_server:
			self.server = es.outgoing_mail_server
			self.port = es.mail_port
			self.use_ssl = cint(es.use_ssl)
			self.login = es.mail_login
			self.password = es.mail_password
			self.always_use_login_id_as_sender = es.always_use_login_id_as_sender
		else:
			self.server = webnotes.conf.get("mail_server") or ""
			self.port = webnotes.conf.get("mail_port") or None
			self.use_ssl = cint(webnotes.conf.get("use_ssl") or 0)
			self.login = webnotes.conf.get("mail_login") or ""
			self.password = webnotes.conf.get("mail_password") or ""
开发者ID:bindscha,项目名称:wnframework_old,代码行数:27,代码来源:smtp.py

示例14: make

def make(doctype=None, name=None, content=None, subject=None, 
	sender=None, recipients=None, contact=None, lead=None, company=None, 
	communication_medium="Email", send_email=False, print_html=None,
	attachments='[]', send_me_a_copy=False, set_lead=True, date=None):
	# add to Communication
	sent_via = None
	
	d = webnotes.doc('Communication')
	d.subject = subject
	d.content = content
	d.sender = sender or webnotes.conn.get_value("Profile", webnotes.session.user, "email")
	d.recipients = recipients
	d.lead = lead
	d.contact = contact
	d.company = company
	if date:
		d.creation = date
	if doctype:
		sent_via = webnotes.get_obj(doctype, name)
		d.fields[doctype.replace(" ", "_").lower()] = name

	if set_lead:
		set_lead_and_contact(d)
	d.communication_medium = communication_medium
	if send_email:
		send_comm_email(d, name, sent_via, print_html, attachments, send_me_a_copy)
	d.save(1, ignore_fields=True)
开发者ID:appost,项目名称:wnframework,代码行数:27,代码来源:communication.py

示例15: import_core_docs

	def import_core_docs(self):
		install_docs = [
			{'doctype':'Module Def', 'name': 'Core', 'module_name':'Core'},

			# roles
			{'doctype':'Role', 'role_name': 'Administrator', 'name': 'Administrator'},
			{'doctype':'Role', 'role_name': 'All', 'name': 'All'},
			{'doctype':'Role', 'role_name': 'System Manager', 'name': 'System Manager'},
			{'doctype':'Role', 'role_name': 'Report Manager', 'name': 'Report Manager'},
			{'doctype':'Role', 'role_name': 'Guest', 'name': 'Guest'},

			# profiles
			{'doctype':'Profile', 'name':'Administrator', 'first_name':'Administrator', 
				'email':'[email protected]', 'enabled':1},
			{'doctype':'Profile', 'name':'Guest', 'first_name':'Guest',
				'email':'[email protected]', 'enabled':1},

			# userroles
			{'doctype':'UserRole', 'parent': 'Administrator', 'role': 'Administrator', 
				'parenttype':'Profile', 'parentfield':'user_roles'},
			{'doctype':'UserRole', 'parent': 'Guest', 'role': 'Guest', 
				'parenttype':'Profile', 'parentfield':'user_roles'}
		]
		
		webnotes.conn.begin()
		for d in install_docs:
			doc = webnotes.doc(fielddata=d)
			doc.insert()
		webnotes.conn.commit()
开发者ID:alvz,项目名称:wnframework,代码行数:29,代码来源:install.py


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