本文整理汇总了Python中webnotes.model.doc.Document.region方法的典型用法代码示例。如果您正苦于以下问题:Python Document.region方法的具体用法?Python Document.region怎么用?Python Document.region使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.region方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_visiting_schedule
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [as 别名]
def generate_visiting_schedule(self,bb,s,a,k):
j=0
d = datetime.date.today()
#n="delete from `tabSub Franchise Visiting Schedule` where region='"+cstr(self.doc.regions)+"' and visiting_date between '"+cstr(d)+"' and '"+cstr(bb)+"'"
#webnotes.conn.sql(n)
#webnotes.errprint(n)
if self.doc.visiting_frequency=='Weekely':
m = 7
j = 4 * cint(self.doc.frequency)
#j= 5
elif self.doc.visiting_frequency=='Forth Night':
#webnotes.errprint("hellooo")
m = 15
j = 2 * cint(self.doc.frequency)
#j= 2
elif self.doc.visiting_frequency=='One Month':
m = 30
j = 1 * cint(self.doc.frequency)
#j=1
#webnotes.errprint(j)
list1 = []
list1.append(self.doc.start_date)
dt=self.doc.start_date
#for j in range (0,j):
# date=add_days(getdate(dt),m)
# webnotes.errprint(date)
# if date <= bb:
# list1.append(date)
# dt=date
#webnotes.errprint(self.doc.start_date)
#webnotes.errprint(bb)
#webnotes.errprint(list1)
webnotes.errprint(j)
for j in range(0,j):
#webnotes.errprint("hii")
for ls in s:
#webnotes.errprint("hello")
for i in range(len(list1)):
#webnotes.errprint(k)
#webnotes.errprint(list1[i])
d=Document('Sub Franchise Visiting Schedule')
d.account_id=k
#webnotes.errprint(d.account_id)
d.region=self.doc.regions
d.device_id=a
d.sf_name=ls[0]
#visiting_date=list1[i]
d.save(new=1)
return ("Welcome..")
示例2: on_submit
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [as 别名]
def on_submit(self):
emp_no = webnotes.conn.sql("select max(employee_number) +1 from `tabEmployee`")
bb = (emp_no[0][0])
cc = cint(bb)
dd = cstr(cc)
if self.doc.status =='Approved':
d = Document('Employee')
d.employee_name=self.doc.recruiter_name
d.employee_number= dd
d.region='Ho'
d.salutation=self.doc.r_salutations
d.gender=self.doc.r_gender
d.date_of_joining=self.doc.posting_date
d.date_of_birth=self.doc.birth_date
d.company='Medsynaptic'
d.save()
示例3: create_customer
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [as 别名]
def create_customer(auth_key,name,mobile_number,email_id,datetime,version,_type='POST'):
login =[]
loginObj = {}
qr="select name from `tabauth keys` where auth_key="+auth_key
res=webnotes.conn.sql(qr)
if res:
qr1="select name from `tabCustomer Details` where customer_name="+name+" and phone_number="+mobile_number
rs=webnotes.conn.sql(qr1)
rgn=webnotes.conn.sql("select region from `tabFranchise` where contact_email='"+res[0][0]+"'")
if rs :
key={}
key['customer_id']=rs[0][0]
login.append(key)
loginObj['status']='200'
loginObj['customer']=login
return loginObj
else :
from webnotes.model.doc import Document
d = Document('Customer Details')
if len(name)>3:
d.customer_name=name[1:-1]
if len(email_id)>3:
d.customer_email=email_id[1:-1]
if len(mobile_number)>3:
d.phone_number=mobile_number[1:-1]
d.region=rgn[0][0]
d.save()
webnotes.conn.commit()
key={}
key['customer_id']=d.name
login.append(key)
loginObj['status']='200'
loginObj['customer']=login
return loginObj
else:
loginObj['status']='401'
return loginObj
示例4: schedule
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [as 别名]
def schedule(_type='POST'):
regn=webnotes.conn.sql("select name from `tabFranchise Visiting Schedule` where name in (select distinct region from `tabFranchise`) and name in (select distinct region from `tabSub Franchise`)",as_list=1)
webnotes.errprint(regn)
for r in regn:
details=webnotes.conn.sql("select visiting_frequency,frequency,start_date from `tabFranchise Visiting Schedule` where name='"+r[0]+"'",as_list=1)
k=webnotes.conn.sql("select account_id from `tabFranchise` where region='"+r[0]+"'",as_list=1)
s=webnotes.conn.sql("select sf_name from `tabSub Franchise` where region='"+r[0]+"'",as_list=1)
bb=get_last_day(details[0][2])
j=0
from webnotes.utils import nowdate
dd = nowdate()
if details[0][0]=='Weekly':
m = 4
j = m * cint(details[0][1])
elif details[0][0]=='Fortnightly':
m = 2
j = m * cint(details[0][1])
elif details[0][0]=='Monthly':
m = 1
j = m * cint(details[0][1])
list1 = []
list1.append(details[0][2])
dt=details[0][2]
for j in range(0,j):
for ls in s:
for i in range(len(list1)):
d=Document('Sub Franchise Visiting Schedule')
d.account_id=k[0][0]
d.region=r[0]
d.sf_name=ls[0]
if details[0][0]=='Weekly':
d.weekly=details[0][1]
elif details[0][0]=='Fortnightly':
d.forth_nightly=details[0][1]
elif details[0][0]=='Monthly':
d.monthly=details[0][1]
d.save()
webnotes.conn.commit()
webnotes.errprint("Done")
示例5: generate_visiting_schedule
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [as 别名]
def generate_visiting_schedule(self,bb,s,a,k):
j=0
d = datetime.date.today()
if self.doc.visiting_frequency=='Weekely':
m = 7
j = 4 * cint(self.doc.frequency)
elif self.doc.visiting_frequency=='Fortnightly':
m = 15
j = 2 * cint(self.doc.frequency)
elif self.doc.visiting_frequency=='Monthly':
m = 30
j = 1 * cint(self.doc.frequency)
list1 = []
list1.append(self.doc.start_date)
dt=self.doc.start_date
#webnotes.errprint(j)
for j in range(0,j):
for ls in s:
for i in range(len(list1)):
#webnotes.errprint("generation")
d=Document('Sub Franchise Visiting Schedule')
d.account_id=k
d.region=self.doc.regions
d.device_id=a
d.sf_name=ls[0]
if self.doc.visiting_frequency=='Weekely':
#webnotes.errprint("Weekely")
d.weekly=self.doc.frequency
elif self.doc.visiting_frequency=='Fortnightly':
#webnotes.errprint("Fortnightly")
d.forth_nightly=self.doc.frequency
elif self.doc.visiting_frequency=='Monthly':
#webnotes.errprint("Monthly")
d.monthly=self.doc.frequency
d.save(new=1)
return ("Welcome..")
示例6: create_subfranchise1
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [as 别名]
def create_subfranchise1(auth_key,name,address,map_location,mobile_number,email_id,datetime,version,_type='POST'):
login =[]
loginObj = {}
if len(auth_key[1:-1])<=0 or len(name[1:-1])<=0 or len(address[1:-1])<=0:
loginObj['status']='401'
loginObj['error']='Incomplete data to create sub- franchise, Please provide token no,name and address'
return loginObj
qr="select name from `tabauth keys` where auth_key="+auth_key
res=webnotes.conn.sql(qr)
if res:
zz=webnotes.conn.sql("select name from `tabSub Franchise` where name='"+name[1:-1]+"'")
if zz:
key={}
key['subfranchise_id']=zz and zz[0][0] or ''
login.append(key)
loginObj['status']='200'
loginObj['subfranchise']=login
return loginObj
else:
str='sent '
from webnotes.utils.email_lib import sendmail
import json,requests
url="http://maps.googleapis.com/maps/api/geocode/json?address="+address+"&sensor=true"
#return url
#webnotes.errprint(url)
r = requests.get(url)
data = json.loads(r.text)
#return data
e=''
sts=data['status']
if sts=='OK':
a=data['results']
b=a[0]
c=b['geometry']
e=c['location']
rig="select region from `tabFranchise` where contact_email='"+res[0][0]+"' order by creation desc limit 1"
rgn=webnotes.conn.sql(rig)
from webnotes.model.doc import Document
d = Document('Sub Franchise')
d.sf_name=name[1:-1]
d.creation=datetime[1:-1]
d.region=rgn and rgn[0][0] or ''
d.address=address[1:-1]
if len(e)>1:
d.lat=e['lat']
d.lon=e['lng']
if len(email_id)>3:
d.email=email_id[1:-1]
if len(mobile_number)>3:
d.c_number=mobile_number[1:-1]
d.save()
d1 = Document('Customer')
d1.customer_name=name[1:-1]+'-'+mobile_number[1:-1]
d1.territory=''
d1.account_id=''
d1.sf_name=''
d1.customer_type='Company'
d1.customer_group='Commercial'
d1.company='PowerCap'
d1.save(new=1)
if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")):
if not webnotes.conn.get_value("Account", {"master_type": "Customer","master_name": d1.name}) and not webnotes.conn.get_value("Account", {"master_name": d1.name}):
if not webnotes.conn.get_value("Stock Ledger Entry", {"Warehouse": d1.name}):
ac_bean = webnotes.bean({
"doctype": "Account",
'account_name': d1.name,
'parent_account': "Accounts Receivable - P",
'group_or_ledger':'Ledger',
'debit_or_credit':'Debit',
'company':"PowerCap",
"master_type": "Customer",
"master_name": d1.name,
"freeze_account": "No"
})
ac_bean.ignore_permissions = True
ac_bean.insert()
webnotes.conn.commit()
key={}
key['subfranchise_id']=d.name
login.append(key)
loginObj['status']='200'
loginObj['subfranchise']=login
return loginObj
else:
loginObj['status']='401'
return loginObj
示例7: create_subfranchise
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [as 别名]
def create_subfranchise(auth_key,name,address,map_location,mobile_number,email_id,datetime,version,_type='POST'):
login =[]
loginObj = {}
if len(auth_key[1:-1])<=0 or len(name[1:-1])<=0 or len(address[1:-1])<=0:
loginObj['status']='401'
loginObj['error']='Incomplete data to create sub- franchise, Please provide token no,name and address'
return loginObj
qr="select name from `tabauth keys` where auth_key="+auth_key
res=webnotes.conn.sql(qr)
if res:
zz=webnotes.conn.sql("select name from `tabSub Franchise` where name='"+name[1:-1]+"'")
if zz:
key={}
key['subfranchise_id']=zz and zz[0][0] or ''
login.append(key)
loginObj['status']='200'
loginObj['subfranchise']=login
return loginObj
else:
str='sent '
from webnotes.utils.email_lib import sendmail
import json,requests
url="http://maps.googleapis.com/maps/api/geocode/json?address="+address+"&sensor=true"
#return url
#webnotes.errprint(url)
r = requests.get(url)
data = json.loads(r.text)
#return data
e=''
sts=data['status']
if sts=='OK':
a=data['results']
b=a[0]
c=b['geometry']
e=c['location']
rig="select region from `tabFranchise` where contact_email='"+res[0][0]+"' order by creation desc limit 1"
rgn=webnotes.conn.sql(rig)
from webnotes.model.doc import Document
d = Document('Sub Franchise')
d.sf_name=name[1:-1]
d.creation=datetime[1:-1]
d.region=rgn and rgn[0][0] or ''
d.address=address[1:-1]
if len(e)>1:
d.lat=e['lat']
d.lon=e['lng']
if len(email_id)>3:
d.email=email_id[1:-1]
if len(mobile_number)>3:
d.c_number=mobile_number[1:-1]
d.save()
key={}
key['subfranchise_id']=d.name
login.append(key)
loginObj['status']='200'
loginObj['subfranchise']=login
return loginObj
else:
loginObj['status']='401'
return loginObj
示例8: create_invoice
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [as 别名]
def create_invoice(auth_key,invoice_type,customer,serial_number,dattime,_type='POST'):
login =[]
loginObj = {}
if len(auth_key[1:-1])<=0 or len(dattime[1:-1])<=0 or len(customer[1:-1])<=0 or len(serial_number[1:-1])<=0 :
loginObj['status']='401'
loginObj['error']='Incomplete data to generate Sales Invoice , Please provide token no , Datetime,customer and serial no'
return loginObj
qr="select name from `tabauth keys` where auth_key="+auth_key
res=webnotes.conn.sql(qr)
rgn=webnotes.conn.sql("select region from `tabFranchise` where contact_email='"+res[0][0]+"'")
zz=serial_number[1:-1].count(' ')
xx=serial_number[1:-1].replace('[','').split(' ')
#xxx=xx.replace(' ','\n')
yy="select item_code,item_name,description from `tabSerial No` where name='"+cstr(xx[0])+"'"
zzz=webnotes.conn.sql(yy)
if not zzz:
loginObj['status']='402'
loginObj['error']='Invalid serails no, please try againg'
return loginObj
pp="select ref_rate from `tabItem Price` where price_list='Standard Selling' and item_code='"+zzz[0][0]+"'"
ppp=webnotes.conn.sql(pp)
if res:
from webnotes.model.doc import Document
d = Document('Sales Invoice')
d.customer=customer[1:-1]
d.customer_name=customer[1:-1]
d.region=rgn[0][0]
d.posting_date=dattime[1:-1]
d.due_date=dattime[1:-1]
d.selling_price_list='Standard Selling'
d.currency='INR'
d.territory='India'
if ppp:
d.net_total_export=ppp[0][0]*zz
d.grand_total_export=ppp[0][0]*zz
d.rounded_total_export=ppp[0][0]*zz
d.outstanding_amount=ppp[0][0]*zz
d.plc_conversion_rate=1
from webnotes.utils import nowdate
from accounts.utils import get_fiscal_year
today = nowdate()
d.fiscal_year=get_fiscal_year(today)[0]
d.debit_to=customer[1:-1]+" - P"
d.is_pos=1
d.cash_bank_account='Cash - P'
d.save()
webnotes.conn.commit()
e=Document('Sales Invoice Item')
e.item_code=zzz[0][0]
e.item_name=zzz[0][1]
e.description=zzz[0][2]
e.qty=zz
e.stock_uom='Nos'
if ppp:
e.ref_rate=ppp[0][0]
e.export_rate=ppp[0][0]
e.export_amount='0'
e.income_account='Sales - P'
e.cost_center='Main - P'
e.serial_no_=serial_number[1:-1].replace('[','').replace(']','')
e.parent=d.name
e.parenttype='Sales Invoice'
e.parentfield='entries'
e.save()
webnotes.conn.commit()
key={}
key['invoice_id_id']=d.name
login.append(key)
loginObj['status']='200'
loginObj['invoice']=login
return loginObj
else:
loginObj['status']='401'
loginObj['error']='invalid token please contact administrator'
return loginObj
示例9: create_in
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [as 别名]
def create_in(data,_type='POST'):
from webnotes.model.doc import Document
from webnotes.utils import nowdate,add_months
data1=json.loads(data)
auth_key=data1['token']
invoice_type=data1['invoice_type']
customer=data1['customer']
dattime=data1['datetime']
item_details=data1['item_details']
login =[]
loginObj = {}
amt=0
qt=0
srl=''
cc=''
zz=''
#return data
if len(auth_key[1:-1]) <=0 or len(dattime[1:-1]) <=0 or len(customer[1:-1])<=0 :
loginObj['status']='401'
loginObj['error']='Incomplete data to generate Sales Invoice , Please provide token no , Datetime,customer and serial no'
return loginObj
for ff in item_details:
a=ff['barcode']
c="select item_code,warehouse from `tabSerial No` where name='"+a[:-1]+"'"
cc=webnotes.conn.sql(c)
#webnotes.errprint(c)
#webnotes.errprint(cc)
amt=cint(amt)+cint(ff['rate'])
qt+=1
srl+=a[:-2].replace(',','\n')
#return cc
if cc :
qr="select name from `tabauth keys` where auth_key='"+auth_key+"'"
#return qr
res=webnotes.conn.sql(qr)
if res :
rr="select region from `tabFranchise` where contact_email='"+res[0][0]+"'"
r1=webnotes.conn.sql(rr)
if r1[0][0]==cc[0][1] :
#webnotes.errprint("same")
pass
else:
#webnotes.errprint("different warehouse")
pass
zz+="'"+a[:-1].replace(',','')+"',"
else:
if invoice_type=='CUSTOMER':
l = Document('Customer Details',customer)
l.customer_name=customer
l.save()
webnotes.conn.commit()
for ll in item_details:
m = Document('Customer Data')
m.serial_no=a[:-1]
m.parent=l.name
m.parenttype='Customer Details'
m.parentfield='customer_data'
m.save(new=1)
webnotes.conn.commit()
qrt="select name from `tabauth keys` where auth_key='"+auth_key+"'"
res=webnotes.conn.sql(qrt)
net=0
if res:
a="select name from tabCustomer where name='"+customer+"'"
b=webnotes.conn.sql(a)
if b:
a=''
else:
d = Document('Customer')
d.customer_name=customer
d.name=customer
d.save(new=1)
webnotes.conn.commit()
qr="select name from `tabauth keys` where auth_key='"+auth_key+"'"
#webnotes.errprint(qr)
res=webnotes.conn.sql(qr)
rgn=''
if res :
rr="select region from `tabFranchise` where contact_email='"+res[0][0]+"'"
#webnotes.errprint(qr)
r1=webnotes.conn.sql(rr,as_list=1)
#webnotes.errprint(r1[0][0])
d = Document('Sales Invoice')
d.customer=customer
d.customer_name=customer
d.posting_date=dattime[1:-1]
d.due_date=dattime[1:-1]
d.remarks='Invalid QR code'
d.selling_price_list='Standard Selling'
d.currency='INR'
if r1:
d.territory=r1[0][0]
d.region=r1[0][0]
d.net_total_export=0
d.grand_total_export=0
d.rounded_total_export=0
d.plc_conversion_rate=1
from webnotes.utils import nowdate
#.........这里部分代码省略.........
示例10: profile_ceation
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import region [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)
dv1=Document('DefaultValue')
dv1.parent=self.doc.contact_email
dv1.parentfield='system_defaults'
dv1.parenttype='Control Panel'
dv1.defkey='regions'
dv1.defvalue=self.doc.regions
dv1.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)
zz=webnotes.conn.sql("select accountID from Geozone where accountID='"+self.doc.account_id+"' and geozoneID='"+self.doc.region+"'",debug=1)
if not zz:
bb="INSERT INTO Geozone select '"+self.doc.account_id+"', geozoneID,sortID, minLatitude,maxLatitude,minLongitude,maxLongitude,zonePurposeID,reverseGeocode,arrivalZone,departureZone,autoNotify,zoomRegion,shapeColor,zoneType,radius,latitude1,longitude1,latitude2,longitude2,latitude3,longitude3,latitude4,longitude4,latitude5,longitude5,latitude6,longitude6,latitude7,longitude7,latitude8,longitude8,latitude9,longitude9,latitude10,longitude10,clientUpload,clientID,groupID,streetAddress,city,stateProvince,postalCode,country,subdivision,displayName,description,lastUpdateTime,creationTime from Geozone where accountID='sysadmin' and geozoneID='"+self.doc.region+"'"
webnotes.errprint (bb)
webnotes.conn.sql(bb)
#dvc="select groupID from DeviceList where accountID='"+self.doc.account_id+"'"
#webnotes.errprint(dvc)
#webnotes.conn.sql(dvc)
#if dvc:
# pass
#else:
dg=Document('Device Group')
dg.group_id=self.doc.region.lower()
dg.account_id=self.doc.account_id.lower()
dg.region=self.doc.region.lower()
dg.save(new=1)
self.doc.authorized_group=dg.name
#DEVICE List
dlist=webnotes.conn.sql("select groupID from DeviceList where deviceID='"+self.doc.device_id+"'")
webnotes.errprint(dlist)
if dlist:
pass
else:
dl="insert into DeviceList (accountID,groupID,deviceID) values('"+cstr(self.doc.account_id)+"','"+cstr(self.doc.authorized_group)+"','"+cstr(self.doc.device_id)+"')"
webnotes.conn.sql(dl)
webnotes.errprint(dl)
#GROUP List
glist=webnotes.conn.sql("select groupID from GroupList where accountID='"+cstr(self.doc.account_id)+"' and userID='"+cstr(self.doc.user_id)+"'")
webnotes.errprint(glist)
if glist:
pass
else:
gl="insert into GroupList (accountID,groupID,userID) values('"+cstr(self.doc.account_id)+"','"+cstr(self.doc.authorized_group)+"','"+cstr(self.doc.user_id)+"')"
webnotes.conn.sql(gl)
webnotes.errprint(gl)