def execute(): webnotes.reload_doc("setup", "doctype", "for_territory") webnotes.reload_doc("setup", "doctype", "price_list") webnotes.reload_doc("accounts", "doctype", "sales_taxes_and_charges_master") webnotes.reload_doc("accounts", "doctype", "shipping_rule") from setup.utils import get_root_of root_territory = get_root_of("Territory") for parenttype in [ "Sales Taxes and Charges Master", "Price List", "Shipping Rule" ]: for name in webnotes.conn.sql_list("""select name from `tab%s` main where not exists (select parent from `tabFor Territory` territory where territory.parenttype=%s and territory.parent=main.name)""" % \ (parenttype, "%s"), (parenttype,)): doc = webnotes.doc({ "doctype": "For Territory", "__islocal": 1, "parenttype": parenttype, "parentfield": "valid_for_territories", "parent": name, "territory": root_territory }) doc.save()
def create_territories(): """create two default territories, one for home country and one named Rest of the World""" from setup.utils import get_root_of country = webnotes.conn.get_value("Control Panel", None, "country") root_territory = get_root_of("Territory") for name in (country, "Rest Of The World"): if name and not webnotes.conn.exists("Territory", name): webnotes.bean( {"doctype": "Territory", "territory_name": name, "parent_territory": root_territory, "is_group": "No"} ).insert()
def validate_price_lists(self): territory_name_map = self.validate_overlapping_territories("price_lists", "price_list") # validate that a Shopping Cart Price List exists for the root territory # as a catch all! from setup.utils import get_root_of root_territory = get_root_of("Territory") if root_territory not in territory_name_map.keys(): msgprint(_("Please specify a Price List which is valid for Territory") + ": " + root_territory, raise_exception=ShoppingCartSetupError)
def validate_price_lists(self): territory_name_map = self.validate_overlapping_territories("price_lists", "selling_price_list") # validate that a Shopping Cart Price List exists for the root territory # as a catch all! from setup.utils import get_root_of root_territory = get_root_of("Territory") if root_territory not in territory_name_map.keys(): msgprint(_("Please specify a Price List which is valid for Territory") + ": " + root_territory, raise_exception=ShoppingCartSetupError)
def create_territories(): """create two default territories, one for home country and one named Rest of the World""" from setup.utils import get_root_of country = webnotes.conn.get_value("Control Panel", None, "country") root_territory = get_root_of("Territory") for name in (country, "Rest Of The World"): if name and not webnotes.conn.exists("Territory", name): webnotes.bean({ "doctype": "Territory", "territory_name": name.replace("'", ""), "parent_territory": root_territory, "is_group": "No" }).insert()
def execute(): webnotes.reload_doc("setup", "doctype", "applicable_territory") webnotes.reload_doc("stock", "doctype", "price_list") webnotes.reload_doc("accounts", "doctype", "sales_taxes_and_charges_master") webnotes.reload_doc("accounts", "doctype", "shipping_rule") from setup.utils import get_root_of root_territory = get_root_of("Territory") for parenttype in ["Sales Taxes and Charges Master", "Price List", "Shipping Rule"]: for name in webnotes.conn.sql_list("""select name from `tab%s` main where not exists (select parent from `tabApplicable Territory` territory where territory.parenttype=%s and territory.parent=main.name)""" % \ (parenttype, "%s"), (parenttype,)): doc = webnotes.doc({ "doctype": "Applicable Territory", "__islocal": 1, "parenttype": parenttype, "parentfield": "valid_for_territories", "parent": name, "territory": root_territory }) doc.save()