本文整理汇总了Python中webnotes.doclist函数的典型用法代码示例。如果您正苦于以下问题:Python doclist函数的具体用法?Python doclist怎么用?Python doclist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了doclist函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_doclist
def set_doclist(self, docs):
for i, d in enumerate(docs):
if isinstance(d, dict):
docs[i] = Document(fielddata=d)
self.docs = self.doclist = webnotes.doclist(docs)
self.doc, self.children = docs[0], webnotes.doclist(docs[1:])
if self.obj:
self.obj.doclist = self.doclist
self.obj.doc = self.doc
示例2: add_communication_list
def add_communication_list(self):
# remove communications if present
self.doclist = webnotes.doclist(self.doclist).get({"doctype": ["!=", "Communcation"]})
comm_list = webnotes.conn.sql("""select * from tabCommunication
where support_ticket=%s order by modified desc limit 20""", self.doc.name, as_dict=1)
[d.update({"doctype":"Communication"}) for d in comm_list]
self.doclist.extend(webnotes.doclist([webnotes.doc(fielddata=d) \
for d in comm_list]))
示例3: add_communication_list
def add_communication_list(self):
# remove communications if present
self.doclist = webnotes.doclist(self.doclist).get({
"doctype": ["!=", "Communcation"]})
comm_list = webnotes.conn.sql("""select * from tabCommunication
where %s=%s order by modified desc limit 20""" \
% (self.doc.doctype.replace(" ", "_").lower(), "%s"),
self.doc.name, as_dict=1, update={"doctype":"Communication"})
self.doclist.extend(webnotes.doclist([webnotes.doc(fielddata=d) \
for d in comm_list]))
示例4: post
def post(self):
"""
Save diff between Customize Form Bean and DocType Bean as property setter entries
"""
if self.doc.doc_type:
from webnotes.model import doc
from webnotes.core.doctype.doctype.doctype import validate_fields_for_doctype
this_doclist = webnotes.doclist([self.doc] + self.doclist)
ref_doclist = self.get_ref_doclist()
dt_doclist = doc.get('DocType', self.doc.doc_type)
# get a list of property setter docs
self.idx_dirty = False
diff_list = self.diff(this_doclist, ref_doclist, dt_doclist)
if self.idx_dirty:
self.make_idx_property_setter(this_doclist, diff_list)
self.set_properties(diff_list)
validate_fields_for_doctype(self.doc.doc_type)
webnotes.clear_cache(doctype=self.doc.doc_type)
webnotes.msgprint("Updated")
示例5: make_test_objects
def make_test_objects(doctype, test_records, verbose=None):
records = []
for doclist in test_records:
if not "doctype" in doclist[0]:
doclist[0]["doctype"] = doctype
d = webnotes.bean((webnotes.doclist(doclist)).copy())
if webnotes.test_objects.get(d.doc.doctype):
# do not create test records, if already exists
return []
if has_field(d.doc.doctype, "naming_series"):
if not d.doc.naming_series:
d.doc.naming_series = "_T-" + d.doc.doctype + "-"
# submit if docstatus is set to 1 for test record
docstatus = d.doc.docstatus
d.doc.docstatus = 0
d.insert()
if docstatus == 1:
d.submit()
records.append(d.doc.name)
return records
示例6: load_from_db
def load_from_db(self, dt=None, dn=None, prefix="tab"):
"""
Load doclist from dt
"""
from webnotes.model.doc import getchildren
if not dt:
dt = self.doc.doctype
if not dn:
dn = self.doc.name
doc = Document(dt, dn, prefix=prefix)
# get all children types
tablefields = webnotes.model.meta.get_table_fields(dt)
# load chilren
doclist = webnotes.doclist([doc])
for t in tablefields:
doclist += getchildren(doc.name, t[0], t[1], dt, prefix=prefix)
self.set_doclist(doclist)
if dt == dn:
self.convert_type(self.doc)
示例7: 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
示例8: set_doclist
def set_doclist(self, doclist):
for i, d in enumerate(doclist):
if isinstance(d, dict):
doclist[i] = Document(fielddata=d)
self.doclist = webnotes.doclist(doclist)
self.doc = self.doclist[0]
if self.obj:
self.obj.doclist = self.doclist
self.obj.doc = self.doc
示例9: cleanup_raw_materials_supplied
def cleanup_raw_materials_supplied(self, parent_items, raw_material_table):
"""Remove all those child items which are no longer present in main item table"""
delete_list = []
for d in self.doclist.get({"parentfield": raw_material_table}):
if [d.main_item_code, d.reference_name] not in parent_items:
# mark for deletion from doclist
delete_list.append([d.main_item_code, d.reference_name])
# delete from doclist
self.doclist = webnotes.doclist(filter(lambda d: [d.main_item_code, d.reference_name]
not in delete_list, self.doclist))
示例10: get_ref_doclist
def get_ref_doclist(self):
"""
* Gets doclist of type self.doc.doc_type
* Applies property setter properties on the doclist
* returns the modified doclist
"""
from webnotes.model.doctype import get
ref_doclist = get(self.doc.doc_type)
ref_doclist = webnotes.doclist([ref_doclist[0]] + ref_doclist.get({"parent": self.doc.doc_type}))
return ref_doclist
示例11: cleanup_packing_list
def cleanup_packing_list(obj, parent_items):
"""Remove all those child items which are no longer present in main item table"""
delete_list = []
for d in obj.doclist.get({"parentfield": "packing_details"}):
if [d.parent_item, d.parent_detail_docname] not in parent_items:
# mark for deletion from doclist
delete_list.append([d.parent_item, d.parent_detail_docname])
if not delete_list:
return obj.doclist
# delete from doclist
obj.doclist = webnotes.doclist(filter(lambda d: [d.parent_item, d.parent_detail_docname]
not in delete_list, obj.doclist))
return obj.doclist
示例12: make_test_objects
def make_test_objects(doctype, test_records):
records = []
for doclist in test_records:
if not "doctype" in doclist[0]:
doclist[0]["doctype"] = doctype
d = webnotes.model_wrapper((webnotes.doclist(doclist)).copy())
if webnotes.test_objects.get(d.doc.doctype):
# do not create test records, if already exists
return []
if has_field(d.doc.doctype, "naming_series"):
if not d.doc.naming_series:
d.doc.naming_series = "_T-" + d.doc.doctype + "-"
d.insert()
records.append(d.doc.name)
return records
示例13: load_from_db
def load_from_db(self, dt=None, dn=None, prefix='tab'):
from webnotes.model.doc import Document, getchildren
if not dt: dt = self.doc.doctype
if not dn: dn = self.doc.name
doc = Document(dt, dn, prefix=prefix)
# get all children types
tablefields = webnotes.model.meta.get_table_fields(dt)
# load chilren
doclist = webnotes.doclist([doc,])
for t in tablefields:
doclist += getchildren(doc.name, t[0], t[1], dt, prefix=prefix)
self.set_doclist(doclist)
self.run_method("onload")
示例14: post
def post(self):
"""
Save diff between Customize Form ModelWrapper and DocType ModelWrapper as property setter entries
"""
if self.doc.doc_type:
from webnotes.model import doc
from core.doctype.doctype.doctype import validate_fields_for_doctype
this_doclist = webnotes.doclist([self.doc] + self.doclist)
ref_doclist = self.get_ref_doclist()
dt_doclist = doc.get('DocType', self.doc.doc_type)
# get a list of property setter docs
diff_list = self.diff(this_doclist, ref_doclist, dt_doclist)
self.set_properties(diff_list)
validate_fields_for_doctype(self.doc.doc_type)
webnotes.clear_cache(doctype=self.doc.doc_type)
示例15: make_purchase_order_based_on_supplier
def make_purchase_order_based_on_supplier(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
if target_doclist:
if isinstance(target_doclist, basestring):
import json
target_doclist = webnotes.doclist(json.loads(target_doclist))
target_doclist = target_doclist.get({"parentfield": ["!=", "po_details"]})
material_requests, supplier_items = get_material_requests_based_on_supplier(source_name)
def postprocess(source, target_doclist):
target_doclist[0].supplier = source_name
set_missing_values(source, target_doclist)
po_items = target_doclist.get({"parentfield": "po_details"})
target_doclist = target_doclist.get({"parentfield": ["!=", "po_details"]}) + \
[d for d in po_items
if d.fields.get("item_code") in supplier_items and d.fields.get("qty") > 0]
return target_doclist
for mr in material_requests:
target_doclist = get_mapped_doclist("Material Request", mr, {
"Material Request": {
"doctype": "Purchase Order",
},
"Material Request Item": {
"doctype": "Purchase Order Item",
"field_map": [
["name", "prevdoc_detail_docname"],
["parent", "prevdoc_docname"],
["parenttype", "prevdoc_doctype"],
["uom", "stock_uom"],
["uom", "uom"]
],
"postprocess": update_item
}
}, target_doclist, postprocess)
return [d.fields for d in target_doclist]