def on_update(self): NestedSet.on_update(self) if not dataent.db.sql("""select name from tabAccount where company=%s and docstatus<2 limit 1""", self.name): if not dataent.local.flags.ignore_chart_of_accounts: dataent.flags.country_change = True self.create_default_accounts() self.create_default_warehouses() if dataent.flags.country_change: install_country_fixtures(self.name) self.create_default_tax_template() if not dataent.db.get_value("Department", {"company": self.name}): from epaas.setup.setup_wizard.operations.install_fixtures import install_post_company_fixtures install_post_company_fixtures(dataent._dict({'company_name': self.name})) if not dataent.db.get_value("Cost Center", {"is_group": 0, "company": self.name}): self.create_default_cost_center() if not dataent.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: dataent.db.set_value("Currency", self.default_currency, "enabled", 1) if hasattr(dataent.local, 'enable_perpetual_inventory') and \ self.name in dataent.local.enable_perpetual_inventory: dataent.local.enable_perpetual_inventory[self.name] = self.enable_perpetual_inventory dataent.clear_cache()
def on_trash(self): """ Trash accounts and cost centers for this company if no gl entry exists """ NestedSet.validate_if_child_exists(self) dataent.utils.nestedset.update_nsm(self) rec = dataent.db.sql("SELECT name from `tabGL Entry` where company = %s", self.name) if not rec: dataent.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"]: dataent.db.sql("delete from `tab{0}` where company = %s".format(doctype), self.name) if not dataent.db.get_value("Stock Ledger Entry", {"company": self.name}): dataent.db.sql("""delete from `tabWarehouse` where company=%s""", self.name) dataent.defaults.clear_default("company", value=self.name) for doctype in ["Mode of Payment Account", "Item Default"]: dataent.db.sql("delete from `tab{0}` where company = %s".format(doctype), self.name) # clear default accounts, warehouses from item warehouses = dataent.db.sql_list("select name from tabWarehouse where company=%s", self.name) if warehouses: dataent.db.sql("""delete from `tabItem Reorder` where warehouse in (%s)""" % ', '.join(['%s']*len(warehouses)), tuple(warehouses)) # reset default company dataent.db.sql("""update `tabSingles` set value="" where doctype='Global Defaults' and field='default_company' and value=%s""", self.name) # delete BOMs boms = dataent.db.sql_list("select name from tabBOM where company=%s", self.name) if boms: dataent.db.sql("delete from tabBOM where company=%s", self.name) for dt in ("BOM Operation", "BOM Item", "BOM Scrap Item", "BOM Explosion Item"): dataent.db.sql("delete from `tab%s` where parent in (%s)""" % (dt, ', '.join(['%s']*len(boms))), tuple(boms)) dataent.db.sql("delete from tabEmployee where company=%s", self.name) dataent.db.sql("delete from tabDepartment where company=%s", self.name) dataent.db.sql("delete from `tabTax Withholding Account` where company=%s", self.name) dataent.db.sql("delete from `tabSales Taxes and Charges Template` where company=%s", self.name) dataent.db.sql("delete from `tabPurchase Taxes and Charges Template` where company=%s", self.name)
def on_update(self): NestedSet.on_update(self) self.validate_one_root()
def on_trash(self): NestedSet.validate_if_child_exists(self) dataent.utils.nestedset.update_nsm(self)
def on_trash(self): NestedSet.on_trash(self) WebsiteGenerator.on_trash(self)
def on_update(self): NestedSet.on_update(self) invalidate_cache_for(self) self.validate_name_with_item() self.validate_one_root()
def on_trash(self): NestedSet.validate_if_child_exists(self) update_nsm(self) self.remove_ancestor_location_features()
def on_update(self): # super(Location, self).on_update() NestedSet.on_update(self)
def on_update(self): NestedSet.on_update(self)