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