当前位置: 首页>>代码示例>>Python>>正文


Python Document.name方法代码示例

本文整理汇总了Python中webnotes.model.doc.Document.name方法的典型用法代码示例。如果您正苦于以下问题:Python Document.name方法的具体用法?Python Document.name怎么用?Python Document.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webnotes.model.doc.Document的用法示例。


在下文中一共展示了Document.name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: copy_doclist

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [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
开发者ID:ranjithtenz,项目名称:stable,代码行数:37,代码来源:doclist.py

示例2: clone

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [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
开发者ID:beliezer,项目名称:wnframework,代码行数:34,代码来源:doclist.py

示例3: create_account_record

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [as 别名]
def create_account_record(ac_name, newdb, domain=''):
	# update accounts
	import webnotes.db

	webnotes.conn = webnotes.db.Database(use_default = 1)
	
	if not webnotes.conn.in_transaction:
		webnotes.conn.sql("start transaction")

	if not webnotes.session:
		webnotes.session = {'user':'shell'}

	from webnotes.model.doc import Document
	
	ac = Document('Account')
	ac.ac_name = ac_name
	ac.db_name = newdb
	ac.name = newdb
	ac.save(1)
	
	# add domain
	if domain:
		acd = ac.addchild('account_domains','Account Domain',1)
		acd.domain = ac_name + '.' + domain
		acd.save(1)

	webnotes.conn.sql("commit")
开发者ID:ranjithtenz,项目名称:stable,代码行数:29,代码来源:setup.py

示例4: addchild

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [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
开发者ID:frank1638,项目名称:wnframework,代码行数:27,代码来源:doc.py

示例5: add_profile

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [as 别名]
def add_profile(email):
	from webnotes.utils import validate_email_add
	from webnotes.model.doc import Document
			
	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.enabled=1
		pr.user_type='System User'
		pr.save(1)
		from webnotes.model.code import get_obj
		pr_obj = get_obj(doc=pr)
		pr_obj.on_update()
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:29,代码来源:my_company.py

示例6: add_profile

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import 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))
开发者ID:calvinfroedge,项目名称:erpnext,代码行数:35,代码来源:my_company.py

示例7: create_new_item

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [as 别名]
 def create_new_item(self):
     i = Document("Item")
     i.item_code = self.doc.new_item_code
     i.item_name = self.doc.new_item_name
     i.name = i.item_code
     i.is_sales_item = "Yes"
     i.is_stock_item = "No"
     i.save(1)
开发者ID:nijil,项目名称:erpnext,代码行数:10,代码来源:sales_bom.py

示例8: create_login

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import 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.')
开发者ID:alvz,项目名称:erpnext,代码行数:60,代码来源:contact_control.py

示例9: create_login

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import 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.")
开发者ID:nijil,项目名称:erpnext,代码行数:60,代码来源:contact_control.py

示例10: create_email_digest

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [as 别名]
    def create_email_digest(self):
        """
			create a default weekly email digest
			* Weekly Digest
			* For all companies
			* Recipients: System Managers
			* Full content
			* Enabled by default
		"""
        import webnotes

        companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)

        from webnotes.profile import get_system_managers

        system_managers = get_system_managers()
        if not system_managers:
            return

        from webnotes.model.doc import Document

        for company in companies_list:
            if company and company[0]:
                edigest = Document("Email Digest")
                edigest.name = "Default Weekly Digest - " + company[0]
                edigest.company = company[0]
                edigest.frequency = "Weekly"
                edigest.recipient_list = "\n".join(system_managers)
                for f in [
                    "new_leads",
                    "new_enquiries",
                    "new_quotations",
                    "new_sales_orders",
                    "new_purchase_orders",
                    "new_transactions",
                    "payables",
                    "payments",
                    "expenses_booked",
                    "invoiced_amount",
                    "collections",
                    "income",
                    "bank_balance",
                    "stock_below_rl",
                    "income_year_to_date",
                    "enabled",
                ]:
                    edigest.fields[f] = 1
                exists = webnotes.conn.sql(
                    """\
					SELECT name FROM `tabEmail Digest`
					WHERE name = %s""",
                    edigest.name,
                )
                if (exists and exists[0]) and exists[0][0]:
                    continue
                else:
                    edigest.save(1)
开发者ID:bindscha,项目名称:erpnext-fork,代码行数:59,代码来源:setup_control.py

示例11: subscribe

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [as 别名]
def subscribe(arg):
	"""subscribe to blog (blog_subscriber)"""
	if webnotes.conn.sql("""select name from `tabBlog Subscriber` where name=%s""", arg):
		webnotes.msgprint("Already a subscriber. Thanks!")
	else:
		from webnotes.model.doc import Document
		d = Document('Blog Subscriber')
		d.name = arg
		d.save()
		webnotes.msgprint("Thank you for subscribing!")
开发者ID:NorrWing,项目名称:erpnext,代码行数:12,代码来源:blog.py

示例12: add_section_breaks_and_renum

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [as 别名]
	def add_section_breaks_and_renum(self):
		for d in self.in_doclist:
			if d.get('parentfield')=='fields':
				if d.get('fieldtype') in ('Section Break', 'Column Break', 'HTML'):
					tmp = Document(fielddata = d)
					tmp.fieldname = ''
					tmp.name = None
					tmp.save(1, ignore_fields = 1, check_links=0)
				else:
					webnotes.conn.sql("update tabDocField set idx=%s where %s=%s and parent=%s" % \
						('%s', d.get('fieldname') and 'fieldname' or 'label', '%s', '%s'), (d.get('idx'), d.get('fieldname') or d.get('label'), self.doc.name))
开发者ID:NorrWing,项目名称:wnframework,代码行数:13,代码来源:transfer.py

示例13: create_new_grp

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [as 别名]
 def create_new_grp(self,arg):
     arg = eval(arg)
     
     grp = Document('File Group')
     grp.group_name = arg['grp_nm']
     grp.parent_group = arg['parent_grp']
     grp.description = arg['desc']
     grp.name = arg['grp_nm']
     grp.save(1)
     msgprint('Created a New Group')
     return grp.name
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:13,代码来源:file_browser_control.py

示例14: copy_doclist

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import name [as 别名]
def copy_doclist(doclist, no_copy = []):
	"""
      Save & return a copy of the given doclist
      Pass fields that are not to be copied in `no_copy`
	"""

	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
开发者ID:Halfnhav,项目名称:wnframework,代码行数:40,代码来源:utils.py

示例15: add_profile

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import 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)
开发者ID:NorrWing,项目名称:erpnext,代码行数:51,代码来源:users.py


注:本文中的webnotes.model.doc.Document.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。