Table Field Renaming: code replace, JV and budget distribution renamed

This commit is contained in:
Nabin Hait
2014-12-25 16:01:55 +05:30
parent d8f4984d71
commit e7d153624f
222 changed files with 1523 additions and 1483 deletions

View File

@@ -42,18 +42,18 @@ def set_item_in_cart(item_code, qty, user=None):
validate_item(item_code)
quotation = get_quotation(user=user)
qty = flt(qty)
quotation_item = quotation.get("quotation_details", {"item_code": item_code})
quotation_item = quotation.get("items", {"item_code": item_code})
if qty==0:
if quotation_item:
# remove
quotation.get("quotation_details").remove(quotation_item[0])
quotation.get("items").remove(quotation_item[0])
else:
# add or update
if quotation_item:
quotation_item[0].qty = qty
else:
quotation.append("quotation_details", {
quotation.append("items", {
"doctype": "Quotation Item",
"item_code": item_code,
"qty": qty

View File

@@ -14,7 +14,7 @@ class WebsitePriceListMissingError(frappe.ValidationError): pass
def set_cart_count(quotation=None):
if not quotation:
quotation = _get_cart_quotation()
cart_count = cstr(len(quotation.get("quotation_details")))
cart_count = cstr(len(quotation.get("items")))
frappe.local.cookie_manager.set_cookie("cart_count", cart_count)
@frappe.whitelist()
@@ -50,7 +50,7 @@ def place_order():
from erpnext.selling.doctype.quotation.quotation import _make_sales_order
sales_order = frappe.get_doc(_make_sales_order(quotation.name, ignore_permissions=True))
for item in sales_order.get("sales_order_details"):
for item in sales_order.get("items"):
item.reserved_warehouse = frappe.db.get_value("Item", item.item_code, "website_warehouse") or None
sales_order.ignore_permissions = True
@@ -66,15 +66,15 @@ def update_cart(item_code, qty, with_doc):
qty = flt(qty)
if qty == 0:
quotation.set("quotation_details", quotation.get("quotation_details", {"item_code": ["!=", item_code]}))
if not quotation.get("quotation_details") and \
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("quotation_details", {"item_code": item_code})
quotation_items = quotation.get("items", {"item_code": item_code})
if not quotation_items:
quotation.append("quotation_details", {
quotation.append("items", {
"doctype": "Quotation Item",
"item_code": item_code,
"qty": qty
@@ -134,13 +134,13 @@ def guess_territory():
def decorate_quotation_doc(quotation_doc):
doc = frappe._dict(quotation_doc.as_dict())
for d in doc.get("quotation_details", []):
for d in doc.get("items", []):
d.update(frappe.db.get_value("Item", d["item_code"],
["website_image", "description", "page_name"], as_dict=True))
d["formatted_rate"] = fmt_money(d.get("rate"), currency=doc.currency)
d["formatted_amount"] = fmt_money(d.get("amount"), currency=doc.currency)
for d in doc.get("other_charges", []):
for d in doc.get("taxes", []):
d["formatted_tax_amount"] = fmt_money(flt(d.get("tax_amount")) / doc.conversion_rate,
currency=doc.currency)
@@ -239,7 +239,7 @@ def set_price_list_and_rate(quotation, cart_settings, billing_territory):
# reset values
quotation.price_list_currency = quotation.currency = \
quotation.plc_conversion_rate = quotation.conversion_rate = None
for item in quotation.get("quotation_details"):
for item in quotation.get("items"):
item.price_list_rate = item.discount_percentage = item.rate = item.amount = None
# refetch values
@@ -253,10 +253,10 @@ def set_taxes(quotation, cart_settings, billing_territory):
quotation.taxes_and_charges = cart_settings.get_tax_master(billing_territory)
# clear table
quotation.set("other_charges", [])
quotation.set("taxes", [])
# append taxes
quotation.append_taxes_from_master("other_charges", "taxes_and_charges")
quotation.append_taxes_from_master("taxes", "taxes_and_charges")
def get_lead_or_customer():
customer = frappe.db.get_value("Contact", {"email_id": frappe.session.user}, "customer")

View File

@@ -190,7 +190,7 @@ def set_price_list(quotation):
if previous_selling_price_list != quotation.selling_price_list:
quotation.price_list_currency = quotation.currency = quotation.plc_conversion_rate = quotation.conversion_rate = None
for d in quotation.get("quotation_details"):
for d in quotation.get("items"):
d.price_list_rate = d.discount_percentage = d.rate = d.amount = None
quotation.set_price_list_and_item_details()

View File

@@ -61,18 +61,18 @@ class TestShoppingCart(unittest.TestCase):
# add first item
set_item_in_cart("_Test Item", 1)
quotation = self.test_get_cart_lead()
self.assertEquals(quotation.get("quotation_details")[0].item_code, "_Test Item")
self.assertEquals(quotation.get("quotation_details")[0].qty, 1)
self.assertEquals(quotation.get("quotation_details")[0].amount, 10)
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
set_item_in_cart("_Test Item 2", 1)
quotation = self.test_get_cart_lead()
self.assertEquals(quotation.get("quotation_details")[1].item_code, "_Test Item 2")
self.assertEquals(quotation.get("quotation_details")[1].qty, 1)
self.assertEquals(quotation.get("quotation_details")[1].amount, 20)
self.assertEquals(quotation.get("items")[1].item_code, "_Test Item 2")
self.assertEquals(quotation.get("items")[1].qty, 1)
self.assertEquals(quotation.get("items")[1].amount, 20)
self.assertEquals(len(quotation.get("quotation_details")), 2)
self.assertEquals(len(quotation.get("items")), 2)
def test_update_cart(self):
# first, add to cart
@@ -81,11 +81,11 @@ class TestShoppingCart(unittest.TestCase):
# update first item
set_item_in_cart("_Test Item", 5)
quotation = self.test_get_cart_lead()
self.assertEquals(quotation.get("quotation_details")[0].item_code, "_Test Item")
self.assertEquals(quotation.get("quotation_details")[0].qty, 5)
self.assertEquals(quotation.get("quotation_details")[0].amount, 50)
self.assertEquals(quotation.get("items")[0].item_code, "_Test Item")
self.assertEquals(quotation.get("items")[0].qty, 5)
self.assertEquals(quotation.get("items")[0].amount, 50)
self.assertEquals(quotation.net_total, 70)
self.assertEquals(len(quotation.get("quotation_details")), 2)
self.assertEquals(len(quotation.get("items")), 2)
def test_remove_from_cart(self):
# first, add to cart
@@ -94,17 +94,17 @@ class TestShoppingCart(unittest.TestCase):
# remove first item
set_item_in_cart("_Test Item", 0)
quotation = self.test_get_cart_lead()
self.assertEquals(quotation.get("quotation_details")[0].item_code, "_Test Item 2")
self.assertEquals(quotation.get("quotation_details")[0].qty, 1)
self.assertEquals(quotation.get("quotation_details")[0].amount, 20)
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)
self.assertEquals(quotation.net_total, 20)
self.assertEquals(len(quotation.get("quotation_details")), 1)
self.assertEquals(len(quotation.get("items")), 1)
# remove second item
set_item_in_cart("_Test Item 2", 0)
quotation = self.test_get_cart_lead()
self.assertEquals(quotation.net_total, 0)
self.assertEquals(len(quotation.get("quotation_details")), 0)
self.assertEquals(len(quotation.get("items")), 0)
def test_set_billing_address(self):
return