def create_territories():
 from frappe.utils.nestedset import get_root_of
 country = frappe.db.get_default(u'country')
 root_territory = get_root_of(u'Territory')
 for name in (country, _(u'Rest Of The World')):
  if (name and (not frappe.db.exists(u'Territory', name))):
   frappe.get_doc({u'doctype': u'Territory', u'territory_name': name.replace(u"'", u''), u'parent_territory': root_territory, u'is_group': u'No'}).insert()

def create_territories ( ) : from frappe . utils . nestedset import get_root_of country = frappe . db . get_default ( u'country' ) root_territory = get_root_of ( u'Territory' ) for name in ( country , _ ( u'Rest Of The World' ) ) : if ( name and ( not frappe . db . exists ( u'Territory' , name ) ) ) : frappe . get_doc ( { u'doctype' : u'Territory' , u'territory_name' : name . replace ( u"'" , u'' ) , u'parent_territory' : root_territory , u'is_group' : u'No' } ) . insert ( )
create two default territories .