Python 3 compatibility syntax error fixes (#10519)

* Use Python 3 style print function

* Use 'Exception as e' instead of 'Exception, e'

* Unpack tuple arguments explicitly in instead of relying on auto unpacking

* Use consistent indentation

* Use 0 if stock_frozen_upto_days is None
This commit is contained in:
Aditya Hase
2017-08-28 18:17:36 +05:30
committed by Rushabh Mehta
parent 7ed4bfe7ee
commit 6ccb6562f1
43 changed files with 141 additions and 138 deletions

View File

@@ -4,7 +4,7 @@
""" """
Import chart of accounts from OpenERP sources Import chart of accounts from OpenERP sources
""" """
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import os, json import os, json
import ast import ast
@@ -229,7 +229,7 @@ def make_charts():
filename = src["id"][5:] + "_" + chart_id filename = src["id"][5:] + "_" + chart_id
print "building " + filename print("building " + filename)
chart = {} chart = {}
chart["name"] = src["name"] chart["name"] = src["name"]
chart["country_code"] = src["id"][5:] chart["country_code"] = src["id"][5:]

View File

@@ -54,13 +54,15 @@ class ShippingRule(Document):
d.idx = i + 1 d.idx = i + 1
def validate_overlapping_shipping_rule_conditions(self): def validate_overlapping_shipping_rule_conditions(self):
def overlap_exists_between((x1, x2), (y1, y2)): def overlap_exists_between(num_range1, num_range2):
""" """
(x1, x2) and (y1, y2) are two ranges num_range1 and num_range2 are two ranges
if condition x = 100 to 300 ranges are represented as a tuple e.g. range 100 to 300 is represented as (100, 300)
then condition y can only be like 50 to 99 or 301 to 400 if condition num_range1 = 100 to 300
then condition num_range2 can only be like 50 to 99 or 301 to 400
hence, non-overlapping condition = (x1 <= x2 < y1 <= y2) or (y1 <= y2 < x1 <= x2) hence, non-overlapping condition = (x1 <= x2 < y1 <= y2) or (y1 <= y2 < x1 <= x2)
""" """
(x1, x2), (y1, y2) = num_range1, num_range2
separate = (x1 <= x2 <= y1 <= y2) or (y1 <= y2 <= x1 <= x2) separate = (x1 <= x2 <= y1 <= y2) or (y1 <= y2 <= x1 <= x2)
return (not separate) return (not separate)

View File

@@ -1,4 +1,4 @@
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import random, json import random, json
import frappe, erpnext import frappe, erpnext
@@ -42,7 +42,7 @@ def setup(domain):
frappe.clear_cache() frappe.clear_cache()
def complete_setup(domain='Manufacturing'): def complete_setup(domain='Manufacturing'):
print "Complete Setup..." print("Complete Setup...")
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
if not frappe.get_all('Company', limit=1): if not frappe.get_all('Company', limit=1):

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe, random import frappe, random
from frappe.desk import query_report from frappe.desk import query_report
@@ -36,7 +36,7 @@ def make_purchase_receipt():
try: try:
pr.submit() pr.submit()
except NegativeStockError: except NegativeStockError:
print 'Negative stock for {0}'.format(po) print('Negative stock for {0}'.format(po))
pass pass
frappe.db.commit() frappe.db.commit()

View File

@@ -1,4 +1,4 @@
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
def execute(): def execute():
@@ -10,5 +10,5 @@ def execute():
frappe.db.get_value("Global Defaults", "Global Defaults", "country")}) frappe.db.get_value("Global Defaults", "Global Defaults", "country")})
d.insert() d.insert()
except: except:
print frappe.get_traceback() print(frappe.get_traceback())

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
from frappe.permissions import reset_perms from frappe.permissions import reset_perms
def execute(): def execute():
@@ -16,5 +16,5 @@ def execute():
try: try:
reset_perms(doctype) reset_perms(doctype)
except: except:
print "Error resetting perms for", doctype print("Error resetting perms for", doctype)
raise raise

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
from frappe.custom.doctype.property_setter.property_setter import make_property_setter from frappe.custom.doctype.property_setter.property_setter import make_property_setter
@@ -91,7 +91,7 @@ def get_default_series(doctype, new_series):
(new_series, new_series)) (new_series, new_series))
if not (default_series and default_series[0][0]): if not (default_series and default_series[0][0]):
print "[Skipping] Cannot guess which naming series to use for", doctype print("[Skipping] Cannot guess which naming series to use for", doctype)
return return
return default_series[0][0] return default_series[0][0]

