Updated Python 3 fixes

This commit is contained in:
Achilles Rasquinha 2018-02-15 11:28:55 +05:30
parent 806a18b511
commit 714c7465fb
13 changed files with 39 additions and 19 deletions

View File

@ -12,6 +12,8 @@ from xml.etree import ElementTree as ET
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 get_account_types(root_list, csv_content, prefix=None):
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":

View File

@ -11,7 +11,7 @@ from erpnext.accounts.party import get_party_account
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 @@ class JournalEntry(AccountsController):
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 @@ class JournalEntry(AccountsController):
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"):

View File

@ -9,6 +9,8 @@ from erpnext.accounts.doctype.tax_rule.tax_rule import IncorrectCustomerGroup, I
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 @@ def make_tax_rule(**args):
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)

View File

@ -122,7 +122,7 @@ def setup_item_price():
}
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(),

View File

@ -6,8 +6,10 @@ import frappe
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"))

View File

@ -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 @@ def execute():
"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 @@ def execute():
"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 @@ def execute():
"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

View File

@ -11,6 +11,8 @@ from frappe.model.document import Document
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 @@ class Project(Document):
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)

View File

@ -17,6 +17,8 @@ test_ignore = ["Price List"]
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 @@ class TestCustomer(unittest.TestCase):
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):

View File

@ -19,6 +19,8 @@ from frappe.website.doctype.website_slideshow.website_slideshow import \
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 @@ def get_timeline_data(doctype, name):
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})

View File

@ -14,6 +14,8 @@ from frappe.model.rename_doc import rename_doc
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 @@ class TestItem(unittest.TestCase):
"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):

View File

@ -12,7 +12,7 @@ from frappe.model.meta import get_field_precision
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 @@ def get_item_details(args):
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

View File

@ -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 @@ def execute(filters=None):
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

View File

@ -6,6 +6,8 @@ import frappe
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 @@ def get_item_details(filters):
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