本文整理汇总了Python中webnotes.model.doc.Document.parent方法的典型用法代码示例。如果您正苦于以下问题:Python Document.parent方法的具体用法?Python Document.parent怎么用?Python Document.parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.parent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: role_match_cond
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def role_match_cond(self):
ur=Document('UserRole')
ur.parent=self.doc.patient_online_id
ur.parentfield='user_roles'
ur.parenttype='Profile'
ur.role='Patient'
ur.save(new=1)
dv=Document('DefaultValue')
dv.parent=self.doc.patient_online_id
dv.parentfield='system_defaults'
dv.parenttype='Control Panel'
dv.defkey='patient'
dv.defvalue=self.doc.name
dv.save(new=1)
dv=Document('DefaultValue')
dv.parent=self.doc.patient_online_id
dv.parentfield='system_defaults'
dv.parenttype='Control Panel'
dv.defkey='patient_id'
dv.defvalue=self.doc.name
dv.save(new=1)
dv=Document("DefaultValue")
dv.parent = self.doc.patient_online_id
dv.parentfield = 'system_defaults'
dv.parenttype = 'Control Panel'
dv.defkey = 'global_id'
dv.defvalue = self.doc.name
dv.save(new=1)
示例2: on_update
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [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)
示例3: create_users
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def create_users(self):
"""
Create Administrator / Guest
"""
webnotes.conn.begin()
from webnotes.model.doc import Document
p = Document('Profile')
p.name = p.first_name = 'Administrator'
p.email = '[email protected]'
p.save(new = 1)
ur = Document('UserRole')
ur.parent = 'Administrator'
ur.role = 'Administrator'
ur.parenttype = 'Profile'
ur.parentfield = 'userroles'
p.enabled = 1
ur.save(1)
p = Document('Profile')
p.name = p.first_name = 'Guest'
p.email = '[email protected]'
p.enabled = 1
p.save(new = 1)
ur = Document('UserRole')
ur.parent = 'Guest'
ur.role = 'Guest'
ur.parenttype = 'Profile'
ur.parentfield = 'userroles'
ur.save(1)
webnotes.conn.commit()
示例4: make_bank_voucher
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def make_bank_voucher(self):
self.set_flag()
"""
get default bank account,default salary acount from company
"""
#amt = self.get_total_salary()
com = webnotes.conn.sql("""select default_bank_account, default_expense_account from `tabCompany`
where name = '%s'""" % self.doc.company,as_list=1)
if not com[0][0] or not com[0][1]:
msgprint("You can set Default Bank Account in Company master.")
if not self.doc.jv:
jv = Document('Journal Voucher')
jv.voucher_type = 'Bank Voucher'
jv.user_remark = 'Referrals Payment'
jv.fiscal_year = '2013-14'
jv.total_credit = jv.total_debit = self.doc.total_amount
jv.company = self.doc.company
jv.posting_date = nowdate()
jv.save()
jvd = Document('Journal Voucher Detail')
jvd.account = com and com[0][0] or ''
jvd.credit = self.doc.total_amount
jvd.parent = jv.name
jvd.save()
jvd1 = Document('Journal Voucher Detail')
jvd1.account = com and com[0][1] or ''
jvd1.debit = self.doc.total_amount
jvd1.parent = jv.name
jvd1.save()
self.doc.jv = jv.name
self.doc.save()
示例5: create_advance_entry
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def create_advance_entry(advance_amount, customer_name, debit_to, company):
jv = Document('Journal Voucher')
jv.voucher_type = 'Cash Voucher'
jv.user_remark = 'Advance Payment'
jv.fiscal_year = webnotes.conn.get_value('Global Defaults',None,'current_fiscal_year')
jv.user_remark = "Advance from patient %s"%customer_name
jv.remark = "User Remark : Advance from patient %s"%customer_name
jv.company = company
jv.posting_date = nowdate()
jv.docstatus=1
jv.save()
chld1 = Document('Journal Voucher Detail')
chld1.parent = jv.name
chld1.account = debit_to
chld1.cost_center = webnotes.conn.get_value('Company',company,'cost_center')
chld1.credit = advance_amount
chld1.is_advance = 'Yes'
chld1.save()
chld2 = Document('Journal Voucher Detail')
chld2.parent = jv.name
chld2.account = webnotes.conn.get_value('Company',company,'default_cash_account')
chld2.cost_center = webnotes.conn.get_value('Company',company,'cost_center')
chld2.debit = advance_amount
chld2.save()
create_gl_entry(jv.name, jv.user_remark, company)
示例6: profile_ceation
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def profile_ceation(self):
webnotes.errprint("creating profile_ceation")
ch=webnotes.conn.sql("select name from tabProfile where name like '%"+cstr(self.doc.contact_email)+"%'")
if ch:
pass
else :
pp=Document('Profile')
pp.email=self.doc.contact_email
pp.first_name=self.doc.contact_name
webnotes.errprint(self.doc.password)
pp.new_password=self.doc.password
pp.account_id=self.doc.name
pp.franchise_admin='1'
pp.enabled='1'
pp.save(new=1)
ur=Document('UserRole')
ur.parent=self.doc.contact_email
ur.parentfield='user_roles'
ur.parenttype='Profile'
ur.role='Franchise'
ur.save(new=1)
dv=Document('DefaultValue')
dv.parent=self.doc.contact_email
dv.parentfield='system_defaults'
dv.parenttype='Control Panel'
dv.defkey='region'
dv.defvalue=self.doc.region
dv.save(new=1)
aa="insert into __Auth(user,password) values('"+self.doc.contact_email+"',password('"+self.doc.password+"'))"
webnotes.errprint(aa)
webnotes.conn.sql(aa)
示例7: create_material_request
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def create_material_request(self,args):
mr=Document('Material Request')
mr.material_request_type='Purchase'
mr.naming_series='MREQ-'
mr.company='InnoWorth'
mr.transaction_date=nowdate()
mr.fiscal_year=webnotes.conn.get_value("Global Defaults", None, "current_fiscal_year")
mr.status='Submitted'
mr.docstatus=1
mr.save()
mrc=Document('Material Request Item')
mrc.parent=mr.name
mrc.item_code=args[0][0]
mrc.qty=args[0][1]
mrc.schedule_date=args[0][2]
mrc.docstatus=1
mrc.warehouse=args[0][3]
mrc.item_name=args[0][4]
mrc.uom=args[0][5]
mrc.description=args[0][6]
mrc.parentfield='indent_details'
mrc.parenttype='Material Request'
mrc.save()
child_data=[]
child_data.append([mrc.item_code,mrc.qty,mrc.schedule_date,mr.name,mrc.warehouse,mrc.item_name,mrc.uom,mrc.description,mrc.name,args[0][7]])
data=[]
data.append({"item_code":mrc.item_code,"so_qty":cstr(mrc.qty),"proj_qty":('+'+cstr(mrc.qty)),"warehouse":mrc.warehouse,"bin_iqty":"Bin.indented_qty","bin_pqty":"Bin.projected_qty","type":"po"})
self.update_bin(data)
import_amount=self.create_child_po(child_data)
return import_amount
示例8: copy_doclist
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [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
示例9: create_child_po
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def create_child_po(self,child_data):
sic=Document('Purchase Order Item')
sic.item_code=child_data[0][0]
sic.qty=child_data[0][1]
sic.stock_qty=child_data[0][1]
sic.schedule_date=child_data[0][2]
sic.prevdoc_docname=child_data[0][3]
sic.warehouse=child_data[0][4]
sic.item_name=child_data[0][5]
sic.uom=child_data[0][6]
sic.stock_uom=child_data[0][6]
sic.description=child_data[0][7]
sic.prevdoc_detail_docname=child_data[0][8]
sic.conversion_factor=1.0
sic.prevdoc_doctype='Material Request'
rate=webnotes.conn.sql("select ref_rate from `tabItem Price` where price_list='Standard Buying' and item_code='"+child_data[0][0]+"'",as_list=1)
if rate:
sic.import_ref_rate=rate[0][0]
sic.import_rate=rate[0][0]
else:
sic.import_ref_rate=1
sic.import_rate=1
if child_data[0][1]:
sic.import_amount=cstr(flt(sic.import_ref_rate)*flt(child_data[0][1]))
else:
sic.import_amount=sic.import_ref_rate
sic.parentfield='po_details'
sic.parenttype='Purchase Order'
sic.parent=child_data[0][9]
sic.save()
return sic.import_amount
示例10: update_prices
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def update_prices(self):
from webnotes.utils.datautils import read_csv_content_from_attached_file
data = read_csv_content_from_attached_file(self.doc)
webnotes.conn.auto_commit_on_many_writes = 1
updated = 0
for line in data:
if line and len(line)==3 and line[0]!='Item':
# if item exists
if webnotes.conn.sql("select name from tabItem where name=%s", line[0]):
if self.is_currency_valid(line[2]):
# if price exists
ref_ret_detail = webnotes.conn.sql("select name from `tabItem Price` where parent=%s and price_list_name=%s and ref_currency=%s", \
(line[0], self.doc.name, line[2]))
if ref_ret_detail:
webnotes.conn.sql("update `tabItem Price` set ref_rate=%s where name=%s", (line[1], ref_ret_detail[0][0]))
else:
d = Document('Item Price')
d.parent = line[0]
d.parentfield = 'ref_rate_details'
d.parenttype = 'Item'
d.price_list_name = self.doc.name
d.ref_rate = line[1]
d.ref_currency = line[2]
d.save(1)
updated += 1
else:
msgprint("[Ignored] Unknown currency '%s' for Item '%s'" % (line[2], line[0]))
else:
msgprint("[Ignored] Did not find Item '%s'" % line[1])
msgprint("<b>%s</b> items updated" % updated)
webnotes.conn.auto_commit_on_many_writes = 0
示例11: addchild
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def addchild(self, fieldname, childtype = '', doclist=None):
"""
Returns a child record of the give `childtype`.
* if local is set, it does not save the record
* if doclist is passed, it append the record to the doclist
"""
from webnotes.model.doc import Document
d = Document()
d.parent = self.name
d.parenttype = self.doctype
d.parentfield = fieldname
d.doctype = childtype
d.docstatus = 0;
d.name = ''
d.owner = webnotes.session['user']
d.fields['__islocal'] = 1 # for Client to identify unsaved doc
if doclist != None:
doclist.append(d)
if doclist:
d.idx = max([(d.idx or 0) for d in doclist if d.doctype==childtype]) + 1
return d
示例12: update_prices
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def update_prices(self):
import csv
data = csv.reader(self.get_csv_data().splitlines())
updated = 0
for line in data:
if len(line)==3:
# if item exists
if sql("select name from tabItem where name=%s", line[0]):
if self.is_currency_valid(line[2]):
# if price exists
ref_ret_detail = sql("select name from `tabRef Rate Detail` where parent=%s and price_list_name=%s and ref_currency=%s", \
(line[0], self.doc.name, line[2]))
if ref_ret_detail:
sql("update `tabRef Rate Detail` set ref_rate=%s where name=%s", (line[1], ref_ret_detail[0][0]))
else:
d = Document('Ref Rate Detail')
d.parent = line[0]
d.parentfield = 'ref_rate_details'
d.parenttype = 'Item'
d.price_list_name = self.doc.name
d.ref_rate = line[1]
d.ref_currency = line[2]
d.save(1)
updated += 1
else:
msgprint("[Ignored] Unknown currency '%s' for Item '%s'" % (line[2], line[0]))
else:
msgprint("[Ignored] Did not find Item '%s'" % line[1])
else:
msgprint("[Ignored] Incorrect format: %s" % str(line))
msgprint("<b>%s</b> items updated" % updated)
示例13: clone
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [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
示例14: add_guest_access_to_page
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def add_guest_access_to_page(page):
"""add Guest in Page Role"""
if not webnotes.conn.sql("""select parent from `tabPage Role`
where role='Guest' and parent=%s""", page):
d = Document('Page Role')
d.parent = page
d.role = 'Guest'
d.save()
示例15: create_document_level0
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parent [as 别名]
def create_document_level0(self):
#webnotes.errprint("in document")
c=Document('Employee Training Details')
c.test= 'Level 0 Completed'
c.is_pass= 1
c.level= self.doc.training_level
c.parent=self.doc.employee
c.save()