View File

@@ -1,11 +1,11 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
def execute(): def execute():
print "WARNING!!!! Email Settings not migrated. Please setup your email again." print("WARNING!!!! Email Settings not migrated. Please setup your email again.")
# this will happen if you are migrating very old accounts # this will happen if you are migrating very old accounts
# comment out this line below and remember to create new Email Accounts # comment out this line below and remember to create new Email Accounts

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
def execute(): def execute():
@@ -31,4 +31,4 @@ def execute():
frappe.db.sql("""UPDATE tabAccount SET root_type=%s WHERE lft>%s and rgt<%s""", frappe.db.sql("""UPDATE tabAccount SET root_type=%s WHERE lft>%s and rgt<%s""",
(root.root_type, root.lft, root.rgt)) (root.root_type, root.lft, root.rgt))
else: else:
print b"Root type not found for {0}".format(root.name.encode("utf-8")) print(b"Root type not found for {0}".format(root.name.encode("utf-8")))

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
from frappe.utils import flt from frappe.utils import flt
@@ -37,7 +37,7 @@ def execute():
if stock_bal and account_bal and abs(flt(stock_bal[0][0]) - flt(account_bal[0][0])) > 0.1: if stock_bal and account_bal and abs(flt(stock_bal[0][0]) - flt(account_bal[0][0])) > 0.1:
try: try:
print voucher_type, voucher_no, stock_bal[0][0], account_bal[0][0] print(voucher_type, voucher_no, stock_bal[0][0], account_bal[0][0])
frappe.db.sql("""delete from `tabGL Entry` frappe.db.sql("""delete from `tabGL Entry`
where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no)) where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no))
@@ -45,10 +45,10 @@ def execute():
voucher = frappe.get_doc(voucher_type, voucher_no) voucher = frappe.get_doc(voucher_type, voucher_no)
voucher.make_gl_entries(repost_future_gle=False) voucher.make_gl_entries(repost_future_gle=False)
frappe.db.commit() frappe.db.commit()
except Exception, e: except Exception as e:
print frappe.get_traceback() print(frappe.get_traceback())
rejected.append([voucher_type, voucher_no]) rejected.append([voucher_type, voucher_no])
frappe.db.rollback() frappe.db.rollback()
print "Failed to repost: " print("Failed to repost: ")
print rejected print(rejected)

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
def execute(): def execute():
@@ -109,7 +109,7 @@ def delete_individual_party_account():
and exists(select gle.name from `tabGL Entry` gle where gle.account = tabAccount.name)""") and exists(select gle.name from `tabGL Entry` gle where gle.account = tabAccount.name)""")
if accounts_not_deleted: if accounts_not_deleted:
print "Accounts not deleted: " + "\n".join(accounts_not_deleted) print("Accounts not deleted: " + "\n".join(accounts_not_deleted))
def remove_customer_supplier_account_report(): def remove_customer_supplier_account_report():

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
from erpnext.stock.stock_ledger import NegativeStockError from erpnext.stock.stock_ledger import NegativeStockError
@@ -28,7 +28,7 @@ def execute():
frappe.local.stockledger_exceptions = None frappe.local.stockledger_exceptions = None
frappe.db.rollback() frappe.db.rollback()
print "Failed to repost: ", failed_list print("Failed to repost: ", failed_list)

View File

