From 691c166a56e00f44dabdfb0219c87defd092ce67 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Thu, 7 Feb 2019 20:35:52 +0530 Subject: [PATCH] fix(py3): Use six.text_type instead of unicode --- .../doctype/production_order/production_order.py | 5 +++-- erpnext/stock/doctype/batch/batch.py | 5 +++-- erpnext/templates/pages/search_help.py | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 2f2c40ef2d..976b24f16a 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe import json +from six import text_type from frappe import _ from frappe.utils import flt, get_datetime, getdate, date_diff, cint, nowdate from frappe.model.document import Document @@ -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) diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index ef0a317d65..71fd82181e 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -2,6 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals +from six import text_type import frappe from frappe import _ from frappe.model.document import Document @@ -60,7 +61,7 @@ def _make_naming_series_key(prefix): :param prefix: Naming series prefix gotten from Stock Settings :return: The derived key. If no prefix is given, an empty string is returned """ - if not unicode(prefix): + if not text_type(prefix): return '' else: return prefix.upper() + '.#####' @@ -86,7 +87,7 @@ class Batch(Document): def autoname(self): """Generate random ID for batch if not specified""" if not self.batch_id: - create_new_batch, batch_number_series = frappe.db.get_value('Item', self.item, + create_new_batch, batch_number_series = frappe.db.get_value('Item', self.item, ['create_new_batch', 'batch_number_series']) if create_new_batch: diff --git a/erpnext/templates/pages/search_help.py b/erpnext/templates/pages/search_help.py index 4a4b0dbd93..887d8f4724 100644 --- a/erpnext/templates/pages/search_help.py +++ b/erpnext/templates/pages/search_help.py @@ -3,6 +3,7 @@ import frappe, requests from frappe import _ from jinja2 import utils from html2text import html2text +from six import text_type from frappe.utils import sanitize_html from frappe.utils.global_search import search @@ -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],