fix: Python 3 compatibility fixes (#18019)
fix: Python 3 compatibility fixes
This commit is contained in:
@@ -350,7 +350,7 @@ def filter_pricing_rules(args, pricing_rules):
|
||||
if len(pricing_rules) > 1:
|
||||
rate_or_discount = list(set([d.rate_or_discount for d in pricing_rules]))
|
||||
if len(rate_or_discount) == 1 and rate_or_discount[0] == "Discount Percentage":
|
||||
pricing_rules = filter(lambda x: x.for_price_list==args.price_list, pricing_rules) \
|
||||
pricing_rules = list(filter(lambda x: x.for_price_list==args.price_list, pricing_rules)) \
|
||||
or pricing_rules
|
||||
|
||||
if len(pricing_rules) > 1 and not args.for_shopping_cart:
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestTaxWithholdingCategory(unittest.TestCase):
|
||||
invoices = []
|
||||
|
||||
# create invoices for lower than single threshold tax rate
|
||||
for _ in xrange(2):
|
||||
for _ in range(2):
|
||||
pi = create_purchase_invoice(supplier = "Test TDS Supplier")
|
||||
pi.submit()
|
||||
invoices.append(pi)
|
||||
|
||||
@@ -36,7 +36,7 @@ class AssetValueAdjustment(Document):
|
||||
fixed_asset_account, accumulated_depreciation_account, depreciation_expense_account = \
|
||||
get_depreciation_accounts(asset)
|
||||
|
||||
depreciation_cost_center, depreciation_series = frappe.get_cached_value('Company', asset.company,
|
||||
depreciation_cost_center, depreciation_series = frappe.get_cached_value('Company', asset.company,
|
||||
["depreciation_cost_center", "series_for_depreciation_entry"])
|
||||
|
||||
je = frappe.new_doc("Journal Entry")
|
||||
@@ -75,8 +75,8 @@ class AssetValueAdjustment(Document):
|
||||
rate_per_day = flt(d.value_after_depreciation) / flt(total_days)
|
||||
from_date = self.date
|
||||
else:
|
||||
no_of_depreciations = len([e.name for e in asset.schedules
|
||||
if (cint(s.finance_book_id) == d.idx and not e.journal_entry)])
|
||||
no_of_depreciations = len([s.name for s in asset.schedules
|
||||
if (cint(s.finance_book_id) == d.idx and not s.journal_entry)])
|
||||
|
||||
value_after_depreciation = d.value_after_depreciation
|
||||
for data in asset.schedules:
|
||||
|
||||
@@ -25,9 +25,12 @@ class TestLocation(unittest.TestCase):
|
||||
temp['features'][0]['properties']['feature_of'] = location
|
||||
formatted_locations.extend(temp['features'])
|
||||
|
||||
formatted_location_string = str(formatted_locations)
|
||||
test_location = frappe.get_doc('Location', 'Test Location Area')
|
||||
test_location.save()
|
||||
|
||||
self.assertEqual(formatted_location_string, str(json.loads(test_location.get('location'))['features']))
|
||||
test_location_features = json.loads(test_location.get('location'))['features']
|
||||
ordered_test_location_features = sorted(test_location_features, key=lambda x: x['properties']['feature_of'])
|
||||
ordered_formatted_locations = sorted(formatted_locations, key=lambda x: x['properties']['feature_of'])
|
||||
|
||||
self.assertEqual(ordered_formatted_locations, ordered_test_location_features)
|
||||
self.assertEqual(area, test_location.get('area'))
|
||||
|
||||
@@ -40,7 +40,7 @@ def get_products_details():
|
||||
products_response = call_mws_method(products.get_matching_product,marketplaceid=marketplace,
|
||||
asins=asin_list)
|
||||
|
||||
matching_products_list = products_response.parsed
|
||||
matching_products_list = products_response.parsed
|
||||
for product in matching_products_list:
|
||||
skus = [row["sku"] for row in sku_asin if row["asin"]==product.ASIN]
|
||||
for sku in skus:
|
||||
@@ -116,7 +116,7 @@ def call_mws_method(mws_method, *args, **kwargs):
|
||||
mws_settings = frappe.get_doc("Amazon MWS Settings")
|
||||
max_retries = mws_settings.max_retry_limit
|
||||
|
||||
for x in xrange(0, max_retries):
|
||||
for x in range(0, max_retries):
|
||||
try:
|
||||
response = mws_method(*args, **kwargs)
|
||||
return response
|
||||
|
||||
@@ -18,6 +18,7 @@ from erpnext.stock.stock_balance import get_planned_qty, update_bin_qty
|
||||
from frappe.utils.csvutils import getlink
|
||||
from erpnext.stock.utils import get_bin, validate_warehouse_company, get_latest_stock_qty
|
||||
from erpnext.utilities.transaction_base import validate_uom_is_integer
|
||||
from six import text_type
|
||||
|
||||
class OverProductionError(frappe.ValidationError): pass
|
||||
class StockOverProductionError(frappe.ValidationError): pass
|
||||
@@ -591,10 +592,10 @@ def make_timesheet(production_order, company):
|
||||
|
||||
@frappe.whitelist()
|
||||
def add_timesheet_detail(timesheet, args):
|
||||
if isinstance(timesheet, unicode):
|
||||
if isinstance(timesheet, text_type):
|
||||
timesheet = frappe.get_doc('Timesheet', timesheet)
|
||||
|
||||
if isinstance(args, unicode):
|
||||
if isinstance(args, text_type):
|
||||
args = json.loads(args)
|
||||
|
||||
timesheet.append('time_logs', args)
|
||||
|
||||
@@ -103,8 +103,8 @@ class TestTimesheet(unittest.TestCase):
|
||||
{
|
||||
"billable": 1,
|
||||
"activity_type": "_Test Activity Type",
|
||||
"from_type": now_datetime(),
|
||||
"hours": 3,
|
||||
"from_time": now_datetime(),
|
||||
"to_time": now_datetime() + datetime.timedelta(hours=3),
|
||||
"company": "_Test Company"
|
||||
}
|
||||
)
|
||||
@@ -113,8 +113,8 @@ class TestTimesheet(unittest.TestCase):
|
||||
{
|
||||
"billable": 1,
|
||||
"activity_type": "_Test Activity Type",
|
||||
"from_type": now_datetime(),
|
||||
"hours": 3,
|
||||
"from_time": now_datetime(),
|
||||
"to_time": now_datetime() + datetime.timedelta(hours=3),
|
||||
"company": "_Test Company"
|
||||
}
|
||||
)
|
||||
|
||||
@@ -69,13 +69,13 @@ def get_gl_entries(filters):
|
||||
|
||||
gl_entries = frappe.db.sql("""
|
||||
select
|
||||
gl.posting_date as GlPostDate, gl.name as GlName, gl.account, gl.transaction_date,
|
||||
gl.posting_date as GlPostDate, gl.name as GlName, gl.account, gl.transaction_date,
|
||||
sum(gl.debit) as debit, sum(gl.credit) as credit,
|
||||
sum(gl.debit_in_account_currency) as debitCurr, sum(gl.credit_in_account_currency) as creditCurr,
|
||||
gl.voucher_type, gl.voucher_no, gl.against_voucher_type,
|
||||
gl.against_voucher, gl.account_currency, gl.against,
|
||||
gl.voucher_type, gl.voucher_no, gl.against_voucher_type,
|
||||
gl.against_voucher, gl.account_currency, gl.against,
|
||||
gl.party_type, gl.party,
|
||||
inv.name as InvName, inv.title as InvTitle, inv.posting_date as InvPostDate,
|
||||
inv.name as InvName, inv.title as InvTitle, inv.posting_date as InvPostDate,
|
||||
pur.name as PurName, pur.title as PurTitle, pur.posting_date as PurPostDate,
|
||||
jnl.cheque_no as JnlRef, jnl.posting_date as JnlPostDate, jnl.title as JnlTitle,
|
||||
pay.name as PayName, pay.posting_date as PayPostDate, pay.title as PayTitle,
|
||||
@@ -84,7 +84,7 @@ def get_gl_entries(filters):
|
||||
emp.employee_name, emp.name as empName,
|
||||
stu.title as student_name, stu.name as stuName,
|
||||
member_name, mem.name as memName
|
||||
|
||||
|
||||
from `tabGL Entry` gl
|
||||
left join `tabSales Invoice` inv on gl.voucher_no = inv.name
|
||||
left join `tabPurchase Invoice` pur on gl.voucher_no = pur.name
|
||||
@@ -124,7 +124,7 @@ def get_result_as_list(data, filters):
|
||||
if account_number[0] is not None:
|
||||
CompteNum = account_number[0]
|
||||
else:
|
||||
frappe.throw(_("Account number for account {0} is not available.<br> Please setup your Chart of Accounts correctly.").format(account.name))
|
||||
frappe.throw(_("Account number for account {0} is not available.<br> Please setup your Chart of Accounts correctly.").format(d.get("account")))
|
||||
|
||||
if d.get("party_type") == "Customer":
|
||||
CompAuxNum = d.get("cusName")
|
||||
|
||||
@@ -5,6 +5,7 @@ from jinja2 import utils
|
||||
from html2text import html2text
|
||||
from frappe.utils import sanitize_html
|
||||
from frappe.utils.global_search import search
|
||||
from six import text_type
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
@@ -12,7 +13,7 @@ def get_context(context):
|
||||
query = str(utils.escape(sanitize_html(frappe.form_dict.q)))
|
||||
context.title = _('Help Results for')
|
||||
context.query = query
|
||||
|
||||
|
||||
context.route = '/search_help'
|
||||
d = frappe._dict()
|
||||
d.results_sections = get_help_results_sections(query)
|
||||
@@ -73,7 +74,7 @@ def prepare_api_results(api, topics_data):
|
||||
for topic in topics_data:
|
||||
route = api.base_url + '/' + (api.post_route + '/' if api.post_route else "")
|
||||
for key in api.post_route_key_list.split(','):
|
||||
route += unicode(topic[key])
|
||||
route += text_type(topic[key])
|
||||
|
||||
results.append(frappe._dict({
|
||||
'title': topic[api.post_title_key],
|
||||
|
||||
Reference in New Issue
Block a user