[fixes] buying/selling price lists, communication and website settings
diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js
index b68627f..3bfa63a 100644
--- a/setup/doctype/price_list/price_list.js
+++ b/setup/doctype/price_list/price_list.js
@@ -21,6 +21,7 @@
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.set_intro("");
if(doc.__islocal) {
+ cur_frm.toggle_display("item_prices_section", false);
cur_frm.set_intro("Save this list to begin.");
return;
} else {
@@ -41,16 +42,12 @@
<thead><tr>\
<th>' + wn._("Item Code") + '</th>\
<th>' + wn._("Price") + '</th>\
- <th>' + wn._("Valid For Selling") + '</th>\
- <th>' + wn._("Valid For Buying") + '</th>\
</tr></thead>\
<tbody>'
+ $.map(item_price.sort(function(a, b) { return a.parent.localeCompare(b.parent); }), function(d) {
return '<tr>'
- + '<td>' + d.parent + '</td>'
+ + '<td><a href="#Form/Item/' + encodeURIComponent(d.parent) +'">' + d.parent + '</a></td>'
+ '<td style="text-align: right;">' + format_currency(d.ref_rate, d.ref_currency) + '</td>'
- + '<td>' + (cint(d.selling) ? '<i class="icon-check"></i>' : "") + '</td>'
- + '<td>' + (cint(d.buying) ? '<i class="icon-check"></i>' : "") + '</td>'
+ '</tr>'
}).join("\n")
+ '</tbody>\
diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py
index 5c03a3a..eae6a3c 100644
--- a/setup/doctype/price_list/price_list.py
+++ b/setup/doctype/price_list/price_list.py
@@ -17,7 +17,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint, _
-from webnotes.utils import cint
+from webnotes.utils import cint, comma_or
class DocType:
@@ -32,6 +32,10 @@
if not (cint(self.doc.valid_for_all_countries) or len(self.doclist.get({"parentfield": "valid_for_countries"}))):
msgprint(_("""Please check "Valid For All Countries" or \
enter atlease one row in the "Countries" table."""), raise_exception=True)
+
+ if self.doc.buying_or_selling not in ["Buying", "Selling"]:
+ msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
+ comma_or(["Buying", "Selling"]), raise_exception=True)
def on_trash(self):
webnotes.conn.sql("""delete from `tabItem Price` where price_list_name = %s""",
diff --git a/setup/doctype/price_list/price_list.txt b/setup/doctype/price_list/price_list.txt
index 781eae5..ed432ec 100644
--- a/setup/doctype/price_list/price_list.txt
+++ b/setup/doctype/price_list/price_list.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-25 11:35:09",
"docstatus": 0,
- "modified": "2013-05-02 14:45:00",
+ "modified": "2013-06-11 20:00:07",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -61,6 +61,26 @@
"reqd": 1
},
{
+ "default": "Selling",
+ "doctype": "DocField",
+ "fieldname": "buying_or_selling",
+ "fieldtype": "Select",
+ "label": "Valid for Buying or Selling?",
+ "options": "Buying\nSelling",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "use_for_website",
+ "fieldtype": "Check",
+ "label": "Use for Website"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "column_break_3",
+ "fieldtype": "Column Break"
+ },
+ {
"default": "1",
"doctype": "DocField",
"fieldname": "valid_for_all_countries",
@@ -68,7 +88,7 @@
"label": "Valid for all countries"
},
{
- "description": "A list of Countries, for which, this Price List is valid",
+ "description": "Or specify a list of Countries, for which, this Price List is valid",
"doctype": "DocField",
"fieldname": "valid_for_countries",
"fieldtype": "Table",
@@ -79,6 +99,7 @@
"doctype": "DocField",
"fieldname": "item_prices_section",
"fieldtype": "Section Break",
+ "hidden": 0,
"label": "Item Prices"
},
{
@@ -88,6 +109,11 @@
"label": "Item Prices"
},
{
+ "doctype": "DocField",
+ "fieldname": "column_break_10",
+ "fieldtype": "Column Break"
+ },
+ {
"depends_on": "eval:!doc.__islocal",
"doctype": "DocField",
"fieldname": "section_break_1",
diff --git a/setup/utils.py b/setup/utils.py
index 33fa3e2..6948117 100644
--- a/setup/utils.py
+++ b/setup/utils.py
@@ -34,16 +34,16 @@
"""
args = {
"price_list_name": "Something",
- "use_for": "buying" or "selling"
+ "buying_or_selling": "Buying" or "Selling"
}
"""
if isinstance(args, basestring):
args = json.loads(args)
result = webnotes.conn.sql("""select distinct ref_currency from `tabItem Price`
- where price_list_name=%s and `%s`=1""" % ("%s", args.get("use_for")),
+ where price_list_name=%s and buying_or_selling=%s""" % ("%s", args.get("buying_or_selling")),
(args.get("price_list_name"),))
if result and len(result)==1:
return {"price_list_currency": result[0][0]}
else:
- return {}
+ return {}
\ No newline at end of file