@@ -1,13 +1,13 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
def execute(): def execute():
country = frappe.db.get_single_value("Global Defaults", "country") country = frappe.db.get_single_value("Global Defaults", "country")
if not country: if not country:
print "Country not specified in Global Defaults" print("Country not specified in Global Defaults")
return return
for company in frappe.db.sql_list("""select name from `tabCompany` for company in frappe.db.sql_list("""select name from `tabCompany`

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
def execute(): def execute():
@@ -21,6 +21,6 @@ def execute():
je.make_gl_entries() je.make_gl_entries()
if je_list: if je_list:
print je_list print(je_list)

View File

@@ -1,4 +1,4 @@
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
import os import os
from frappe.utils import get_files_path from frappe.utils import get_files_path
@@ -45,7 +45,7 @@ def fix_files_for_item(files_path, unlinked_files):
try: try:
file_data.save() file_data.save()
except IOError: except IOError:
print "File {0} does not exist".format(new_file_url) print("File {0} does not exist".format(new_file_url))
# marking fix to prevent further errors # marking fix to prevent further errors
fixed_files.append(file_url) fixed_files.append(file_url)

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
from frappe.email import sendmail_to_system_managers from frappe.email import sendmail_to_system_managers
from frappe.utils import get_link_to_form from frappe.utils import get_link_to_form
@@ -36,6 +36,6 @@ Administrator""" % "\n".join([(d[0] + ": " + ", ".join(d[1])) for d in wrong_rec
except: except:
pass pass
print "="*50 print("="*50)
print content print(content)
print "="*50 print("="*50)

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
import MySQLdb import MySQLdb
@@ -32,7 +32,7 @@ def execute():
migrate_item_variants() migrate_item_variants()
except MySQLdb.ProgrammingError: except MySQLdb.ProgrammingError:
print "`tabItem Variant` not found" print("`tabItem Variant` not found")
def rename_and_reload_doctypes(): def rename_and_reload_doctypes():
if "tabVariant Attribute" in frappe.db.get_tables(): if "tabVariant Attribute" in frappe.db.get_tables():

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
""" """
@@ -38,19 +38,19 @@ def check():
si_list = get_affected_sales_invoice() si_list = get_affected_sales_invoice()
if so_list or dn_list or si_list: if so_list or dn_list or si_list:
print "Entries with Target Warehouse:" print("Entries with Target Warehouse:")
if so_list: if so_list:
print "Sales Order" print("Sales Order")
print so_list print(so_list)
if dn_list: if dn_list:
print "Delivery Notes" print("Delivery Notes")
print [d.name for d in dn_list] print([d.name for d in dn_list])
if si_list: if si_list:
print "Sales Invoice" print("Sales Invoice")
print [d.name for d in si_list] print([d.name for d in si_list])
def repost(): def repost():
@@ -61,34 +61,34 @@ def repost():
frappe.db.commit() frappe.db.commit()
if dn_failed_list: if dn_failed_list:
print "-"*40 print("-"*40)
print "Delivery Note Failed to Repost" print("Delivery Note Failed to Repost")
print dn_failed_list print(dn_failed_list)
if si_failed_list: if si_failed_list:
print "-"*40 print("-"*40)
print "Sales Invoice Failed to Repost" print("Sales Invoice Failed to Repost")
print si_failed_list print(si_failed_list)
print print()
print """ print("""
If above Delivery Notes / Sales Invoice failed due to negative stock, follow these steps: If above Delivery Notes / Sales Invoice failed due to negative stock, follow these steps:
- Ensure that stock is available for those items in the mentioned warehouse on the date mentioned in the error - Ensure that stock is available for those items in the mentioned warehouse on the date mentioned in the error
- Run this patch again - Run this patch again
""" """)
def repost_dn(dn_failed_list): def repost_dn(dn_failed_list):
dn_list = get_affected_delivery_notes() dn_list = get_affected_delivery_notes()
if dn_list: if dn_list:
print "-"*40 print("-"*40)
print "Reposting Delivery Notes" print("Reposting Delivery Notes")
for dn in dn_list: for dn in dn_list:
if dn.docstatus == 0: if dn.docstatus == 0:
continue continue
print dn.name print(dn.name)
try: try:
dn_doc = frappe.get_doc("Delivery Note", dn.name) dn_doc = frappe.get_doc("Delivery Note", dn.name)
@@ -107,7 +107,7 @@ def repost_dn(dn_failed_list):
except Exception: except Exception:
dn_failed_list.append(dn.name) dn_failed_list.append(dn.name)
frappe.local.stockledger_exceptions = None frappe.local.stockledger_exceptions = None
print frappe.get_traceback() print(frappe.get_traceback())
frappe.db.rollback() frappe.db.rollback()
frappe.db.sql("update `tabDelivery Note Item` set target_warehouse='' where docstatus=0") frappe.db.sql("update `tabDelivery Note Item` set target_warehouse='' where docstatus=0")
@@ -116,14 +116,14 @@ def repost_si(si_failed_list):
si_list = get_affected_sales_invoice() si_list = get_affected_sales_invoice()
if si_list: if si_list:
print "-"*40 print("-"*40)
print "Reposting Sales Invoice" print("Reposting Sales Invoice")
for si in si_list: for si in si_list:
if si.docstatus == 0: if si.docstatus == 0:
continue continue
print si.name print(si.name)
try: try:
si_doc = frappe.get_doc("Sales Invoice", si.name) si_doc = frappe.get_doc("Sales Invoice", si.name)
@@ -141,7 +141,7 @@ def repost_si(si_failed_list):
except Exception: except Exception:
si_failed_list.append(si.name) si_failed_list.append(si.name)
frappe.local.stockledger_exceptions = None frappe.local.stockledger_exceptions = None
print frappe.get_traceback() print(frappe.get_traceback())
frappe.db.rollback() frappe.db.rollback()
frappe.db.sql("update `tabSales Invoice Item` set target_warehouse='' where docstatus=0") frappe.db.sql("update `tabSales Invoice Item` set target_warehouse='' where docstatus=0")
@@ -152,8 +152,8 @@ def repost_so():
frappe.db.sql("update `tabSales Order Item` set target_warehouse=''") frappe.db.sql("update `tabSales Order Item` set target_warehouse=''")
if so_list: if so_list:
print "-"*40 print("-"*40)
print "Sales Order reposted" print("Sales Order reposted")
def get_affected_delivery_notes(): def get_affected_delivery_notes():

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
from frappe.utils import cstr from frappe.utils import cstr
@@ -33,7 +33,7 @@ def execute():
(pi.name, company.expenses_included_in_valuation)) (pi.name, company.expenses_included_in_valuation))
if gle_for_expenses_included_in_valuation: if gle_for_expenses_included_in_valuation:
print pi.name print(pi.name)
frappe.db.sql("""delete from `tabGL Entry` frappe.db.sql("""delete from `tabGL Entry`
where voucher_type='Purchase Invoice' and voucher_no=%s""", pi.name) where voucher_type='Purchase Invoice' and voucher_no=%s""", pi.name)

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
def execute(): def execute():
@@ -44,7 +44,7 @@ def execute():
where name=%s""", d.name) where name=%s""", d.name)
for d in journal_entries: for d in journal_entries:
print d print(d)
# delete existing gle # delete existing gle
frappe.db.sql("delete from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no=%s", d) frappe.db.sql("delete from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no=%s", d)

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
import frappe import frappe
def execute(): def execute():
@@ -11,4 +12,4 @@ def execute():
if item_doc.thumbnail: if item_doc.thumbnail:
item_doc.db_set("thumbnail", item_doc.thumbnail, update_modified=False) item_doc.db_set("thumbnail", item_doc.thumbnail, update_modified=False)
except Exception: except Exception:
print "Unable to make thumbnail for {0}".format(item.website_image.encode("utf-8")) print("Unable to make thumbnail for {0}".format(item.website_image.encode("utf-8")))

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
def execute(): def execute():
@@ -13,7 +13,7 @@ def execute():
and against_voucher=je.reference_name)""") and against_voucher=je.reference_name)""")
for d in je_list: for d in je_list:
print d print(d)
# delete existing gle # delete existing gle
frappe.db.sql("delete from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no=%s", d) frappe.db.sql("delete from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no=%s", d)

View File

@@ -1,4 +1,4 @@
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
from frappe.utils import encode from frappe.utils import encode
@@ -25,7 +25,7 @@ def execute():
try: try:
file.validate_file() file.validate_file()
except IOError: except IOError:
print encode(item.website_image), "does not exist" print(encode(item.website_image), "does not exist")
file.delete() file.delete()
item.db_set("website_image", None, update_modified=False) item.db_set("website_image", None, update_modified=False)

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe, erpnext import frappe, erpnext
def execute(): def execute():
@@ -35,11 +35,11 @@ def execute():
voucher.make_gl_entries() voucher.make_gl_entries()
frappe.db.commit() frappe.db.commit()
except Exception as e: except Exception as e:
print frappe.get_traceback() print(frappe.get_traceback())
rejected.append([voucher_type, voucher_no]) rejected.append([voucher_type, voucher_no])
frappe.db.rollback() frappe.db.rollback()
print rejected print(rejected)
def set_warehouse_for_stock_account(warehouse_account): def set_warehouse_for_stock_account(warehouse_account):
for account in warehouse_account: for account in warehouse_account:

View File

@@ -81,7 +81,7 @@ def execute():
try: try:
frappe.db.sql("""INSERT INTO `tabSalary Component` ({0}) SELECT {1} FROM `tab{2}`""" frappe.db.sql("""INSERT INTO `tabSalary Component` ({0}) SELECT {1} FROM `tab{2}`"""
.format(target_cols, source_cols, doctype)) .format(target_cols, source_cols, doctype))
except Exception, e: except Exception as e:
if e.args[0]==1062: if e.args[0]==1062:
pass pass

View File

@@ -2,7 +2,7 @@
# Copyright (c) 2015, Frappe Technologies and contributors # Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
@@ -13,7 +13,7 @@ class StudentApplicant(Document):
if self.student_admission: if self.student_admission:
naming_series = frappe.db.get_value('Student Admission', self.student_admission, naming_series = frappe.db.get_value('Student Admission', self.student_admission,
'naming_series_for_student_applicant') 'naming_series_for_student_applicant')
print naming_series print(naming_series)
if naming_series: if naming_series:
self.naming_series = naming_series self.naming_series = naming_series

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import unittest import unittest
import frappe import frappe
from frappe.utils.nestedset import NestedSetRecursionError, NestedSetMultipleRootsError, \ from frappe.utils.nestedset import NestedSetRecursionError, NestedSetMultipleRootsError, \
@@ -112,7 +112,7 @@ class TestItem(unittest.TestCase):
def print_tree(self): def print_tree(self):
import json import json
print json.dumps(frappe.db.sql("select name, lft, rgt from `tabItem Group` order by lft"), indent=1) print(json.dumps(frappe.db.sql("select name, lft, rgt from `tabItem Group` order by lft"), indent=1))
def test_move_leaf_into_another_group(self): def test_move_leaf_into_another_group(self):
# before move # before move

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
@@ -19,10 +19,10 @@ def after_install():
def check_setup_wizard_not_completed(): def check_setup_wizard_not_completed():
if frappe.db.get_default('desktop:home_page') == 'desktop': if frappe.db.get_default('desktop:home_page') == 'desktop':
print print()
print "ERPNext can only be installed on a fresh site where the setup wizard is not completed" print("ERPNext can only be installed on a fresh site where the setup wizard is not completed")
print "You can reinstall this site (after saving your data) using: bench --site [sitename] reinstall" print("You can reinstall this site (after saving your data) using: bench --site [sitename] reinstall")
print print()
return False return False
def set_single_defaults(): def set_single_defaults():

View File

@@ -18,7 +18,7 @@ class StockSettings(Document):
self.get("item_naming_by")=="Naming Series", hide_name_field=True) self.get("item_naming_by")=="Naming Series", hide_name_field=True)
stock_frozen_limit = 356 stock_frozen_limit = 356
submitted_stock_frozen = self.stock_frozen_upto_days submitted_stock_frozen = self.stock_frozen_upto_days or 0
if submitted_stock_frozen > stock_frozen_limit: if submitted_stock_frozen > stock_frozen_limit:
self.stock_frozen_upto_days = stock_frozen_limit self.stock_frozen_upto_days = stock_frozen_limit
frappe.msgprint (_("`Freeze Stocks Older Than` should be smaller than %d days.") %stock_frozen_limit) frappe.msgprint (_("`Freeze Stocks Older Than` should be smaller than %d days.") %stock_frozen_limit)

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import print_function, unicode_literals
import frappe import frappe
from frappe.utils import flt, cstr, nowdate, nowtime from frappe.utils import flt, cstr, nowdate, nowtime
@@ -170,7 +170,7 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin
where item_code=%s and warehouse=%s and docstatus < 2""", (d[0], d[1])) where item_code=%s and warehouse=%s and docstatus < 2""", (d[0], d[1]))
if serial_nos and flt(serial_nos[0][0]) != flt(d[2]): if serial_nos and flt(serial_nos[0][0]) != flt(d[2]):
print d[0], d[1], d[2], serial_nos[0][0] print(d[0], d[1], d[2], serial_nos[0][0])
sle = frappe.db.sql("""select valuation_rate, company from `tabStock Ledger Entry` sle = frappe.db.sql("""select valuation_rate, company from `tabStock Ledger Entry`
where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No'
@@ -244,7 +244,7 @@ def repost_all_stock_vouchers():
i = 0 i = 0
for voucher_type, voucher_no in vouchers: for voucher_type, voucher_no in vouchers:
i+=1 i+=1
print i, "/", len(vouchers), voucher_type, voucher_no print(i, "/", len(vouchers), voucher_type, voucher_no)
try: try:
for dt in ["Stock Ledger Entry", "GL Entry"]: for dt in ["Stock Ledger Entry", "GL Entry"]:
frappe.db.sql("""delete from `tab%s` where voucher_type=%s and voucher_no=%s"""% frappe.db.sql("""delete from `tab%s` where voucher_type=%s and voucher_no=%s"""%
@@ -259,9 +259,9 @@ def repost_all_stock_vouchers():
doc.update_stock_ledger() doc.update_stock_ledger()
doc.make_gl_entries(repost_future_gle=False) doc.make_gl_entries(repost_future_gle=False)
frappe.db.commit() frappe.db.commit()
except Exception, e: except Exception as e:
print frappe.get_traceback() print(frappe.get_traceback())
rejected.append([voucher_type, voucher_no]) rejected.append([voucher_type, voucher_no])
frappe.db.rollback() frappe.db.rollback()
print rejected print(rejected)

View File

@@ -1,5 +1,5 @@
## temp utility ## temp utility
from __future__ import print_function
import frappe import frappe
from erpnext.utilities.activation import get_level from erpnext.utilities.activation import get_level
from frappe.utils import cstr from frappe.utils import cstr
@@ -12,7 +12,7 @@ def update_doctypes():
for f in dt.fields: for f in dt.fields:
if f.fieldname == d.fieldname and f.fieldtype in ("Text", "Small Text"): if f.fieldname == d.fieldname and f.fieldtype in ("Text", "Small Text"):
print f.parent, f.fieldname print(f.parent, f.fieldname)
f.fieldtype = "Text Editor" f.fieldtype = "Text Editor"
dt.save() dt.save()
break break