Merge pull request #12932 from achillesrasquinha/py3-basestring

Py3 basestring
This commit is contained in:
Achilles Rasquinha 2018-02-15 12:16:12 +05:30 committed by GitHub
commit d56b00f5fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 28 additions and 14 deletions

View File

@ -208,7 +208,7 @@ def remove_pricing_rule_for_item(pricing_rule, item_details):
@frappe.whitelist()
def remove_pricing_rules(item_list):
if isinstance(item_list, basestring):
if isinstance(item_list, string_types):
item_list = json.loads(item_list)
out = []

View File

@ -14,6 +14,8 @@ from frappe import _
from frappe.core.doctype.communication.email import make
from frappe.utils import nowdate
from six import string_types
@frappe.whitelist()
def get_pos_data():
@ -196,7 +198,7 @@ def get_customers_list(pos_profile={}):
def get_customers_address(customers):
customer_address = {}
if isinstance(customers, basestring):
if isinstance(customers, string_types):
customers = [frappe._dict({'name': customers})]
for data in customers:
@ -216,7 +218,7 @@ def get_customers_address(customers):
def get_contacts(customers):
customer_contact = {}
if isinstance(customers, basestring):
if isinstance(customers, string_types):
customers = [frappe._dict({'name': customers})]
for data in customers:
@ -351,13 +353,13 @@ def get_pricing_rule_data(doc):
@frappe.whitelist()
def make_invoice(doc_list={}, email_queue_list={}, customers_list={}):
if isinstance(doc_list, basestring):
if isinstance(doc_list, string_types):
doc_list = json.loads(doc_list)
if isinstance(email_queue_list, basestring):
if isinstance(email_queue_list, string_types):
email_queue_list = json.loads(email_queue_list)
if isinstance(customers_list, basestring):
if isinstance(customers_list, string_types):
customers_list = json.loads(customers_list)
customers_list = make_customer_and_address(customers_list)

View File

@ -16,6 +16,8 @@ from erpnext.stock.doctype.material_request.material_request import set_missing_
from erpnext.controllers.buying_controller import BuyingController
from erpnext.buying.utils import validate_for_items
from six import string_types
STANDARD_USERS = ("Guest", "Administrator")
class RequestforQuotation(BuyingController):
@ -240,7 +242,7 @@ def make_supplier_quotation(source_name, for_supplier, target_doc=None):
# This method is used to make supplier quotation from supplier's portal.
@frappe.whitelist()
def create_supplier_quotation(doc):
if isinstance(doc, basestring):
if isinstance(doc, string_types):
doc = json.loads(doc)
try:

View File

@ -52,7 +52,7 @@ def make_variant_based_on_manufacturer(template, manufacturer, manufacturer_part
return variant
def validate_item_variant_attributes(item, args=None):
if isinstance(item, basestring):
if isinstance(item, string_types):
item = frappe.get_doc('Item', item)
if not args:

View File

@ -7,6 +7,8 @@ from frappe.utils.nestedset import get_root_of
from frappe.utils import cint
from erpnext.accounts.doctype.pos_profile.pos_profile import get_item_groups
from six import string_types
@frappe.whitelist()
def get_items(start, page_length, price_list, item_group, search_value="", pos_profile=None):
serial_no = ""
@ -90,7 +92,7 @@ def get_conditions(item_code, serial_no, batch_no, barcode):
@frappe.whitelist()
def submit_invoice(doc,is_saved):
if isinstance(doc, basestring):
if isinstance(doc, string_types):
args = json.loads(doc)
if(cint(is_saved) == 1):

View File

@ -7,6 +7,8 @@ import json
from frappe.model.document import Document
from frappe.utils.jinja import validate_template
from six import string_types
class TermsandConditions(Document):
def validate(self):
if self.terms:
@ -14,7 +16,7 @@ class TermsandConditions(Document):
@frappe.whitelist()
def get_terms_and_conditions(template_name, doc):
if isinstance(doc, basestring):
if isinstance(doc, string_types):
doc = json.loads(doc)
terms_and_conditions = frappe.get_doc("Terms and Conditions", template_name)

View File

@ -15,6 +15,8 @@ from erpnext.controllers.buying_controller import BuyingController
from erpnext.manufacturing.doctype.production_order.production_order import get_item_details
from erpnext.buying.utils import check_for_closed_status, validate_for_items
from six import string_types
form_grid_templates = {
"items": "templates/form_grid/material_request_grid.html"
}
@ -275,7 +277,7 @@ def make_request_for_quotation(source_name, target_doc=None):
@frappe.whitelist()
def make_purchase_order_based_on_supplier(source_name, target_doc=None):
if target_doc:
if isinstance(target_doc, basestring):
if isinstance(target_doc, string_types):
import json
target_doc = frappe.get_doc(json.loads(target_doc))
target_doc.set("items", [])

View File

@ -872,7 +872,7 @@ class StockEntry(StockController):
@frappe.whitelist()
def move_sample_to_retention_warehouse(company, items):
if isinstance(items, basestring):
if isinstance(items, string_types):
items = json.loads(items)
retention_warehouse = frappe.db.get_single_value('Stock Settings', 'sample_retention_warehouse')
stock_entry = frappe.new_doc("Stock Entry")

View File

@ -4,6 +4,8 @@
import frappe, erpnext
from frappe.utils import cint, flt
from six import string_types
@frappe.whitelist()
def make_stock_entry(**args):
'''Helper function to make a Stock Entry
@ -49,7 +51,7 @@ def make_stock_entry(**args):
if args.item_code:
args.item = args.item_code
if isinstance(args.qty, basestring):
if isinstance(args.qty, string_types):
if '.' in args.qty:
args.qty = flt(args.qty)
else:

View File

@ -8,6 +8,8 @@ from frappe import _
from frappe.utils import cstr, now_datetime, cint, flt, get_time
from erpnext.controllers.status_updater import StatusUpdater
from six import string_types
class UOMMustBeIntegerError(frappe.ValidationError): pass
class TransactionBase(StatusUpdater):
@ -139,7 +141,7 @@ def delete_events(ref_type, ref_name):
where ref_type=%s and ref_name=%s""", (ref_type, ref_name)), for_reload=True)
def validate_uom_is_integer(doc, uom_field, qty_fields, child_dt=None):
if isinstance(qty_fields, basestring):
if isinstance(qty_fields, string_types):
qty_fields = [qty_fields]
distinct_uoms = list(set([d.get(uom_field) for d in doc.get_all_children()]))