[test-fixes]
diff --git a/erpnext/accounts/doctype/tax_rule/tax_rule.py b/erpnext/accounts/doctype/tax_rule/tax_rule.py
index 1e306e9..bcbd559 100644
--- a/erpnext/accounts/doctype/tax_rule/tax_rule.py
+++ b/erpnext/accounts/doctype/tax_rule/tax_rule.py
@@ -5,7 +5,6 @@
from __future__ import unicode_literals
import frappe
from frappe import _
-from frappe.model import default_fields
from frappe.model.document import Document
from frappe.utils import cstr
@@ -121,7 +120,10 @@
conditions = []
for key, value in args.iteritems():
- conditions.append("ifnull({0}, '') in ('', '{1}')".format(key, frappe.db.escape(cstr(value))))
+ if key in "use_for_shopping_cart":
+ conditions.append("use_for_shopping_cart = {0}".format(1 if value else 0))
+ else:
+ conditions.append("ifnull({0}, '') in ('', '{1}')".format(key, frappe.db.escape(cstr(value))))
matching = frappe.db.sql("""select * from `tabTax Rule`
where {0}""".format(" and ".join(conditions)), as_dict = True)
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 9596b44..baa237e 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -280,7 +280,7 @@
billing_address=None, shipping_address=None, use_for_shopping_cart=None):
from erpnext.accounts.doctype.tax_rule.tax_rule import get_tax_template, get_party_details
args = {
- party_type: party,
+ party_type.lower(): party,
"customer_group": customer_group,
"supplier_type": supplier_type,
"company": company
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index b6acf20..c4f3db0 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -73,10 +73,6 @@
qty = flt(qty)
if qty == 0:
quotation.set("items", quotation.get("items", {"item_code": ["!=", item_code]}))
- if not quotation.get("items") and \
- not quotation.get("__islocal"):
- quotation.__delete = True
-
else:
quotation_items = quotation.get("items", {"item_code": item_code})
if not quotation_items:
@@ -90,16 +86,11 @@
apply_cart_settings(quotation=quotation)
- if hasattr(quotation, "__delete"):
- frappe.delete_doc("Quotation", quotation.name, ignore_permissions=True)
- quotation = _get_cart_quotation()
- else:
- quotation.flags.ignore_permissions = True
- quotation.save()
+ quotation.flags.ignore_permissions = True
+ quotation.save()
set_cart_count(quotation)
-
if with_items:
context = get_cart_quotation(quotation)
return {
@@ -160,11 +151,12 @@
if not party:
party = get_customer()
- quotation = frappe.db.get_value("Quotation",
- {party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0})
+ quotation = frappe.get_all("Quotation", fields=["name"], filters=
+ {party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0},
+ order_by="modified desc", limit_page_length=1)
if quotation:
- qdoc = frappe.get_doc("Quotation", quotation)
+ qdoc = frappe.get_doc("Quotation", quotation[0].name)
else:
qdoc = frappe.get_doc({
"doctype": "Quotation",
diff --git a/erpnext/shopping_cart/test_shopping_cart.py b/erpnext/shopping_cart/test_shopping_cart.py
index 61536ac..41f7442 100644
--- a/erpnext/shopping_cart/test_shopping_cart.py
+++ b/erpnext/shopping_cart/test_shopping_cart.py
@@ -52,11 +52,14 @@
# add first item
update_cart("_Test Item", 1)
+
quotation = self.test_get_cart_customer()
+
self.assertEquals(quotation.get("items")[0].item_code, "_Test Item")
self.assertEquals(quotation.get("items")[0].qty, 1)
self.assertEquals(quotation.get("items")[0].amount, 10)
+
# add second item
update_cart("_Test Item 2", 1)
quotation = self.test_get_cart_customer()
@@ -86,6 +89,7 @@
# remove first item
update_cart("_Test Item", 0)
quotation = self.test_get_cart_customer()
+
self.assertEquals(quotation.get("items")[0].item_code, "_Test Item 2")
self.assertEquals(quotation.get("items")[0].qty, 1)
self.assertEquals(quotation.get("items")[0].amount, 20)
@@ -149,16 +153,29 @@
def enable_shopping_cart(self):
settings = frappe.get_doc("Shopping Cart Settings", "Shopping Cart Settings")
- if settings.get("price_lists"):
- settings.enabled = 1
- else:
- settings.update({
- "enabled": 1,
- "company": "_Test Company",
- "default_customer_group": "_Test Customer Group",
- "quotation_series": "_T-Quotation-",
- "price_list": "_Test Price List India"
- })
+ settings.update({
+ "enabled": 1,
+ "company": "_Test Company",
+ "default_customer_group": "_Test Customer Group",
+ "quotation_series": "_T-Quotation-",
+ "price_list": "_Test Price List India"
+ })
+
+ # insert item price
+ if not frappe.db.get_value("Item Price", {"price_list": "_Test Price List India",
+ "item_code": "_Test Item"}):
+ frappe.get_doc({
+ "doctype": "Item Price",
+ "price_list": "_Test Price List India",
+ "item_code": "_Test Item",
+ "price_list_rate": 10
+ }).insert()
+ frappe.get_doc({
+ "doctype": "Item Price",
+ "price_list": "_Test Price List India",
+ "item_code": "_Test Item 2",
+ "price_list_rate": 20
+ }).insert()
settings.save()
frappe.local.shopping_cart_settings = None