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


Python NestedSet.validate_if_child_exists方法代码示例

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


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

示例1: on_trash

# 需要导入模块: from frappe.utils.nestedset import NestedSet [as 别名]
# 或者: from frappe.utils.nestedset.NestedSet import validate_if_child_exists [as 别名]
	def on_trash(self):
		"""
			Trash accounts and cost centers for this company if no gl entry exists
		"""
		NestedSet.validate_if_child_exists(self)
		frappe.utils.nestedset.update_nsm(self)

		rec = frappe.db.sql("SELECT name from `tabGL Entry` where company = %s", self.name)
		if not rec:
			frappe.db.sql("""delete from `tabBudget Account`
				where exists(select name from tabBudget
					where name=`tabBudget Account`.parent and company = %s)""", self.name)

			for doctype in ["Account", "Cost Center", "Budget", "Party Account"]:
				frappe.db.sql("delete from `tab{0}` where company = %s".format(doctype), self.name)

		if not frappe.db.get_value("Stock Ledger Entry", {"company": self.name}):
			frappe.db.sql("""delete from `tabWarehouse` where company=%s""", self.name)

		frappe.defaults.clear_default("company", value=self.name)
		for doctype in ["Mode of Payment Account", "Item Default"]:
			frappe.db.sql("delete from `tab{0}` where company = %s".format(doctype), self.name)

		# clear default accounts, warehouses from item
		warehouses = frappe.db.sql_list("select name from tabWarehouse where company=%s", self.name)
		if warehouses:
			frappe.db.sql("""delete from `tabItem Reorder` where warehouse in (%s)"""
				% ', '.join(['%s']*len(warehouses)), tuple(warehouses))

		# reset default company
		frappe.db.sql("""update `tabSingles` set value=""
			where doctype='Global Defaults' and field='default_company'
			and value=%s""", self.name)

		# delete BOMs
		boms = frappe.db.sql_list("select name from tabBOM where company=%s", self.name)
		if boms:
			frappe.db.sql("delete from tabBOM where company=%s", self.name)
			for dt in ("BOM Operation", "BOM Item", "BOM Scrap Item", "BOM Explosion Item"):
				frappe.db.sql("delete from `tab%s` where parent in (%s)"""
					% (dt, ', '.join(['%s']*len(boms))), tuple(boms))

		frappe.db.sql("delete from tabEmployee where company=%s", self.name)
		frappe.db.sql("delete from tabDepartment where company=%s", self.name)
		frappe.db.sql("delete from `tabTax Withholding Account` where company=%s", self.name)

		frappe.db.sql("delete from `tabSales Taxes and Charges Template` where company=%s", self.name)
		frappe.db.sql("delete from `tabPurchase Taxes and Charges Template` where company=%s", self.name)
开发者ID:Aptronics,项目名称:erpnext,代码行数:50,代码来源:company.py

示例2: on_trash

# 需要导入模块: from frappe.utils.nestedset import NestedSet [as 别名]
# 或者: from frappe.utils.nestedset.NestedSet import validate_if_child_exists [as 别名]
	def on_trash(self):
		NestedSet.validate_if_child_exists(self)
		update_nsm(self)
		self.remove_ancestor_location_features()
开发者ID:Aptronics,项目名称:erpnext,代码行数:6,代码来源:location.py

示例3: on_trash

# 需要导入模块: from frappe.utils.nestedset import NestedSet [as 别名]
# 或者: from frappe.utils.nestedset.NestedSet import validate_if_child_exists [as 别名]
	def on_trash(self):
		NestedSet.validate_if_child_exists(self)
		frappe.utils.nestedset.update_nsm(self)
开发者ID:Aptronics,项目名称:erpnext,代码行数:5,代码来源:supplier_group.py


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