fix: Python 3 compatibility fixes (#18024)
fix: Python 3 compatibility fixes
This commit is contained in:
@@ -373,7 +373,7 @@ def apply_internal_priority(pricing_rules, field_set, args):
|
|||||||
filtered_rules = []
|
filtered_rules = []
|
||||||
for field in field_set:
|
for field in field_set:
|
||||||
if args.get(field):
|
if args.get(field):
|
||||||
filtered_rules = filter(lambda x: x[field]==args[field], pricing_rules)
|
filtered_rules = list(filter(lambda x: x[field]==args[field], pricing_rules))
|
||||||
if filtered_rules: break
|
if filtered_rules: break
|
||||||
|
|
||||||
return filtered_rules or pricing_rules
|
return filtered_rules or pricing_rules
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ class TestSalesPaymentSummary(unittest.TestCase):
|
|||||||
pe.submit()
|
pe.submit()
|
||||||
|
|
||||||
mop = get_mode_of_payments(filters)
|
mop = get_mode_of_payments(filters)
|
||||||
self.assertTrue('Credit Card' in mop.values()[0])
|
self.assertTrue('Credit Card' in list(mop.values())[0])
|
||||||
self.assertTrue('Cash' in mop.values()[0])
|
self.assertTrue('Cash' in list(mop.values())[0])
|
||||||
|
|
||||||
# Cancel all Cash payment entry and check if this mode of payment is still fetched.
|
# Cancel all Cash payment entry and check if this mode of payment is still fetched.
|
||||||
payment_entries = frappe.get_all("Payment Entry", filters={"mode_of_payment": "Cash", "docstatus": 1}, fields=["name", "docstatus"])
|
payment_entries = frappe.get_all("Payment Entry", filters={"mode_of_payment": "Cash", "docstatus": 1}, fields=["name", "docstatus"])
|
||||||
@@ -57,8 +57,8 @@ class TestSalesPaymentSummary(unittest.TestCase):
|
|||||||
pe.cancel()
|
pe.cancel()
|
||||||
|
|
||||||
mop = get_mode_of_payments(filters)
|
mop = get_mode_of_payments(filters)
|
||||||
self.assertTrue('Credit Card' in mop.values()[0])
|
self.assertTrue('Credit Card' in list(mop.values())[0])
|
||||||
self.assertTrue('Cash' not in mop.values()[0])
|
self.assertTrue('Cash' not in list(mop.values())[0])
|
||||||
|
|
||||||
def test_get_mode_of_payments_details(self):
|
def test_get_mode_of_payments_details(self):
|
||||||
filters = get_filters()
|
filters = get_filters()
|
||||||
@@ -84,7 +84,7 @@ class TestSalesPaymentSummary(unittest.TestCase):
|
|||||||
|
|
||||||
mopd = get_mode_of_payment_details(filters)
|
mopd = get_mode_of_payment_details(filters)
|
||||||
|
|
||||||
mopd_values = mopd.values()[0]
|
mopd_values = list(mopd.values())[0]
|
||||||
for mopd_value in mopd_values:
|
for mopd_value in mopd_values:
|
||||||
if mopd_value[0] == "Credit Card":
|
if mopd_value[0] == "Credit Card":
|
||||||
cc_init_amount = mopd_value[1]
|
cc_init_amount = mopd_value[1]
|
||||||
@@ -96,7 +96,7 @@ class TestSalesPaymentSummary(unittest.TestCase):
|
|||||||
pe.cancel()
|
pe.cancel()
|
||||||
|
|
||||||
mopd = get_mode_of_payment_details(filters)
|
mopd = get_mode_of_payment_details(filters)
|
||||||
mopd_values = mopd.values()[0]
|
mopd_values = list(mopd.values())[0]
|
||||||
for mopd_value in mopd_values:
|
for mopd_value in mopd_values:
|
||||||
if mopd_value[0] == "Credit Card":
|
if mopd_value[0] == "Credit Card":
|
||||||
cc_final_amount = mopd_value[1]
|
cc_final_amount = mopd_value[1]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from frappe.utils import flt, cint, nowdate
|
|||||||
|
|
||||||
from frappe import throw, _
|
from frappe import throw, _
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate, cint
|
||||||
from erpnext.controllers.buying_controller import BuyingController
|
from erpnext.controllers.buying_controller import BuyingController
|
||||||
from erpnext.accounts.utils import get_account_currency
|
from erpnext.accounts.utils import get_account_currency
|
||||||
from frappe.desk.notifications import clear_doctype_notifications
|
from frappe.desk.notifications import clear_doctype_notifications
|
||||||
@@ -128,7 +128,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
self.company, self.base_grand_total)
|
self.company, self.base_grand_total)
|
||||||
|
|
||||||
self.update_prevdoc_status()
|
self.update_prevdoc_status()
|
||||||
if self.per_billed < 100:
|
if cint(self.per_billed) < 100:
|
||||||
self.update_billing_status()
|
self.update_billing_status()
|
||||||
else:
|
else:
|
||||||
self.status = "Completed"
|
self.status = "Completed"
|
||||||
|
|||||||
@@ -562,7 +562,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
for d in stock_entry.get("items"):
|
for d in stock_entry.get("items"):
|
||||||
if d.item_code != "_Test FG Item 2":
|
if d.item_code != "_Test FG Item 2":
|
||||||
rm_cost += flt(d.amount)
|
rm_cost += flt(d.amount)
|
||||||
fg_cost = filter(lambda x: x.item_code=="_Test FG Item 2", stock_entry.get("items"))[0].amount
|
fg_cost = list(filter(lambda x: x.item_code=="_Test FG Item 2", stock_entry.get("items")))[0].amount
|
||||||
self.assertEqual(fg_cost,
|
self.assertEqual(fg_cost,
|
||||||
flt(rm_cost + bom_operation_cost + work_order.additional_operating_cost, 2))
|
flt(rm_cost + bom_operation_cost + work_order.additional_operating_cost, 2))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user