Updated Python 3 fixes
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py b/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py
index 9e3388b..eb3e7ff 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py
@@ -12,6 +12,8 @@
from frappe.utils.csvutils import read_csv_content
import frappe
+from six import iteritems
+
path = "/Users/nabinhait/projects/odoo/addons"
accounts = {}
@@ -137,7 +139,7 @@
def make_maps_for_xml(xml_roots, account_types, country_dir):
"""make maps for `charts` and `accounts`"""
- for model, root_list in xml_roots.iteritems():
+ for model, root_list in iteritems(xml_roots):
for root in root_list:
for node in root[0].findall("record"):
if node.get("model")=="account.account.template":
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 9a28946..addffac 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -11,7 +11,7 @@
from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amount
from erpnext.hr.doctype.employee_loan.employee_loan import update_disbursement_status
-from six import string_types
+from six import string_types, iteritems
class JournalEntry(AccountsController):
def __init__(self, *args, **kwargs):
@@ -230,7 +230,7 @@
def validate_orders(self):
"""Validate totals, closed and docstatus for orders"""
- for reference_name, total in self.reference_totals.iteritems():
+ for reference_name, total in iteritems(self.reference_totals):
reference_type = self.reference_types[reference_name]
account = self.reference_accounts[reference_name]
@@ -262,7 +262,7 @@
def validate_invoices(self):
"""Validate totals and docstatus for invoices"""
- for reference_name, total in self.reference_totals.iteritems():
+ for reference_name, total in iteritems(self.reference_totals):
reference_type = self.reference_types[reference_name]
if reference_type in ("Sales Invoice", "Purchase Invoice"):
diff --git a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py
index 54a7520..9a1fc7a 100644
--- a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py
+++ b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py
@@ -9,6 +9,8 @@
test_records = frappe.get_test_records('Tax Rule')
+from six import iteritems
+
class TestTaxRule(unittest.TestCase):
def setUp(self):
frappe.db.sql("delete from `tabTax Rule`")
@@ -129,7 +131,7 @@
tax_rule = frappe.new_doc("Tax Rule")
- for key, val in args.iteritems():
+ for key, val in iteritems(args):
if key != "save":
tax_rule.set(key, val)
diff --git a/erpnext/demo/setup/manufacture.py b/erpnext/demo/setup/manufacture.py
index 24ffd92..1081c40 100644
--- a/erpnext/demo/setup/manufacture.py
+++ b/erpnext/demo/setup/manufacture.py
@@ -122,7 +122,7 @@
}
for price_list in ("standard_buying", "standard_selling"):
- for item, rate in locals().get(price_list).iteritems():
+ for item, rate in iteritems(locals().get(price_list)):
frappe.get_doc({
"doctype": "Item Price",
"price_list": price_list.replace("_", " ").title(),
diff --git a/erpnext/patches/v4_0/import_country_codes.py b/erpnext/patches/v4_0/import_country_codes.py
index 5e9f3b4..43e23d5 100644
--- a/erpnext/patches/v4_0/import_country_codes.py
+++ b/erpnext/patches/v4_0/import_country_codes.py
@@ -6,8 +6,10 @@
from frappe.geo.country_info import get_all
from frappe.utils.install import import_country_and_currency
+from six import iteritems
+
def execute():
frappe.reload_doc("setup", "doctype", "country")
import_country_and_currency()
- for name, country in get_all().iteritems():
+ for name, country in iteritems(get_all()):
frappe.set_value("Country", name, "code", country.get("code"))
\ No newline at end of file
diff --git a/erpnext/patches/v4_4/make_email_accounts.py b/erpnext/patches/v4_4/make_email_accounts.py
index 510fe3a..d055fce 100644
--- a/erpnext/patches/v4_4/make_email_accounts.py
+++ b/erpnext/patches/v4_4/make_email_accounts.py
@@ -1,6 +1,8 @@
import frappe
from frappe.model import default_fields
+from six import iteritems
+
def execute():
frappe.reload_doc("email", "doctype", "email_account")
@@ -19,7 +21,7 @@
"use_tls": "use_ssl"
}
- for target_fieldname, source_fieldname in mapping.iteritems():
+ for target_fieldname, source_fieldname in iteritems(mapping):
account.set(target_fieldname, outgoing.get(source_fieldname))
account.enable_outgoing = 1
@@ -42,7 +44,7 @@
"auto_reply_message": "support_autoreply"
}
- for target_fieldname, source_fieldname in mapping.iteritems():
+ for target_fieldname, source_fieldname in iteritems(mapping):
account.set(target_fieldname, support.get(source_fieldname))
account.enable_outgoing = 0
@@ -63,7 +65,7 @@
"use_ssl": "use_ssl",
}
- for target_fieldname, source_fieldname in mapping.iteritems():
+ for target_fieldname, source_fieldname in iteritems(mapping):
account.set(target_fieldname, source.get(source_fieldname))
account.enable_outgoing = 0
diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py
index 979c4fc..049c943 100644
--- a/erpnext/projects/doctype/project/project.py
+++ b/erpnext/projects/doctype/project/project.py
@@ -11,6 +11,8 @@
from erpnext.controllers.queries import get_filters_cond
from frappe.desk.reportview import get_match_cond
+from six import iteritems
+
class Project(Document):
def get_feed(self):
return '{0}: {1}'.format(_(self.status), self.project_name)
@@ -257,7 +259,7 @@
dependency_map[task.title] = [ x['subject'] for x in frappe.get_list(
'Task Depends On', {"parent": name}, ['subject'])]
- for key, value in dependency_map.iteritems():
+ for key, value in iteritems(dependency_map):
task_name = frappe.db.get_value('Task', {"subject": key, "project": self.name })
task_doc = frappe.get_doc('Task', task_name)
diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py
index 45546e3..887a9e4 100644
--- a/erpnext/selling/doctype/customer/test_customer.py
+++ b/erpnext/selling/doctype/customer/test_customer.py
@@ -17,6 +17,8 @@
test_dependencies = ['Payment Term', 'Payment Terms Template']
test_records = frappe.get_test_records('Customer')
+from six import iteritems
+
class TestCustomer(unittest.TestCase):
def setUp(self):
if not frappe.get_value('Item', '_Test Item'):
@@ -51,7 +53,7 @@
details = get_party_details("_Test Customer")
- for key, value in to_check.iteritems():
+ for key, value in iteritems(to_check):
self.assertEquals(value, details.get(key))
def test_rename(self):
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 27f2c7b..9758b93 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -19,6 +19,8 @@
from frappe.website.render import clear_cache
from frappe.website.website_generator import WebsiteGenerator
+from six import iteritems
+
class DuplicateReorderRows(frappe.ValidationError):
pass
@@ -720,7 +722,7 @@
and posting_date > date_sub(curdate(), interval 1 year)
group by posting_date''', name))
- for date, count in items.iteritems():
+ for date, count in iteritems(items):
timestamp = get_timestamp(date)
out.update({timestamp: count})
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index 7241be3..8a436fd 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -14,6 +14,8 @@
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.stock.get_item_details import get_item_details
+from six import iteritems
+
test_ignore = ["BOM"]
test_dependencies = ["Warehouse"]
@@ -97,7 +99,7 @@
"ignore_pricing_rule": 1
})
- for key, value in to_check.iteritems():
+ for key, value in iteritems(to_check):
self.assertEquals(value, details.get(key))
def test_item_attribute_change_after_variant(self):
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 5a884ad..35d76a5 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -12,7 +12,7 @@
from erpnext.stock.doctype.batch.batch import get_batch_no
from erpnext import get_company_currency
-from six import string_types
+from six import string_types, iteritems
@frappe.whitelist()
def get_item_details(args):
@@ -71,7 +71,7 @@
out.update(get_bin_details(args.item_code, out.warehouse))
# update args with out, if key or value not exists
- for key, value in out.iteritems():
+ for key, value in iteritems(out):
if args.get(key) is None:
args[key] = value
diff --git a/erpnext/stock/report/bom_search/bom_search.py b/erpnext/stock/report/bom_search/bom_search.py
index 828ae16..e3955c9 100644
--- a/erpnext/stock/report/bom_search/bom_search.py
+++ b/erpnext/stock/report/bom_search/bom_search.py
@@ -4,6 +4,8 @@
from __future__ import unicode_literals
import frappe, json
+from six import iteritems
+
def execute(filters=None):
data = []
parents = {
@@ -18,9 +20,9 @@
for d in frappe.get_all(doctype, fields=["parent", "item_code"]):
all_boms.setdefault(d.parent, []).append(d.item_code)
- for parent, items in all_boms.iteritems():
+ for parent, items in iteritems(all_boms):
valid = True
- for key, item in filters.iteritems():
+ for key, item in iteritems(filters):
if key != "search_sub_assemblies":
if item and item not in items:
valid = False
diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py
index 2948119..a529891 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.py
+++ b/erpnext/stock/report/stock_balance/stock_balance.py
@@ -6,6 +6,8 @@
from frappe import _
from frappe.utils import flt, cint, getdate
+from six import iteritems
+
def execute(filters=None):
if not filters: filters = {}
@@ -208,7 +210,7 @@
if filters.get('show_variant_attributes', 0) == 1:
variant_values = get_variant_values_for(item_details.keys())
- item_details = {k: v.update(variant_values.get(k, {})) for k, v in item_details.iteritems()}
+ item_details = {k: v.update(variant_values.get(k, {})) for k, v in iteritems(item_details)}
return item_details