Use range instead xrange (#13128)
* Use range instead of xrange
* convert float to int
diff --git a/erpnext/demo/demo.py b/erpnext/demo/demo.py
index 42ef896..f765469 100644
--- a/erpnext/demo/demo.py
+++ b/erpnext/demo/demo.py
@@ -63,7 +63,7 @@
# runs_for = 100
fixed_asset.work()
- for i in xrange(runs_for):
+ for i in range(runs_for):
sys.stdout.write("\rSimulating {0}: Day {1}".format(
current_date.strftime("%Y-%m-%d"), i))
sys.stdout.flush()
diff --git a/erpnext/demo/setup/healthcare.py b/erpnext/demo/setup/healthcare.py
index d645e30..b48e0bc 100644
--- a/erpnext/demo/setup/healthcare.py
+++ b/erpnext/demo/setup/healthcare.py
@@ -65,7 +65,7 @@
i += 1
def make_consulation():
- for i in xrange(3):
+ for i in range(3):
physician = get_random("Physician")
department = frappe.get_value("Physician", physician, "department")
patient = get_random("Patient")
@@ -74,7 +74,7 @@
consultation.save(ignore_permissions=True)
def consulation_on_appointment():
- for i in xrange(3):
+ for i in range(3):
appointment = get_random("Patient Appointment")
appointment = frappe.get_doc("Patient Appointment",appointment)
consultation = set_consultation(appointment.patient, appointment.patient_sex, appointment.physician, appointment.department, appointment.appointment_date, i)
diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py
index 64a04d5..4ed4df9 100644
--- a/erpnext/demo/setup/setup_data.py
+++ b/erpnext/demo/setup/setup_data.py
@@ -80,7 +80,7 @@
def setup_fiscal_year():
fiscal_year = None
- for year in xrange(2010, now_datetime().year + 1, 1):
+ for year in range(2010, now_datetime().year + 1, 1):
try:
fiscal_year = frappe.get_doc({
"doctype": "Fiscal Year",
diff --git a/erpnext/demo/user/education.py b/erpnext/demo/user/education.py
index 8c82f87..4fc9c6a 100644
--- a/erpnext/demo/user/education.py
+++ b/erpnext/demo/user/education.py
@@ -15,7 +15,7 @@
def work():
frappe.set_user(frappe.db.get_global('demo_education_user'))
- for d in xrange(20):
+ for d in range(20):
approve_random_student_applicant()
enroll_random_student(frappe.flags.current_date)
# if frappe.flags.current_date.weekday()== 0:
@@ -94,7 +94,7 @@
cs.course_start_date = cstr(start_date)
cs.course_end_date = cstr(end_date)
day = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
- for x in xrange(3):
+ for x in range(3):
random_day = random.choice(day)
cs.day = random_day
cs.from_time = timedelta(hours=(random.randrange(7, 17,1)))
diff --git a/erpnext/demo/user/purchase.py b/erpnext/demo/user/purchase.py
index 8769b09..d9fc1f3 100644
--- a/erpnext/demo/user/purchase.py
+++ b/erpnext/demo/user/purchase.py
@@ -116,7 +116,7 @@
return mr
def add_suppliers(rfq):
- for i in xrange(2):
+ for i in range(2):
supplier = get_random("Supplier")
if supplier not in [d.supplier for d in rfq.get('suppliers')]:
rfq.append("suppliers", { "supplier": supplier })
diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py
index 54ea173..2fd2565 100644
--- a/erpnext/demo/user/sales.py
+++ b/erpnext/demo/user/sales.py
@@ -13,27 +13,27 @@
def work():
frappe.set_user(frappe.db.get_global('demo_sales_user_2'))
if random.random() < 0.5:
- for i in xrange(random.randint(1,7)):
+ for i in range(random.randint(1,7)):
make_opportunity()
if random.random() < 0.5:
- for i in xrange(random.randint(1,3)):
+ for i in range(random.randint(1,3)):
make_quotation()
# lost quotations / inquiries
if random.random() < 0.3:
- for i in xrange(random.randint(1,3)):
+ for i in range(random.randint(1,3)):
quotation = get_random('Quotation', doc=True)
if quotation and quotation.status == 'Submitted':
quotation.declare_order_lost('Did not ask')
- for i in xrange(random.randint(1,3)):
+ for i in range(random.randint(1,3)):
opportunity = get_random('Opportunity', doc=True)
if opportunity and opportunity.status in ('Open', 'Replied'):
opportunity.declare_enquiry_lost('Did not ask')
if random.random() < 0.3:
- for i in xrange(random.randint(1,3)):
+ for i in range(random.randint(1,3)):
make_sales_order()
if random.random() < 0.1: