From 5cf536b39d84d7c18ade866f79a4def61eb275d5 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Tue, 13 Feb 2018 19:05:54 +0530 Subject: [PATCH 1/3] Fixed iteritems and exceptions --- erpnext/accounts/doctype/tax_rule/tax_rule.py | 4 +++- erpnext/hr/doctype/payroll_entry/test_payroll_entry.py | 6 +++--- erpnext/patches/v4_0/validate_v3_patch.py | 2 +- erpnext/stock/doctype/stock_entry/test_stock_entry.py | 4 +++- erpnext/stock/stock_ledger.py | 4 +++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/tax_rule/tax_rule.py b/erpnext/accounts/doctype/tax_rule/tax_rule.py index 2e92e05458..028fa723dd 100644 --- a/erpnext/accounts/doctype/tax_rule/tax_rule.py +++ b/erpnext/accounts/doctype/tax_rule/tax_rule.py @@ -11,6 +11,8 @@ from frappe.contacts.doctype.address.address import get_default_address from frappe.utils.nestedset import get_root_of from erpnext.setup.doctype.customer_group.customer_group import get_parent_customer_groups +from six import iteritems + class IncorrectCustomerGroup(frappe.ValidationError): pass class IncorrectSupplierType(frappe.ValidationError): pass class ConflictingTaxRule(frappe.ValidationError): pass @@ -133,7 +135,7 @@ def get_tax_template(posting_date, args): conditions = ["""(from_date is null or from_date <= '{0}') and (to_date is null or to_date >= '{0}')""".format(posting_date)] - for key, value in args.iteritems(): + for key, value in iteritems(args): if key=="use_for_shopping_cart": conditions.append("use_for_shopping_cart = {0}".format(1 if value else 0)) if key == 'customer_group': 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") diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index b2f85d0a9e..be92ce1308 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -17,9 +17,11 @@ from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry from erpnext.accounts.doctype.account.test_account import get_inventory_account from erpnext.stock.doctype.stock_entry.stock_entry import move_sample_to_retention_warehouse +from six import iteritems + def get_sle(**args): condition, values = "", [] - for key, value in args.iteritems(): + for key, value in iteritems(args.iteritems): condition += " and " if condition else " where " condition += "`{0}`=%s".format(key) values.append(value) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 956f976d70..4d4435ef82 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -8,6 +8,8 @@ from frappe.utils import cint, flt, cstr, now from erpnext.stock.utils import get_valuation_method import json +from six import iteritems + # future reposting class NegativeStockError(frappe.ValidationError): pass @@ -87,7 +89,7 @@ class update_entries_after(object): "allow_negative_stock")) self.args = args - for key, value in args.iteritems(): + for key, value in iteritems(args): setattr(self, key, value) self.previous_sle = self.get_sle_before_datetime() From c67b1258dd7899219efb479f945493f8867eeb73 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Wed, 14 Feb 2018 16:13:37 +0530 Subject: [PATCH 2/3] python3-fixes From 4b847f78979c260ba4c1ba95c35cca2a53296b46 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Wed, 14 Feb 2018 16:44:58 +0530 Subject: [PATCH 3/3] fixed iteritems --- erpnext/stock/doctype/stock_entry/test_stock_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index be92ce1308..2da9f35ccc 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -21,7 +21,7 @@ from six import iteritems def get_sle(**args): condition, values = "", [] - for key, value in iteritems(args.iteritems): + for key, value in iteritems(args): condition += " and " if condition else " where " condition += "`{0}`=%s".format(key) values.append(value)