chore: remove past module dependencies
This commit is contained in:
parent
6098e92ba9
commit
897e90ac55
@ -10,7 +10,6 @@ from frappe.contacts.doctype.address.address import get_default_address
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import cint, cstr
|
||||
from frappe.utils.nestedset import get_root_of
|
||||
from past.builtins import cmp
|
||||
from six import iteritems
|
||||
|
||||
from erpnext.setup.doctype.customer_group.customer_group import get_parent_customer_groups
|
||||
@ -170,6 +169,10 @@ def get_tax_template(posting_date, args):
|
||||
for key in args:
|
||||
if rule.get(key): rule.no_of_keys_matched += 1
|
||||
|
||||
def cmp(a, b):
|
||||
# refernce: https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
|
||||
return int(a > b) - int(a < b)
|
||||
|
||||
rule = sorted(tax_rule,
|
||||
key = functools.cmp_to_key(lambda b, a:
|
||||
cmp(a.no_of_keys_matched, b.no_of_keys_matched) or
|
||||
|
@ -10,7 +10,6 @@ import re
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import add_days, add_months, cint, cstr, flt, formatdate, get_first_day, getdate
|
||||
from past.builtins import cmp
|
||||
from six import itervalues
|
||||
|
||||
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
||||
@ -343,7 +342,7 @@ def sort_accounts(accounts, is_root=False, key="name"):
|
||||
def compare_accounts(a, b):
|
||||
if re.split(r'\W+', a[key])[0].isdigit():
|
||||
# if chart of accounts is numbered, then sort by number
|
||||
return cmp(a[key], b[key])
|
||||
return int(a[key] > b[key]) - int(a[key] < b[key])
|
||||
elif is_root:
|
||||
if a.report_type != b.report_type and a.report_type == "Balance Sheet":
|
||||
return -1
|
||||
@ -355,7 +354,7 @@ def sort_accounts(accounts, is_root=False, key="name"):
|
||||
return -1
|
||||
else:
|
||||
# sort by key (number) or name
|
||||
return cmp(a[key], b[key])
|
||||
return int(a[key] > b[key]) - int(a[key] < b[key])
|
||||
return 1
|
||||
|
||||
accounts.sort(key = functools.cmp_to_key(compare_accounts))
|
||||
|
@ -2,7 +2,6 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
import functools
|
||||
import json
|
||||
import os
|
||||
|
||||
@ -13,7 +12,6 @@ from frappe.cache_manager import clear_defaults_cache
|
||||
from frappe.contacts.address_and_contact import load_address_and_contact
|
||||
from frappe.utils import cint, formatdate, get_timestamp, today
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
from past.builtins import cmp
|
||||
|
||||
from erpnext.accounts.doctype.account.account import get_account_currency
|
||||
from erpnext.setup.setup_wizard.operations.taxes_setup import setup_taxes_and_charges
|
||||
@ -583,7 +581,7 @@ def get_default_company_address(name, sort_key='is_primary_address', existing_ad
|
||||
return existing_address
|
||||
|
||||
if out:
|
||||
return sorted(out, key = functools.cmp_to_key(lambda x,y: cmp(y[1], x[1])))[0][0]
|
||||
return min(out, key=lambda x: x[1])[0] # find min by sort_key
|
||||
else:
|
||||
return None
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user