[FIX] sorting multiple compares

This commit is contained in:
Achilles Rasquinha 2018-02-23 17:22:07 +05:30
parent 5b9f3b0cd3
commit a3555aa7bd
2 changed files with 6 additions and 2 deletions

View File

@ -5,6 +5,8 @@ from __future__ import unicode_literals
import re
import functools
import frappe
from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency
from erpnext.accounts.utils import get_fiscal_year
@ -325,7 +327,7 @@ def sort_root_accounts(roots):
return -1
return 1
roots.sort(compare_roots)
roots.sort(key = functools.cmp_to_key(compare_roots))
def set_gl_entries_by_account(

View File

@ -9,6 +9,8 @@ from erpnext.setup.utils import get_exchange_rate
from frappe.website.website_generator import WebsiteGenerator
from erpnext.stock.get_item_details import get_conversion_factor
import functools
from six import string_types
from operator import itemgetter
@ -585,7 +587,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
@frappe.whitelist()
def get_bom_items(bom, company, qty=1, fetch_exploded=1):
items = get_bom_items_as_dict(bom, company, qty, fetch_exploded).values()
items.sort(lambda a, b: a.item_code > b.item_code and 1 or -1)
items.sort(key = functools.cmp_to_key(lambda a, b: a.item_code > b.item_code and 1 or -1))
return items
def validate_bom_no(item, bom_no):