本文整理汇总了Python中webnotes.doc函数的典型用法代码示例。如果您正苦于以下问题:Python doc函数的具体用法?Python doc怎么用?Python doc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了doc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: set_defaults
def set_defaults(args):
# enable default currency
webnotes.conn.set_value("Currency", args.get("currency"), "enabled", 1)
global_defaults = webnotes.bean("Global Defaults", "Global Defaults")
global_defaults.doc.fields.update({
'current_fiscal_year': args.curr_fiscal_year,
'default_currency': args.get('currency'),
'default_company':args.get('company_name'),
'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"),
"float_precision": 3,
"is_active":1,
"max_users":5,
"country": args.get("country"),
"time_zone": args.get("time_zone")
})
global_defaults.save()
accounts_settings = webnotes.bean("Accounts Settings")
accounts_settings.doc.auto_accounting_for_stock = 1
accounts_settings.save()
stock_settings = webnotes.bean("Stock Settings")
stock_settings.doc.item_naming_by = "Item Code"
stock_settings.doc.valuation_method = "FIFO"
stock_settings.doc.stock_uom = "Nos"
stock_settings.doc.auto_indent = 1
stock_settings.save()
selling_settings = webnotes.bean("Selling Settings")
selling_settings.doc.cust_master_name = "Customer Name"
selling_settings.doc.so_required = "No"
selling_settings.doc.dn_required = "No"
selling_settings.save()
buying_settings = webnotes.bean("Buying Settings")
buying_settings.doc.supp_master_name = "Supplier Name"
buying_settings.doc.po_required = "No"
buying_settings.doc.pr_required = "No"
buying_settings.doc.maintain_same_rate = 1
buying_settings.save()
notification_control = webnotes.bean("Notification Control")
notification_control.doc.quotation = 1
notification_control.doc.sales_invoice = 1
notification_control.doc.purchase_order = 1
notification_control.save()
hr_settings = webnotes.bean("HR Settings")
hr_settings.doc.emp_created_by = "Naming Series"
hr_settings.save()
email_settings = webnotes.bean("Email Settings")
email_settings.doc.send_print_in_body_and_attachment = 1
email_settings.save()
# control panel
cp = webnotes.doc("Control Panel", "Control Panel")
cp.company_name = args["company_name"]
cp.save()
开发者ID:saurabh6790,项目名称:omn-app,代码行数:60,代码来源:setup_wizard.py
示例17: 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['letter_heads'] = get_letter_heads()
load_country_and_currency(bootinfo)
import webnotes.model.doctype
bootinfo['notification_settings'] = webnotes.doc("Notification Control",
"Notification Control").get_values()
# if no company, show a dialog box to create a new company
bootinfo["customer_count"] = webnotes.conn.sql("""select count(*) from tabCustomer""")[0][0]
if not bootinfo["customer_count"]:
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, cost_center
from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
开发者ID:shygoly,项目名称:erpnext,代码行数:32,代码来源:boot.py
示例18: get_pages
def get_pages(m):
import importlib
pages = webnotes.conn.sql_list("""select name from tabPage where module=%s""", m)
prefix = "docs.dev.modules." + m + ".page."
docs = {
"_icon": "file-alt",
"_label": "Pages",
"_toc": [prefix + d for d in pages]
}
for p in pages:
page = webnotes.doc("Page", p)
mydocs = docs[p] = {
"_label": page.title or p,
"_type": "page",
}
update_readme(mydocs, m, "page", p)
mydocs["_modified"] = page.modified
# controller
page_name = scrub(p)
try:
page_controller = importlib.import_module(scrub(m) + ".page." + page_name + "." + page_name)
inspect_object_and_update_docs(mydocs, page_controller)
except ImportError, e:
pass
开发者ID:rohitw1991,项目名称:latestadbwnf,代码行数:25,代码来源:documentation_tool.py
示例19: get_context
def get_context():
"""generate rss feed"""
host = get_request_site_address()
blog_list = webnotes.conn.sql("""\
select page_name as name, published_on, modified, title, content from `tabBlog Post`
where ifnull(published,0)=1
order by published_on desc limit 20""", as_dict=1)
for blog in blog_list:
blog.link = urllib.quote(host + '/' + blog.name + '.html')
blog.content = escape_html(blog.content or "")
if blog_list:
modified = max((blog['modified'] for blog in blog_list))
else:
modified = now()
ws = webnotes.doc('Website Settings', 'Website Settings')
context = {
'title': ws.title_prefix,
'description': ws.description or ((ws.title_prefix or "") + ' Blog'),
'modified': modified,
'items': blog_list,
'link': host + '/blog'
}
webnotes.response.content_type = "text/xml"
# print context
return context
开发者ID:ricardomomm,项目名称:wnframework,代码行数:33,代码来源:rss.py
示例20: make_lead
def make_lead(d, real_name):
lead = webnotes.doc("Lead")
lead.lead_name = real_name or d.sender
lead.email_id = d.sender
lead.source = "Email"
lead.save(1)
return lead.name
开发者ID:masums,项目名称:wnframework,代码行数:7,代码来源:communication.py
注:本文中的webnotes.doc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论