From 12cb0ea6339cfeb2c996de35796fd08439a4b890 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 18 Jun 2019 21:50:05 +0530 Subject: [PATCH 1/8] fix(tests): Timesheet tests --- erpnext/projects/doctype/timesheet/test_timesheet.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index f1179033bed..32f0428fcd8 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -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" } ) From 3d59ab5c55a369a45dba88c5e12d98e17b280a04 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 18 Jun 2019 23:01:20 +0530 Subject: [PATCH 2/8] fix(tests): Do not test order of features in Location --- erpnext/assets/doctype/location/test_location.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/assets/doctype/location/test_location.py b/erpnext/assets/doctype/location/test_location.py index 22d25b5e11c..c98b0b0936c 100644 --- a/erpnext/assets/doctype/location/test_location.py +++ b/erpnext/assets/doctype/location/test_location.py @@ -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')) From d48d5c7cbd477a55f126d268cd65f36baf6a5833 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 21 Jun 2019 11:57:33 +0530 Subject: [PATCH 3/8] fix: Replace unicode with six.text_type --- .../doctype/production_order/production_order.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 2f2c40ef2d4..b5abb733b01 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -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) From 14b5c96c58a674a1e5b985a2ff6fa57fdc9b10e5 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 7 Feb 2019 18:10:30 +0530 Subject: [PATCH 4/8] fix(py3): Use range instead of xrange --- .../tax_withholding_category/test_tax_withholding_category.py | 2 +- .../doctype/amazon_mws_settings/amazon_methods.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py index 25301967080..638e57ed2b9 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py @@ -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) diff --git a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_methods.py b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_methods.py index 124910e35de..1c39d8818c4 100644 --- a/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_methods.py +++ b/erpnext/erpnext_integrations/doctype/amazon_mws_settings/amazon_methods.py @@ -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 From fbab41668ddc2af4d93f4fcaf923233086fa6b18 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 21 Jun 2019 11:31:29 +0530 Subject: [PATCH 5/8] fix(py3): Undefined variable --- .../fichier_des_ecritures_comptables_[fec].py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py b/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py index e1b6c4db4f9..e903c9f00a4 100644 --- a/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py +++ b/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py @@ -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.
Please setup your Chart of Accounts correctly.").format(account.name)) + frappe.throw(_("Account number for account {0} is not available.
Please setup your Chart of Accounts correctly.").format(d.get("account"))) if d.get("party_type") == "Customer": CompAuxNum = d.get("cusName") From 72056c26a8ab5afb995455cf7b5156831bf3e103 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 1 May 2019 11:51:04 +0530 Subject: [PATCH 6/8] fix(py3): Undefined variable --- .../asset_value_adjustment/asset_value_adjustment.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py index ac3c3507027..56425a0dcb4 100644 --- a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py +++ b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py @@ -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: From 4acd39b6a40b36aa2cb2ca72df644072acc587fb Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 21 Jun 2019 12:08:23 +0530 Subject: [PATCH 7/8] fix(py3): Convert filter to list --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 7f0f60ff02e..fca914e3139 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -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: From 618146cc6377907b2ce71d106cdc21fd471d8327 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 21 Jun 2019 12:09:44 +0530 Subject: [PATCH 8/8] fix(py3): Replace unicode with six.text_type --- erpnext/templates/pages/search_help.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/templates/pages/search_help.py b/erpnext/templates/pages/search_help.py index 4a4b0dbd934..cd767b3099c 100644 --- a/erpnext/templates/pages/search_help.py +++ b/erpnext/templates/pages/search_help.py @@ -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],