本文整理汇总了Python中webnotes.get_doctype函数的典型用法代码示例。如果您正苦于以下问题:Python get_doctype函数的具体用法?Python get_doctype怎么用?Python get_doctype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_doctype函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_linked_docs
def get_linked_docs(doctype, name, metadata_loaded=None):
if not metadata_loaded: metadata_loaded = []
meta = webnotes.get_doctype(doctype, True)
linkinfo = meta[0].get("__linked_with")
results = {}
for dt, link in linkinfo.items():
link["doctype"] = dt
linkmeta = webnotes.get_doctype(dt, True)
if not linkmeta[0].get("issingle"):
fields = [d.fieldname for d in linkmeta.get({"parent":dt, "in_list_view":1})] \
+ ["name", "modified"]
fields = ["`tab{dt}`.`{fn}`".format(dt=dt, fn=sf.strip()) for sf in fields if sf]
if link.get("child_doctype"):
ret = webnotes.get_list(doctype=dt, fields=fields,
filters=[[link.get('child_doctype'), link.get("fieldname"), '=', name]])
else:
ret = webnotes.get_list(doctype=dt, fields=fields,
filters=[[dt, link.get("fieldname"), '=', name]])
if ret:
results[dt] = ret
if not dt in metadata_loaded:
if not "docs" in webnotes.local.response:
webnotes.local.response.docs = []
webnotes.local.response.docs += linkmeta
return results
开发者ID:miguelfontanes,项目名称:wnframework,代码行数:31,代码来源:utils.py
示例2: get_mapped_doclist
def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=[],
postprocess=None, ignore_permissions=False):
if isinstance(target_doclist, basestring):
target_doclist = json.loads(target_doclist)
source = webnotes.bean(from_doctype, from_docname)
if not ignore_permissions and not webnotes.has_permission(from_doctype, "read", source.doc):
webnotes.msgprint("No Permission", raise_exception=webnotes.PermissionError)
source_meta = webnotes.get_doctype(from_doctype)
target_meta = webnotes.get_doctype(table_maps[from_doctype]["doctype"])
# main
if target_doclist:
if isinstance(target_doclist[0], dict):
target_doc = webnotes.doc(fielddata=target_doclist[0])
else:
target_doc = target_doclist[0]
else:
target_doc = webnotes.new_doc(table_maps[from_doctype]["doctype"])
map_doc(source.doc, target_doc, table_maps[source.doc.doctype], source_meta, target_meta)
if target_doclist:
target_doclist[0] = target_doc
else:
target_doclist = [target_doc]
# children
for source_d in source.doclist[1:]:
table_map = table_maps.get(source_d.doctype)
if table_map:
if "condition" in table_map:
if not table_map["condition"](source_d):
continue
target_doctype = table_map["doctype"]
parentfield = target_meta.get({
"parent": target_doc.doctype,
"doctype": "DocField",
"fieldtype": "Table",
"options": target_doctype
})[0].fieldname
if table_map.get("add_if_empty") and row_exists_in_target(parentfield, target_doclist):
continue
target_d = webnotes.new_doc(target_doctype, target_doc, parentfield)
map_doc(source_d, target_d, table_map, source_meta, target_meta, source.doclist[0])
target_doclist.append(target_d)
target_doclist = webnotes.doclist(target_doclist)
if postprocess:
new_target_doclist = postprocess(source, target_doclist)
if new_target_doclist:
target_doclist = new_target_doclist
return target_doclist
开发者ID:frank1638,项目名称:wnframework,代码行数:58,代码来源:mapper.py
示例3: create_custom_field_for_workflow_state
def create_custom_field_for_workflow_state(self):
webnotes.clear_cache(doctype=self.doc.document_type)
doctypeobj = webnotes.get_doctype(self.doc.document_type)
if not len(doctypeobj.get({"doctype": "DocField", "fieldname": self.doc.workflow_state_field})):
# create custom field
webnotes.bean(
[
{
"doctype": "Custom Field",
"dt": self.doc.document_type,
"__islocal": 1,
"fieldname": self.doc.workflow_state_field,
"label": self.doc.workflow_state_field.replace("_", " ").title(),
"hidden": 1,
"fieldtype": "Link",
"options": "Workflow State",
# "insert_after": doctypeobj.get({"doctype":"DocField"})[-1].fieldname
}
]
).save()
webnotes.msgprint(
"Created Custom Field '%s' in '%s'" % (self.doc.workflow_state_field, self.doc.document_type)
)
开发者ID:jacara,项目名称:erpclone,代码行数:25,代码来源:workflow.py
示例4: get_query_result
def get_query_result(fields, dt, txt, searchfield, start, page_len, filters):
doctype = webnotes.get_doctype(dt)
enabled_condition = ""
if doctype.get({"parent":dt, "fieldname":"enabled", "fieldtype":"Check"}):
enabled_condition = " AND ifnull(`enabled`,0)=1 "
if doctype.get({"parent":dt, "fieldname":"disabled", "fieldtype":"Check"}):
enabled_condition = " AND ifnull(`disabled`,0)!=1"
filter_condition, filter_values = build_filter_conditions(filters)
args = {
'fields': fields,
'dt': dt,
'key': searchfield,
'txt': '%s',
'start': start,
'len': page_len,
'enabled_condition': enabled_condition,
'filter_condition': filter_condition
}
return webnotes.conn.sql("""select %(fields)s FROM `tab%(dt)s`
WHERE `%(key)s` LIKE %(txt)s
AND docstatus != 2 %(enabled_condition)s %(filter_condition)s
ORDER BY `%(key)s`
ASC LIMIT %(start)s, %(len)s""" % args,
tuple(["%%%s%%" % txt] + filter_values))
开发者ID:IPenuelas,项目名称:wnframework,代码行数:28,代码来源:search.py
示例5: get_defaults
def get_defaults(self, arg):
if isinstance(arg, basestring):
import json
arg = json.loads(arg)
match_key = arg["match"]
with_profiles = arg["profiles"]
pl = ol = []
# defaults
dl = [
a
for a in sql(
"select parent, ifnull(parenttype,'') as parenttype, ifnull(defvalue,'') as defvalue from tabDefaultValue where defkey=%s order by parenttype desc, parent asc",
match_key,
as_dict=1,
)
]
# options
tn = webnotes.get_doctype(arg["doctype"]).get_options(match_key)
# tn = sql("select options from tabDocField where fieldname=%s and fieldtype='Link' and docstatus=0 limit 1", match_key)[0][0]
ol = [""] + [a[0] for a in sql("select name from `tab%s` where ifnull(docstatus,0)=0" % tn)]
# roles
if with_profiles == "Yes":
# profiles
pl = [""] + [a[0] for a in sql("select name from tabProfile where ifnull(enabled,0)=1")]
return {"dl": dl, "pl": pl, "ol": ol}
开发者ID:gowrav-vishwakarma,项目名称:erpnext,代码行数:33,代码来源:permission_control.py
示例6: upload
def upload():
from webnotes.utils.datautils import read_csv_content_from_uploaded_file
from webnotes.modules import scrub
rows = read_csv_content_from_uploaded_file()
if not rows:
msg = [_("Please select a csv file")]
return {"messages": msg, "error": msg}
columns = [scrub(f) for f in rows[4]]
columns[0] = "name"
columns[3] = "att_date"
ret = []
error = False
from webnotes.utils.datautils import check_record, import_doc
doctype_dl = webnotes.get_doctype("Attendance")
for i, row in enumerate(rows[5:]):
if not row:
continue
row_idx = i + 5
d = webnotes._dict(zip(columns, row))
d["doctype"] = "Attendance"
if d.name:
d["docstatus"] = webnotes.conn.get_value("Attendance", d.name, "docstatus")
try:
check_record(d, doctype_dl=doctype_dl)
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
except Exception, e:
error = True
ret.append("Error for row (#%d) %s : %s" % (row_idx, len(row) > 1 and row[1] or "", cstr(e)))
webnotes.errprint(webnotes.getTraceback())
开发者ID:bindscha,项目名称:erpnext-fork,代码行数:34,代码来源:upload_attendance.py
示例7: update_completed_qty
def update_completed_qty(controller, caller_method):
if controller.doc.doctype == "Stock Entry":
material_request_map = {}
for d in controller.doclist.get({"parentfield": "mtn_details"}):
if d.material_request:
if d.material_request not in material_request_map:
material_request_map[d.material_request] = []
material_request_map[d.material_request].append(d.material_request_item)
for mr_name, mr_items in material_request_map.items():
mr_obj = webnotes.get_obj("Material Request", mr_name, with_children=1)
mr_doctype = webnotes.get_doctype("Material Request")
if mr_obj.doc.status in ["Stopped", "Cancelled"]:
msgprint(
_("Material Request")
+ ": %s, " % mr_obj.doc.name
+ _(mr_doctype.get_label("status"))
+ " = %s. " % _(mr_obj.doc.status)
+ _("Cannot continue."),
raise_exception=webnotes.InvalidStatusError,
)
_update_requested_qty(controller, mr_obj, mr_items)
# update ordered percentage and qty
mr_obj.update_completed_qty(mr_items)
开发者ID:bindscha,项目名称:erpnext-fork,代码行数:28,代码来源:material_request.py
示例8: has_permission
def has_permission(doctype, ptype="read", refdoc=None, verbose=True):
"""check if user has permission"""
if webnotes.conn.get_value("DocType", doctype, "istable")==1:
return True
meta = webnotes.get_doctype(doctype)
if ptype=="submit" and not cint(meta[0].is_submittable):
return False
if ptype=="import" and not cint(meta[0].allow_import):
return False
if webnotes.session.user=="Administrator":
return True
# get user permissions
if not get_user_perms(meta).get(ptype):
return False
if refdoc:
if isinstance(refdoc, basestring):
refdoc = webnotes.doc(meta[0].name, refdoc)
if not has_unrestricted_access(meta, refdoc, verbose=verbose):
return False
if not has_additional_permission(refdoc):
return False
return True
开发者ID:bindscha,项目名称:wnframework_old,代码行数:31,代码来源:permissions.py
示例9: validate_currency
def validate_currency(args, item, meta=None):
from webnotes.model.meta import get_field_precision
if not meta:
meta = webnotes.get_doctype(args.doctype)
# validate conversion rate
if meta.get_field("currency"):
validate_conversion_rate(args.currency, args.conversion_rate,
meta.get_label("conversion_rate"), args.company)
# round it
args.conversion_rate = flt(args.conversion_rate,
get_field_precision(meta.get_field("conversion_rate"),
webnotes._dict({"fields": args})))
# validate price list conversion rate
if meta.get_field("price_list_currency") and (args.selling_price_list or args.buying_price_list) \
and args.price_list_currency:
validate_conversion_rate(args.price_list_currency, args.plc_conversion_rate,
meta.get_label("plc_conversion_rate"), args.company)
# round it
args.plc_conversion_rate = flt(args.plc_conversion_rate,
get_field_precision(meta.get_field("plc_conversion_rate"),
webnotes._dict({"fields": args})))
开发者ID:rajatkapoor,项目名称:erpnext,代码行数:25,代码来源:transaction_base.py
示例10: execute
def execute():
webnotes.reload_doc("hr", "doctype", "leave_application")
if not webnotes.get_doctype("Leave Application").get({"doctype": "DocField",
"parent": "Leave Application", "permlevel": 2}):
webnotes.conn.sql("""update `tabDocPerm` set permlevel=1
where parent="Leave Application" and permlevel=2""")
开发者ID:Anirudh887,项目名称:erpnext,代码行数:7,代码来源:p05_leave_application.py
示例11: get_default_account
def get_default_account(self, account_for):
account = webnotes.conn.get_value("Company", self.doc.company, account_for)
if not account:
msgprint(_("Please mention default account for '") +
_(webnotes.get_doctype("company").get_label(account_for) +
_("' in Company: ") + self.doc.company), raise_exception=True)
return account
开发者ID:PhamThoTam,项目名称:erpnext,代码行数:8,代码来源:accounts_controller.py
示例12: test_doclist
def test_doclist(self):
p_meta = webnotes.get_doctype("Profile")
self.assertEquals(len(p_meta.get({"doctype": "DocField", "parent": "Profile", "fieldname": "first_name"})), 1)
self.assertEquals(len(p_meta.get({"doctype": "DocField", "parent": "Profile", "fieldname": "^first"})), 1)
self.assertEquals(len(p_meta.get({"fieldname": ["!=", "first_name"]})), len(p_meta) - 1)
self.assertEquals(len(p_meta.get({"fieldname": ["in", ["first_name", "last_name"]]})), 2)
self.assertEquals(len(p_meta.get({"fieldname": ["not in", ["first_name", "last_name"]]})), len(p_meta) - 2)
开发者ID:appost,项目名称:wnframework,代码行数:8,代码来源:test_profile.py
示例13: get_item_details
def get_item_details(args):
"""
args = {
"item_code": "",
"warehouse": None,
"customer": "",
"conversion_rate": 1.0,
"selling_price_list": None,
"price_list_currency": None,
"plc_conversion_rate": 1.0
}
"""
if isinstance(args, basestring):
args = json.loads(args)
args = webnotes._dict(args)
if args.barcode:
args.item_code = _get_item_code(barcode=args.barcode)
elif not args.item_code and args.serial_no:
args.item_code = _get_item_code(serial_no=args.serial_no)
item_bean = webnotes.bean("Item", args.item_code)
_validate_item_details(args, item_bean.doc)
meta = webnotes.get_doctype(args.doctype)
# hack! for Sales Order Item
warehouse_fieldname = "warehouse"
if meta.get_field("reserved_warehouse", parentfield=args.parentfield):
warehouse_fieldname = "reserved_warehouse"
out = _get_basic_details(args, item_bean, warehouse_fieldname)
if meta.get_field("currency"):
out.base_ref_rate = out.basic_rate = out.ref_rate = out.export_rate = 0.0
if args.selling_price_list and args.price_list_currency:
out.update(_get_price_list_rate(args, item_bean, meta))
out.update(_get_item_discount(out.item_group, args.customer))
if out.get(warehouse_fieldname):
out.update(get_available_qty(args.item_code, out.get(warehouse_fieldname)))
out.customer_item_code = _get_customer_item_code(args, item_bean)
if cint(args.is_pos):
pos_settings = get_pos_settings(args.company)
if pos_settings:
out.update(apply_pos_settings(pos_settings, out))
if args.doctype in ("Sales Invoice", "Delivery Note"):
if item_bean.doc.has_serial_no == "Yes" and not args.serial_no:
out.serial_no = _get_serial_nos_by_fifo(args, item_bean)
return out
开发者ID:gangadhar-kadam,项目名称:powapp,代码行数:58,代码来源:__init__.py
示例14: print_mandatory_fields
def print_mandatory_fields(doctype):
print "Please setup make_test_records for: " + doctype
print "-" * 60
doctype_obj = webnotes.get_doctype(doctype)
print "Autoname: " + (doctype_obj[0].autoname or "")
print "Mandatory Fields: "
for d in doctype_obj.get({"reqd":1}):
print d.parent + ":" + d.fieldname + " | " + d.fieldtype + " | " + (d.options or "")
print
开发者ID:appost,项目名称:wnframework,代码行数:9,代码来源:test_runner.py
示例15: get_stock_in_hand_account
def get_stock_in_hand_account(self):
stock_in_hand_account = webnotes.conn.get_value("Company", self.doc.company, "stock_in_hand_account")
if not stock_in_hand_account:
msgprint(_("Missing") + ": "
+ _(webnotes.get_doctype("company").get_label("stock_in_hand_account")
+ " " + _("for Company") + " " + self.doc.company), raise_exception=True)
return stock_in_hand_account
开发者ID:alvz,项目名称:erpnext,代码行数:9,代码来源:accounts_controller.py
示例16: get_company_default
def get_company_default(company, fieldname):
value = webnotes.conn.get_value("Company", company, fieldname)
if not value:
msgprint(_("Please mention default value for '") +
_(webnotes.get_doctype("company").get_label(fieldname) +
_("' in Company: ") + company), raise_exception=True)
return value
开发者ID:BillTheBest,项目名称:erpnext,代码行数:9,代码来源:utils.py
示例17: copy_common_fields
def copy_common_fields(from_doc, to_doc):
from webnotes.model import default_fields
doctype_list = webnotes.get_doctype(to_doc.doctype)
for fieldname, value in from_doc.fields.items():
if fieldname in default_fields:
continue
if doctype_list.get_field(fieldname) and to_doc.fields[fieldname] != value:
to_doc.fields[fieldname] = value
开发者ID:appost,项目名称:wnframework,代码行数:10,代码来源:doc.py
示例18: get_new_doc
def get_new_doc(doctype, parent_doc = None, parentfield = None):
doc = webnotes.doc({
"doctype": doctype,
"__islocal": 1,
"owner": webnotes.session.user,
"docstatus": 0
})
meta = webnotes.get_doctype(doctype)
restrictions = webnotes.defaults.get_restrictions()
if parent_doc:
doc.parent = parent_doc.name
doc.parenttype = parent_doc.doctype
if parentfield:
doc.parentfield = parentfield
for d in meta.get({"doctype":"DocField", "parent": doctype}):
default = webnotes.defaults.get_user_default(d.fieldname)
if (d.fieldtype=="Link") and d.ignore_restrictions != 1 and (d.options in restrictions)\
and len(restrictions[d.options])==1:
doc.fields[d.fieldname] = restrictions[d.options][0]
elif default:
doc.fields[d.fieldname] = default
elif d.fields.get("default"):
if d.default == "__user":
doc.fields[d.fieldname] = webnotes.session.user
elif d.default == "Today":
doc.fields[d.fieldname] = nowdate()
elif d.default.startswith(":"):
ref_fieldname = d.default[1:].lower().replace(" ", "_")
if parent_doc:
ref_docname = parent_doc.fields[ref_fieldname]
else:
ref_docname = webnotes.conn.get_default(ref_fieldname)
doc.fields[d.fieldname] = webnotes.conn.get_value(d.default[1:],
ref_docname, d.fieldname)
else:
doc.fields[d.fieldname] = d.default
# convert type of default
if d.fieldtype in ("Int", "Check"):
doc.fields[d.fieldname] = cint(doc.fields[d.fieldname])
elif d.fieldtype in ("Float", "Currency"):
doc.fields[d.fieldname] = flt(doc.fields[d.fieldname])
elif d.fieldtype == "Time":
doc.fields[d.fieldname] = nowtime()
return doc
开发者ID:bindscha,项目名称:wnframework_old,代码行数:55,代码来源:create_new.py
示例19: validate_restrictions
def validate_restrictions(self):
if self.ignore_restrictions:
return
has_restricted_data = False
for d in self.doclist:
if not webnotes.permissions.has_unrestricted_access(webnotes.get_doctype(d.doctype), d):
has_restricted_data = True
if has_restricted_data:
raise BeanPermissionError
开发者ID:bindscha,项目名称:wnframework_old,代码行数:11,代码来源:bean.py
示例20: can_restrict_user
def can_restrict_user(user, doctype, docname=None):
if not can_restrict(doctype, docname):
return False
meta = webnotes.get_doctype(doctype)
# check if target user does not have restrict permission
if has_only_non_restrict_role(meta, user):
return True
return False
开发者ID:bindscha,项目名称:wnframework_old,代码行数:11,代码来源:permissions.py
注:本文中的webnotes.get_doctype函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论