Exemple #1
0
	def on_update(self):
		NestedSet.on_update(self)
		if not frappe.db.sql("""select name from tabAccount
				where company=%s and docstatus<2 limit 1""", self.name):
			if not frappe.local.flags.ignore_chart_of_accounts:
				frappe.flags.country_change = True
				self.create_default_accounts()
				self.create_default_warehouses()

		if frappe.flags.country_change:
			install_country_fixtures(self.name)
			self.create_default_tax_template()

		if not frappe.db.get_value("Department", {"company": self.name}):
			from erpnext.setup.setup_wizard.operations.install_fixtures import install_post_company_fixtures
			install_post_company_fixtures(frappe._dict({'company_name': self.name}))

		if not frappe.db.get_value("Cost Center", {"is_group": 0, "company": self.name}):
			self.create_default_cost_center()

		if not frappe.local.flags.ignore_chart_of_accounts:
			self.set_default_accounts()
			if self.default_cash_account:
				self.set_mode_of_payment_account()

		if self.default_currency:
			frappe.db.set_value("Currency", self.default_currency, "enabled", 1)

		if hasattr(frappe.local, 'enable_perpetual_inventory') and \
			self.name in frappe.local.enable_perpetual_inventory:
			frappe.local.enable_perpetual_inventory[self.name] = self.enable_perpetual_inventory

		frappe.clear_cache()
Exemple #2
0
	def on_update(self):
		NestedSet.on_update(self)
		if not frappe.db.sql("""select name from tabAccount
				where company=%s and docstatus<2 limit 1""", self.name):
			if not frappe.local.flags.ignore_chart_of_accounts:
				frappe.flags.country_change = True
				self.create_default_accounts()
				self.create_default_warehouses()

		if frappe.flags.country_change:
			install_country_fixtures(self.name)
			self.create_default_tax_template()



		if not frappe.db.get_value("Department", {"company": self.name}):
			from erpnext.setup.setup_wizard.operations.install_fixtures import install_post_company_fixtures
			install_post_company_fixtures(frappe._dict({'company_name': self.name}))

		if not frappe.db.get_value("Cost Center", {"is_group": 0, "company": self.name}):
			self.create_default_cost_center()

		if not frappe.local.flags.ignore_chart_of_accounts:
			self.set_default_accounts()
			if self.default_cash_account:
				self.set_mode_of_payment_account()

		if self.default_currency:
			frappe.db.set_value("Currency", self.default_currency, "enabled", 1)

		if hasattr(frappe.local, 'enable_perpetual_inventory') and \
			self.name in frappe.local.enable_perpetual_inventory:
			frappe.local.enable_perpetual_inventory[self.name] = self.enable_perpetual_inventory

		frappe.clear_cache()
Exemple #3
0
    def on_trash(self):
        # clear from child table (sub procedures)
        frappe.db.sql(
            """update `tabQuality Procedure Process`
			set `procedure`='' where `procedure`=%s""",
            self.name,
        )
        NestedSet.on_trash(self, allow_root_deletion=True)
Exemple #4
0
    def on_update(self):
        NestedSet.on_update(self)
        if not frappe.db.sql(
                """SELECT
							name
						FROM
							tabAccount
						WHERE
							company=%s and docstatus<2 limit 1""", self.name):
            self.create_accounts()
        self.set_default_accounts()
Exemple #5
0
	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)

		# reset default company
		frappe.db.sql("""update `tabSingles` set value=""
			where doctype='Chart of Accounts Importer' and field='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)
Exemple #6
0
	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)
Exemple #7
0
	def on_update(self):
		NestedSet.on_update(self)
		WebsiteGenerator.on_update(self)
		invalidate_cache_for(self)
		self.validate_name_with_item()
		self.validate_one_root()
Exemple #8
0
	def after_rename(self, olddn, newdn, merge=False):
		NestedSet.after_rename(self, olddn, newdn, merge)
		WebsiteGenerator.after_rename(self, olddn, newdn, merge)
Exemple #9
0
 def on_trash(self):
     NestedSet.validate_if_child_exists(self)
     frappe.utils.nestedset.update_nsm(self)
Exemple #10
0
 def on_update(self):
     if not frappe.flags.in_rebuild_config:
         NestedSet.on_update(self)
     self.clear_cache()
Exemple #11
0
 def on_update(self):
     NestedSet.on_update(self)
     self.set_parent()
Exemple #12
0
	def on_trash(self):
		NestedSet.on_trash(self)
		WebsiteGenerator.on_trash(self)
		self.delete_child_item_groups_key()
Exemple #13
0
	def on_trash(self):
		NestedSet.validate_if_child_exists(self)
		frappe.utils.nestedset.update_nsm(self)
Exemple #14
0
 def on_update(self):
     WebsiteGenerator.on_update(self)
     NestedSet.on_update(self)
     clear_cache(website_group=self.name)
Exemple #15
0
 def on_update(self):
     if self.get_url() != self.name:
         self.rename()
     if not frappe.flags.in_sync_website:
         NestedSet.on_update(self)
     self.clear_cache()
Exemple #16
0
 def on_trash(self):
     NestedSet.validate_if_child_exists(self)
     update_nsm(self)
     self.remove_ancestor_location_features()
Exemple #17
0
 def on_update(self):
     # super(Location, self).on_update()
     NestedSet.on_update(self)
Exemple #18
0
	def on_trash(self):
		NestedSet.validate_if_child_exists(self)
		update_nsm(self)
		self.remove_ancestor_location_features()
Exemple #19
0
 def on_update(self):
     NestedSet.on_update(self)
     self.validate_one_root()
Exemple #20
0
	def after_rename(self, olddn, newdn, merge=False):
		NestedSet.after_rename(self, olddn, newdn, merge)
Exemple #21
0
	def on_trash(self):
		NestedSet.on_trash(self)
		WebsiteGenerator.on_trash(self)
Exemple #22
0
	def on_update(self):
		# super(Location, self).on_update()
		NestedSet.on_update(self)
Exemple #23
0
	def on_update(self):
		NestedSet.on_update(self)
		invalidate_cache_for(self)
		self.validate_name_with_item()
		self.validate_one_root()
		self.delete_child_item_groups_key()
Exemple #24
0
 def on_update(self):
     NestedSet.on_update(self)
     invalidate_cache_for(self)
     self.validate_name_with_item()
     self.validate_one_root()
Exemple #25
0
 def on_update(self):
     if not frappe.flags.in_rebuild_config:
         NestedSet.on_update(self)
     self.clear_cache()
Exemple #26
0
	def on_update(self):
		NestedSet.on_update(self)
		self.validate_one_root()
Exemple #27
0
 def on_update(self):
     NestedSet.on_update(self)
     self.create_accounts()
Exemple #28
0
	def on_update(self):
		NestedSet.on_update(self)
Exemple #29
0
 def after_rename(self, olddn, newdn, merge=False):
     NestedSet.after_rename(self, olddn, newdn, merge)
     WebsiteGenerator.after_rename(self, olddn, newdn, merge)
Exemple #30
0
 def on_update(self):
     NestedSet.on_update(self)
Exemple #31
0
 def on_trash(self):
     NestedSet.on_trash(self)
     WebsiteGenerator.on_trash(self)
Exemple #32
0
	def on_update(self):
		WebsiteGenerator.on_update(self)
		NestedSet.on_update(self)
		clear_cache(website_group=self.name)