[minor] [webshop] [fix]
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js
index 919de22..9c11eea 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/doctype/sales_common/sales_common.js
@@ -492,6 +492,21 @@
}
},
+ shipping_rule: function() {
+ var me = this;
+ if(this.frm.doc.shipping_rule) {
+ this.frm.call({
+ doc: this.frm.doc,
+ method: "apply_shipping_rule",
+ callback: function(r) {
+ if(!r.exc) {
+ me.calculate_taxes_and_totals();
+ }
+ }
+ })
+ }
+ },
+
set_dynamic_labels: function() {
this._super();
set_sales_bom_help(this.frm.doc);
diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt
index 6fc07b6..b59ca94 100644
--- a/setup/doctype/global_defaults/global_defaults.txt
+++ b/setup/doctype/global_defaults/global_defaults.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-02 17:53:24",
"docstatus": 0,
- "modified": "2013-07-05 14:39:17",
+ "modified": "2013-07-15 15:03:01",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -179,7 +179,6 @@
"fieldname": "hr",
"fieldtype": "Section Break",
"label": "HR",
- "options": "<div style=\"padding-top: 8px;\" class=\"columnHeading\">HR</div>",
"read_only": 0
},
{
diff --git a/startup/webutils.py b/startup/webutils.py
index 4c1f528..87d12e4 100644
--- a/startup/webutils.py
+++ b/startup/webutils.py
@@ -82,10 +82,10 @@
phone = party.phone
else:
mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
- "customer": party.name})
+ "customer": party.name}, ["mobile_no", "phone"])
return {
- "company_name": party.customer_name if party.doctype == "Customer" else party.company_name,
- "mobile_no": mobile_no,
- "phone": phone
+ "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
+ "mobile_no": cstr(mobile_no),
+ "phone": cstr(phone)
}
\ No newline at end of file
diff --git a/website/css/website.css b/website/css/website.css
index b71ff13..f2880e8 100644
--- a/website/css/website.css
+++ b/website/css/website.css
@@ -186,3 +186,8 @@
background-color: #a7a9aa;
border-color: #a7a9aa;
}
+
+.breadcrumb {
+ margin: 0 -20px 20px;
+ border-radius: 0px;
+}
\ No newline at end of file
diff --git a/website/doctype/shopping_cart_settings/shopping_cart_settings.js b/website/doctype/shopping_cart_settings/shopping_cart_settings.js
new file mode 100644
index 0000000..74988dc
--- /dev/null
+++ b/website/doctype/shopping_cart_settings/shopping_cart_settings.js
@@ -0,0 +1,7 @@
+$.extend(cur_frm.cscript, {
+ onload: function() {
+ if(cur_frm.doc.__quotation_series) {
+ cur_frm.fields_dict.quotation_series.df.options = cur_frm.doc.__quotation_series;
+ }
+ }
+});
\ No newline at end of file
diff --git a/website/doctype/shopping_cart_settings/shopping_cart_settings.py b/website/doctype/shopping_cart_settings/shopping_cart_settings.py
index 7fe14c3..853eeb4 100644
--- a/website/doctype/shopping_cart_settings/shopping_cart_settings.py
+++ b/website/doctype/shopping_cart_settings/shopping_cart_settings.py
@@ -9,6 +9,9 @@
class ShoppingCartSetupError(webnotes.ValidationError): pass
class DocType(DocListController):
+ def onload(self):
+ self.doc.fields["__quotation_series"] = webnotes.get_doctype("Quotation").get_options("naming_series")
+
def validate(self):
if self.doc.enabled:
self.validate_price_lists()
@@ -17,6 +20,7 @@
def on_update(self):
webnotes.conn.set_default("shopping_cart_enabled", self.doc.fields.get("enabled") or 0)
+ webnotes.conn.set_default("shopping_cart_quotation_series", self.doc.fields.get("quotation_series"))
def validate_overlapping_territories(self, parentfield, fieldname):
# for displaying message
@@ -91,16 +95,17 @@
expected_to_exist = [currency + "-" + company_currency
for currency in price_list_currency_map.values()
if currency != company_currency]
-
- exists = webnotes.conn.sql_list("""select name from `tabCurrency Exchange`
- where name in (%s)""" % (", ".join(["%s"]*len(expected_to_exist)),),
- tuple(expected_to_exist))
+
+ if expected_to_exist:
+ exists = webnotes.conn.sql_list("""select name from `tabCurrency Exchange`
+ where name in (%s)""" % (", ".join(["%s"]*len(expected_to_exist)),),
+ tuple(expected_to_exist))
- missing = list(set(expected_to_exist).difference(exists))
+ missing = list(set(expected_to_exist).difference(exists))
- if missing:
- msgprint(_("Missing Currency Exchange Rates for" + ": " + comma_and(missing)),
- raise_exception=ShoppingCartSetupError)
+ if missing:
+ msgprint(_("Missing Currency Exchange Rates for" + ": " + comma_and(missing)),
+ raise_exception=ShoppingCartSetupError)
def get_name_from_territory(self, territory, parentfield, fieldname):
name = None
diff --git a/website/doctype/shopping_cart_settings/shopping_cart_settings.txt b/website/doctype/shopping_cart_settings/shopping_cart_settings.txt
index 7455864..21e6ee3 100644
--- a/website/doctype/shopping_cart_settings/shopping_cart_settings.txt
+++ b/website/doctype/shopping_cart_settings/shopping_cart_settings.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-06-19 15:57:32",
"docstatus": 0,
- "modified": "2013-07-10 18:42:29",
+ "modified": "2013-07-15 17:33:05",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -80,6 +80,13 @@
},
{
"doctype": "DocField",
+ "fieldname": "quotation_series",
+ "fieldtype": "Select",
+ "label": "Quotation Series",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
"fieldname": "section_break_6",
"fieldtype": "Section Break"
},
diff --git a/website/helpers/cart.py b/website/helpers/cart.py
index ea72e40..2149534 100644
--- a/website/helpers/cart.py
+++ b/website/helpers/cart.py
@@ -58,6 +58,10 @@
qty = flt(qty)
if qty == 0:
quotation.set_doclist(quotation.doclist.get({"item_code": ["!=", item_code]}))
+ if not quotation.doclist.get({"parentfield": "quotation_details"}) and \
+ not quotation.doc.fields.get("__islocal"):
+ quotation.__delete = True
+
else:
quotation_items = quotation.doclist.get({"item_code": item_code})
if not quotation_items:
@@ -72,8 +76,12 @@
apply_cart_settings(quotation=quotation)
- quotation.ignore_permissions = True
- quotation.save()
+ if hasattr(quotation, "__delete"):
+ webnotes.delete_doc("Quotation", quotation.doc.name, ignore_permissions=True)
+ quotation = _get_cart_quotation()
+ else:
+ quotation.ignore_permissions = True
+ quotation.save()
set_cart_count(quotation)
@@ -191,7 +199,7 @@
for d in doclist:
if d.item_code:
d.fields.update(webnotes.conn.get_value("Item", d.item_code,
- ["website_image", "web_short_description", "page_name"], as_dict=True))
+ ["website_image", "description", "page_name"], as_dict=True))
d.formatted_rate = fmt_money(d.export_rate, currency=doclist[0].currency)
d.formatted_amount = fmt_money(d.export_amount, currency=doclist[0].currency)
elif d.charge_type:
@@ -215,7 +223,7 @@
else:
qbean = webnotes.bean({
"doctype": "Quotation",
- "naming_series": "QTN-CART-",
+ "naming_series": webnotes.defaults.get_user_default("shopping_cart_quotation_series") or "QTN-CART-",
"quotation_to": party.doctype,
"company": webnotes.defaults.get_user_default("company"),
"order_type": "Shopping Cart",
@@ -224,7 +232,10 @@
(party.doctype.lower()): party.name
})
- # map_contact_fields(qbean, party)
+ if party.doctype == "Customer":
+ qbean.doc.contact_person = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
+ "customer": party.name})
+ qbean.run_method("set_contact_fields")
qbean.run_method("onload_post_render")
apply_cart_settings(party, qbean)
@@ -259,10 +270,11 @@
party_bean.save()
qbean = _get_cart_quotation(party)
- qbean.doc.customer_name = company_name or fullname
- qbean.run_method("set_contact_fields")
- qbean.ignore_permissions = True
- qbean.save()
+ if not qbean.doc.fields.get("__islocal"):
+ qbean.doc.customer_name = company_name or fullname
+ qbean.run_method("set_contact_fields")
+ qbean.ignore_permissions = True
+ qbean.save()
def apply_cart_settings(party=None, quotation=None):
if not party:
@@ -374,27 +386,26 @@
return territory
-@webnotes.whitelist()
-def checkout():
- quotation = _get_cart_quotation()
-
- quotation.ignore_permissions = True
- quotation.submit()
-
- from selling.doctype.quotation.quotation import make_sales_order
-
- sales_order = webnotes.bean(make_sales_order(quotation.doc.name))
-
- sales_order.ignore_permissions = True
- sales_order.insert()
- sales_order.submit()
-
- return sales_order
-
import unittest
-test_dependencies = ["Item", "Price List", "Contact"]
+test_dependencies = ["Item", "Price List", "Contact", "Shopping Cart Settings"]
class TestCart(unittest.TestCase):
+ def tearDown(self):
+ return
+
+ cart_settings = webnotes.bean("Shopping Cart Settings")
+ cart_settings.ignore_permissions = True
+ cart_settings.doc.enabled = 0
+ cart_settings.save()
+
+ def enable_shopping_cart(self):
+ return
+ if not webnotes.conn.get_value("Shopping Cart Settings", None, "enabled"):
+ cart_settings = webnotes.bean("Shopping Cart Settings")
+ cart_settings.ignore_permissions = True
+ cart_settings.doc.enabled = 1
+ cart_settings.save()
+
def test_get_lead_or_customer(self):
webnotes.session.user = "test@example.com"
party1 = get_lead_or_customer()
@@ -407,7 +418,9 @@
self.assertEquals(party.name, "_Test Customer")
def test_add_to_cart(self):
+ self.enable_shopping_cart()
webnotes.session.user = "test@example.com"
+
update_cart("_Test Item", 1)
quotation = _get_cart_quotation()
@@ -440,8 +453,9 @@
quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"})
self.assertEquals(quotation_items, [])
- def test_checkout(self):
+ def test_place_order(self):
quotation = self.test_update_cart()
- sales_order = checkout()
+ sales_order_name = place_order()
+ sales_order = webnotes.bean("Sales Order", sales_order_name)
self.assertEquals(sales_order.doclist.getone({"item_code": "_Test Item"}).prevdoc_docname, quotation.doc.name)
\ No newline at end of file
diff --git a/website/templates/css/product_page.css b/website/templates/css/product_page.css
index 566b6b5..457fc62 100644
--- a/website/templates/css/product_page.css
+++ b/website/templates/css/product_page.css
@@ -7,4 +7,7 @@
font-size: 18px;
line-height: 200%;
}
+ .item-stock {
+ margin-bottom: 10px !important;
+ }
</style>
\ No newline at end of file
diff --git a/website/templates/html/product_page.html b/website/templates/html/product_page.html
index 73520ef..4f04cec 100644
--- a/website/templates/html/product_page.html
+++ b/website/templates/html/product_page.html
@@ -32,8 +32,7 @@
<p class="help">Item Code: <span itemprop="productID">{{ name }}</span></p>
<h4>Product Description</h4>
<div itemprop="description">
- {{ web_long_description or web_short_description or description or
- "[No description given]" }}
+ {{ web_long_description or description or "[No description given]" }}
</div>
<div style="min-height: 100px; margin: 10px 0;">
<div class="item-price-info" style="display: none;">
diff --git a/website/templates/js/cart.js b/website/templates/js/cart.js
index bb3fcb9..2f5ad31 100644
--- a/website/templates/js/cart.js
+++ b/website/templates/js/cart.js
@@ -143,7 +143,7 @@
'<div style="height: 120px; overflow: hidden;"><img src="' + doc.image + '" /></div>' :
'{% include "app/website/templates/html/product_missing_image.html" %}';
- if(!doc.web_short_description) doc.web_short_description = doc.description;
+ if(doc.description === doc.item_name) doc.description = "";
$(repl('<div class="row">\
<div class="col col-lg-9 col-sm-9">\
@@ -151,7 +151,7 @@
<div class="col col-lg-3">%(image_html)s</div>\
<div class="col col-lg-9">\
<h4><a href="%(page_name)s">%(item_name)s</a></h4>\
- <p>%(web_short_description)s</p>\
+ <p>%(description)s</p>\
</div>\
</div>\
</div>\