本文整理汇总了Python中webnotes.model.doc.Document.first_name方法的典型用法代码示例。如果您正苦于以下问题:Python Document.first_name方法的具体用法?Python Document.first_name怎么用?Python Document.first_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.first_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_lead_address_contact
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_lead_address_contact(self):
if self.doc.lead_name:
details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, phone, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1)
d = Document('Address')
d.address_line1 = details[0]['address_line1']
d.address_line2 = details[0]['address_line2']
d.city = details[0]['city']
d.country = details[0]['country']
d.pincode = details[0]['pincode']
d.state = details[0]['state']
d.fax = details[0]['fax']
d.email_id = details[0]['email_id']
d.phone = details[0]['phone']
d.customer = self.doc.name
d.customer_name = self.doc.customer_name
d.is_primary_address = 1
d.address_type = 'Office'
try:
d.save(1)
except NameError, e:
pass
c = Document('Contact')
c.first_name = details[0]['lead_name']
c.email_id = details[0]['email_id']
c.phone = details[0]['phone']
c.mobile_no = details[0]['mobile_no']
c.customer = self.doc.name
c.customer_name = self.doc.customer_name
c.is_primary_contact = 1
try:
c.save(1)
except NameError, e:
pass
示例2: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def add_profile(args):
from webnotes.utils import validate_email_add
from webnotes.model.doc import Document
email = args['user']
sql = webnotes.conn.sql
if not email:
email = webnotes.form_dict.get('user')
if not validate_email_add(email):
raise Exception
return 'Invalid Email Id'
if sql("select name from tabProfile where name = %s", email):
# exists, enable it
sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
webnotes.msgprint('Profile exists, enabled it')
else:
# does not exist, create it!
pr = Document('Profile')
pr.name = email
pr.email = email
pr.first_name = args.get('first_name')
pr.last_name = args.get('last_name')
pr.enabled = 1
pr.user_type = 'System User'
pr.save(1)
if args.get('password'):
sql("""
UPDATE tabProfile
SET password = PASSWORD(%s)
WHERE name = %s""", (args.get('password'), email))
示例3: profile_ceation
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [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)
示例4: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_profile(self, user_email, user_fname, user_lname):
pr = Document('Profile')
pr.first_name = user_fname
pr.last_name = user_lname
pr.name = pr.email = user_email
pr.enabled = 1
pr.save(1)
self.add_roles(pr)
示例5: create_login
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [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.')
示例6: create_login
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [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.")
示例7: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_profile(self, user_email, user_fname, user_lname, pwd=None):
pr = Document('Profile')
pr.first_name = user_fname
pr.last_name = user_lname
pr.name = pr.email = user_email
pr.enabled = 1
pr.save(1)
if pwd: webnotes.conn.sql("UPDATE `tabProfile` SET password=PASSWORD(%s) WHERE name=%s", (pwd, user_email))
self.add_roles(pr)
示例8: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_profile(usr, name):
d = Document("Profile")
d.owner = "Administrator"
d.email = usr
d.first_name = name
d.enabled = 1
d.creation = nowdate() + ' ' + nowtime()
d.user_type = "System User"
d.save(1)
示例9: create_contact
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_contact(self,name,args):
c=Document('Contact')
c.customer_name=args['Customer Name']
c.first_name=name
c.customer=name
c.email_id=args['Email Id']
c.phone=args['Phone Number']
c.is_primary_contact=1
c.save()
示例10: create_contact
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_contact(contact_details):
from webnotes.model.doc import Document
contact = Document("Contact")
contact.first_name = contact_details['first_name']
contact.email_id = contact_details['email_id']
contact.mobile_no = contact_details['mobile_no']
if contact_details['doc']=='Customer':
contact.customer=contact_details['link']
else:
contact.referrer_physician=contact_details['link']
contact.save()
示例11: create_patient
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_patient(first_name,last_name,gender,date_of_birth,mobile_no,email, branch):
# webnotes.errprint([first_name,last_name,gender,date_of_birth,mobile_no,email])
d = Document('Patient Register')
d.first_name = first_name
d.last_name = last_name
d.birth_date = date_of_birth
d.gender = gender
d.mobile = mobile_no
d.email = email
d.lab_branch = branch
d.save()
return d.name
示例12: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_profile(self, user_email, user_fname, user_lname, pwd=None):
pr = Document('Profile')
pr.first_name = user_fname
pr.last_name = user_lname
pr.name = pr.email = user_email
pr.enabled = 1
pr.save(1)
if pwd:
webnotes.conn.sql("""insert into __Auth (user, `password`)
values (%s, password(%s))
on duplicate key update `password`=password(%s)""",
(user_email, pwd, pwd))
add_all_roles_to(pr.name)
示例13: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def add_profile(args):
from webnotes.utils import validate_email_add, now
email = args['user']
sql = webnotes.conn.sql
# validate max number of users exceeded or not
import conf
if hasattr(conf, 'max_users'):
active_users = sql("""select count(*) from tabProfile
where ifnull(enabled, 0)=1 and docstatus<2
and name not in ('Administrator', 'Guest')""")[0][0]
if active_users >= conf.max_users and conf.max_users:
# same message as in users.js
webnotes.msgprint("""Alas! <br />\
You already have <b>%(active_users)s</b> active users, \
which is the maximum number that you are currently allowed to add. <br /><br /> \
So, to add more users, you can:<br /> \
1. <b>Upgrade to the unlimited users plan</b>, or<br /> \
2. <b>Disable one or more of your existing users and try again</b>""" \
% {'active_users': active_users}, raise_exception=1)
if not email:
email = webnotes.form_dict.get('user')
if not validate_email_add(email):
raise Exception
return 'Invalid Email Id'
if sql("select name from tabProfile where name = %s", email):
# exists, enable it
sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
webnotes.msgprint('Profile exists, enabled it with new password')
else:
# does not exist, create it!
pr = Document('Profile')
pr.name = email
pr.email = email
pr.first_name = args.get('first_name')
pr.last_name = args.get('last_name')
pr.enabled = 1
pr.user_type = 'System User'
pr.save(1)
if args.get('password'):
sql("""
UPDATE tabProfile
SET password = PASSWORD(%s), modified = %s
WHERE name = %s""", (args.get('password'), now, email))
send_welcome_mail(email, args)
示例14: create_p_contact
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_p_contact(self,nm,phn_no,email_id,mob_no,fax,cont_addr):
c1 = Document('Contact')
c1.first_name = nm
c1.contact_name = nm
c1.contact_no = phn_no
c1.email_id = email_id
c1.mobile_no = mob_no
c1.fax = fax
c1.contact_address = cont_addr
c1.is_primary_contact = 'Yes'
c1.is_customer =1
c1.customer = self.doc.name
c1.customer_name = self.doc.customer_name
c1.customer_address = self.doc.address
c1.customer_group = self.doc.customer_group
c1.save(1)
示例15: create_lead_address_contact
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import first_name [as 别名]
def create_lead_address_contact(self):
if self.doc.lead_name:
if not webnotes.conn.get_value("Address", {"lead": self.doc.lead_name, "customer": self.doc.customer}):
webnotes.conn.sql("""update `tabAddress` set customer=%s, customer_name=%s where lead=%s""",
(self.doc.name, self.doc.customer_name, self.doc.lead_name))
lead = webnotes.conn.get_value("Lead", self.doc.lead_name, ["lead_name", "email_id", "phone", "mobile_no"], as_dict=True)
c = Document('Contact')
c.first_name = lead.lead_name
c.email_id = lead.email_id
c.phone = lead.phone
c.mobile_no = lead.mobile_no
c.customer = self.doc.name
c.customer_name = self.doc.customer_name
c.is_primary_contact = 1
try:
c.save(1)
except NameError, e:
pass