本文整理汇总了Python中webnotes.model.doc.Document.parenttype方法的典型用法代码示例。如果您正苦于以下问题:Python Document.parenttype方法的具体用法?Python Document.parenttype怎么用?Python Document.parenttype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.parenttype方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_update
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [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)
示例2: create_users
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [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()
示例3: role_match_cond
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [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)
示例4: profile_ceation
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [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)
示例5: addchild
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [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
示例6: update_prices
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [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
示例7: create_material_request
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [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: create_child_po
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [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
示例9: update_prices
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [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)
示例10: create_login
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [as 别名]
def create_login(self, arg):
arg = eval(arg)
cont_det = sql("select * from tabContact where name=%s", (arg["contact"]), as_dict=1)
if cont_det[0]["docstatus"] != 0:
msgprint("Please save the corresponding contact first")
raise Exception
if sql("select name from tabProfile where name=%s", cont_det[0]["email_id"]):
msgprint("Profile with same name already exist.")
raise Exception
else:
p = Document("Profile")
p.name = cont_det[0]["email_id"]
p.first_name = cont_det[0]["first_name"]
p.last_name = cont_det[0]["last_name"]
p.email = cont_det[0]["email_id"]
p.cell_no = cont_det[0]["contact_no"]
p.password = "password"
p.enabled = 1
p.user_type = "Partner"
p.save(1)
get_obj(doc=p).on_update()
role = []
if cont_det[0]["contact_type"] == "Individual":
role = ["Customer"]
else:
if cont_det[0]["is_customer"]:
role.append("Customer")
if cont_det[0]["is_supplier"]:
role.append("Supplier")
if cont_det[0]["is_sales_partner"]:
role.append("Partner")
if role:
prof_nm = p.name
for i in role:
r = Document("UserRole")
r.parent = p.name
r.role = i
r.parenttype = "Profile"
r.parentfield = "userroles"
r.save(1)
if i == "Customer":
def_keys = ["from_company", "customer_name", "customer"]
def_val = cont_det[0]["customer_name"]
self.set_default_val(def_keys, def_val, prof_nm)
if i == "Supplier":
def_keys = ["supplier_name", "supplier"]
def_val = cont_det[0]["supplier_name"]
self.set_default_val(def_keys, def_val, prof_nm)
sql("update tabContact set has_login = 'Yes' where name=%s", cont_det[0]["name"])
sql("update tabContact set disable_login = 'No' where name=%s", cont_det[0]["name"])
msgprint("User login is created.")
示例11: create_login
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [as 别名]
def create_login(self,arg):
arg = eval(arg)
cont_det = sql("select * from tabContact where name=%s",(arg['contact']),as_dict=1)
if cont_det[0]['docstatus'] !=0:
msgprint('Please save the corresponding contact first')
raise Exception
if sql("select name from tabProfile where name=%s",cont_det[0]['email_id']):
msgprint('Profile with same name already exist.')
raise Exception
else:
p = Document('Profile')
p.name = cont_det[0]['email_id']
p.first_name = cont_det[0]['first_name']
p.last_name = cont_det[0]['last_name']
p.email = cont_det[0]['email_id']
p.cell_no = cont_det[0]['contact_no']
p.password = 'password'
p.enabled = 1
p.user_type = 'Partner';
p.save(1)
get_obj(doc=p).on_update()
role = []
if cont_det[0]['contact_type'] == 'Individual':
role = ['Customer']
else:
if cont_det[0]['is_customer']:
role.append('Customer')
if cont_det[0]['is_supplier']:
role.append('Supplier')
if cont_det[0]['is_sales_partner']:
role.append('Partner')
if role:
prof_nm = p.name
for i in role:
r = Document('UserRole')
r.parent = p.name
r.role = i
r.parenttype = 'Profile'
r.parentfield = 'userroles'
r.save(1)
if i == 'Customer':
def_keys = ['from_company','customer_name','customer']
def_val = cont_det[0]['customer_name']
self.set_default_val(def_keys,def_val,prof_nm)
if i == 'Supplier':
def_keys = ['supplier_name','supplier']
def_val = cont_det[0]['supplier_name']
self.set_default_val(def_keys,def_val,prof_nm)
sql("update tabContact set has_login = 'Yes' where name=%s",cont_det[0]['name'])
sql("update tabContact set disable_login = 'No' where name=%s",cont_det[0]['name'])
msgprint('User login is created.')
示例12: import_core_module
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [as 别名]
def import_core_module(self):
"""
Imports the "Core" module from .txt file and creates
Creates profile Administrator
"""
from webnotes.modules.import_module import import_module
from webnotes.modules.module_manager import reload_doc
reload_doc("core", "doctype", "doctype")
reload_doc("core", "doctype", "docfield")
reload_doc("core", "doctype", "docperm")
import_module("core")
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()
示例13: set_default_val
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [as 别名]
def set_default_val(self,def_keys,def_val,prof_nm):
for d in def_keys:
kv = Document('DefaultValue')
kv.defkey = d
kv.defvalue = def_val
kv.parent = prof_nm
kv.parenttype = 'Profile'
kv.parentfield = 'defaults'
kv.save(1)
示例14: set_default_val
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [as 别名]
def set_default_val(self, def_keys, def_val, prof_nm):
for d in def_keys:
kv = Document("DefaultValue")
kv.defkey = d
kv.defvalue = def_val
kv.parent = prof_nm
kv.parenttype = "Profile"
kv.parentfield = "defaults"
kv.save(1)
示例15: add_default_home_page
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import parenttype [as 别名]
def add_default_home_page():
if not webnotes.conn.sql("""select name from `tabDefault Home Page`
where role='Guest' and home_page='Login Page'"""):
d = Document('Default Home Page')
d.parent = 'Control Panel'
d.parenttype = 'Control Panel'
d.parentfield = 'default_home_pages'
d.role = 'Guest'
d.home_page = 'Login Page'
d.save(1)