From b72303321300d38aaff2206ea5c2bc68410f37c5 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Wed, 14 Feb 2018 16:13:37 +0530 Subject: [PATCH 1/2] python3-fixes --- erpnext/hr/doctype/payroll_entry/test_payroll_entry.py | 6 +++--- erpnext/patches/v4_0/validate_v3_patch.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py index 21b0d58a22..52735efe64 100644 --- a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py +++ b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py @@ -167,9 +167,9 @@ def make_holiday(holiday_list_name): current_fiscal_year = get_fiscal_year(nowdate(), as_dict=True) dt = getdate(nowdate()) - new_year = dt + relativedelta(month=01, day=01, year=dt.year) - republic_day = dt + relativedelta(month=01, day=26, year=dt.year) - test_holiday = dt + relativedelta(month=02, day=02, year=dt.year) + new_year = dt + relativedelta(month=1, day=1, year=dt.year) + republic_day = dt + relativedelta(month=1, day=26, year=dt.year) + test_holiday = dt + relativedelta(month=2, day=2, year=dt.year) frappe.get_doc({ 'doctype': 'Holiday List', diff --git a/erpnext/patches/v4_0/validate_v3_patch.py b/erpnext/patches/v4_0/validate_v3_patch.py index 5f72847dcd..3df39edea6 100644 --- a/erpnext/patches/v4_0/validate_v3_patch.py +++ b/erpnext/patches/v4_0/validate_v3_patch.py @@ -8,4 +8,4 @@ def execute(): from frappe.modules.patch_handler import executed last_v3_patch = 'patches.1401.fix_pos_outstanding' if not executed(last_v3_patch): - raise Exception, "site not ready to migrate to version 4" + raise Exception("site not ready to migrate to version 4") From 1697a7aa81d24596dac6e1f0064ad98faebd94a0 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Thu, 15 Feb 2018 11:39:45 +0530 Subject: [PATCH 2/2] replaced string_types with basestring --- .../accounts/doctype/pricing_rule/pricing_rule.py | 2 +- erpnext/accounts/doctype/sales_invoice/pos.py | 12 +++++++----- .../request_for_quotation/request_for_quotation.py | 4 +++- erpnext/controllers/item_variant.py | 2 +- erpnext/selling/page/point_of_sale/point_of_sale.py | 4 +++- .../terms_and_conditions/terms_and_conditions.py | 4 +++- .../doctype/material_request/material_request.py | 4 +++- erpnext/stock/doctype/stock_entry/stock_entry.py | 2 +- .../stock/doctype/stock_entry/stock_entry_utils.py | 4 +++- erpnext/utilities/transaction_base.py | 4 +++- 10 files changed, 28 insertions(+), 14 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index c26cb92603..1087878716 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -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 = [] diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index 20eb14b26d..be6078a871 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -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) diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index 97c4438dd3..d57cd7d873 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -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: diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py index 547044669a..e8260d9e3d 100644 --- a/erpnext/controllers/item_variant.py +++ b/erpnext/controllers/item_variant.py @@ -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: diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py index 666284f3db..bbfb5adfb9 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -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): diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py index 85cf4dd8d8..a2152a6eb5 100644 --- a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py +++ b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py @@ -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) diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index defce62e2e..32874419c3 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -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", []) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 4915c78865..4de2002c1a 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -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") diff --git a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py index 29e3eb1ab8..8bf261060e 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py @@ -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: diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 0032e80f1e..6594c301ee 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -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()]))