[fixes] buying/selling price lists, communication and website settings
diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js
index eee7984..4cf8de7 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -28,13 +28,13 @@
if(this.frm.fields_dict.price_list_name) {
this.frm.set_query("price_list_name", function() {
- return repl("select distinct price_list_name from `tabItem Price` \
- where buying = 1 and price_list_name like \"%s%%\"");
+ return repl("select name, currency from `tabPrice List` \
+ where buying_or_selling = 'Buying' and name like \"%s%%\"");
});
this.frm.set_query("price_list_currency", function() {
return repl("select distinct ref_currency from `tabItem Price` \
- where price_list_name=\"%(price_list_name)s\" and buying = 1 \
+ where price_list_name=\"%(price_list_name)s\" and buying_or_selling = 'Buying' \
and ref_currency like \"%s%%\"",
{price_list_name: me.frm.doc.price_list_name});
});
diff --git a/buying/utils.py b/buying/utils.py
index 1aaa5d1..3c8f693 100644
--- a/buying/utils.py
+++ b/buying/utils.py
@@ -102,7 +102,7 @@
"parentfield": "ref_rate_details",
"price_list_name": args.price_list_name,
"ref_currency": args.price_list_currency,
- "buying": 1})
+ "buying_or_selling": "Buying"})
if price_list_rate:
out.import_ref_rate = \
flt(price_list_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate)
diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py
index f417b31..bf5da8d 100644
--- a/controllers/accounts_controller.py
+++ b/controllers/accounts_controller.py
@@ -42,7 +42,7 @@
not self.doc.price_list_currency:
self.doc.fields.update(get_price_list_currency({
"price_list_name": self.doc.price_list_name,
- "use_for": buying_or_selling
+ "buying_or_selling": buying_or_selling
}))
def set_missing_item_details(self, get_item_details):
diff --git a/patches/january_2013/purchase_price_list.py b/patches/january_2013/purchase_price_list.py
index 02c260e..419e709 100644
--- a/patches/january_2013/purchase_price_list.py
+++ b/patches/january_2013/purchase_price_list.py
@@ -4,6 +4,6 @@
webnotes.reload_doc("stock", "doctype", "item_price")
# check for selling
- webnotes.conn.sql("""update `tabItem Price` set selling=1
- where ifnull(selling, 0)=0 and ifnull(buying, 0)=0""")
+ webnotes.conn.sql("""update `tabItem Price` set buying_or_selling = "Selling"
+ where ifnull(buying_or_selling, '')=''""")
\ No newline at end of file
diff --git a/patches/june_2013/p03_buying_selling_for_price_list.py b/patches/june_2013/p03_buying_selling_for_price_list.py
new file mode 100644
index 0000000..a41bda1
--- /dev/null
+++ b/patches/june_2013/p03_buying_selling_for_price_list.py
@@ -0,0 +1,14 @@
+import webnotes
+from webnotes.utils import cint
+
+def execute():
+ for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""):
+ buying, selling = False, False
+ for b, s in webnotes.conn.sql("""select distinct buying, selling
+ from `tabItem Price` where price_list_name=%s""", price_list):
+ buying = buying or cint(b)
+ selling = selling or cint(s)
+
+ webnotes.conn.set_value("Price List", price_list, "buying_or_selling", ("Selling" if selling else "Buying"))
+ webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s where price_list_name=%s""",
+ (("Selling" if selling else "Buying"), price_list))
diff --git a/patches/patch_list.py b/patches/patch_list.py
index a1012ba..035666c 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -241,7 +241,8 @@
"patches.june_2013.p01_update_bom_exploded_items",
"patches.june_2013.p02_update_project_completed",
"execute:webnotes.delete_doc('DocType', 'System Console')",
+ "patches.june_2013.p03_buying_selling_for_price_list",
"patches.june_2013.p04_fix_event_for_lead_oppty_project",
"patches.june_2013.p05_remove_unused_doctypes",
- "patches.june_2013.p06_drop_unused_tables"
+ "patches.june_2013.p06_drop_unused_tables",
]
\ No newline at end of file
diff --git a/public/js/transaction.js b/public/js/transaction.js
index b7df5b6..a7e8c10 100644
--- a/public/js/transaction.js
+++ b/public/js/transaction.js
@@ -90,14 +90,14 @@
this.price_list_currency();
},
- price_list_name: function(use_for) {
+ price_list_name: function(buying_or_selling) {
var me = this;
if(this.frm.doc.price_list_name) {
this.frm.call({
method: "setup.utils.get_price_list_currency",
args: {args: {
price_list_name: this.frm.doc.price_list_name,
- use_for: use_for
+ buying_or_selling: buying_or_selling
}},
callback: function(r) {
if(!r.exc) {
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js
index dc3f60d..ef23bab 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/doctype/sales_common/sales_common.js
@@ -102,7 +102,7 @@
},
price_list_name: function() {
- this._super("selling");
+ this._super("Selling");
},
ref_rate: function(doc, cdt, cdn) {
diff --git a/selling/utils.py b/selling/utils.py
index 6901028..8947cb5 100644
--- a/selling/utils.py
+++ b/selling/utils.py
@@ -135,7 +135,7 @@
"parentfield": "ref_rate_details",
"price_list_name": args.price_list_name,
"price_list_currency": args.price_list_currency,
- "selling": 1})
+ "buying_or_selling": "Selling"})
if not base_ref_rate:
return {}
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
diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js
index acc78e7..1dcd038 100644
--- a/stock/doctype/item/item.js
+++ b/stock/doctype/item/item.js
@@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-cur_frm.add_fetch("price_list_name", "currency", "ref_currency")
+cur_frm.add_fetch("price_list_name", "currency", "ref_currency");
+cur_frm.add_fetch("price_list_name", "buying_or_selling", "buying_or_selling");
cur_frm.cscript.refresh = function(doc) {
// make sensitive fields(has_serial_no, is_stock_item, valuation_method)
diff --git a/stock/doctype/item_price/item_price.txt b/stock/doctype/item_price/item_price.txt
index ad0b840..e4926cb 100644
--- a/stock/doctype/item_price/item_price.txt
+++ b/stock/doctype/item_price/item_price.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-04-29 15:18:04",
+ "creation": "2013-05-02 16:29:48",
"docstatus": 0,
- "modified": "2013-04-29 19:16:45",
+ "modified": "2013-06-11 18:27:55",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -60,21 +60,18 @@
"oldfieldname": "ref_currency",
"oldfieldtype": "Select",
"options": "Currency",
- "reqd": 1,
+ "read_only": 1,
+ "reqd": 0,
"search_index": 1
},
{
- "description": "Allow this price in sales related forms",
+ "default": "Selling",
"doctype": "DocField",
- "fieldname": "selling",
- "fieldtype": "Check",
- "label": "Valid For Selling"
- },
- {
- "description": "Allow this price in purchase related forms",
- "doctype": "DocField",
- "fieldname": "buying",
- "fieldtype": "Check",
- "label": "Valid For Buying"
+ "fieldname": "buying_or_selling",
+ "fieldtype": "Select",
+ "label": "Valid for Buying or Selling?",
+ "options": "Buying\nSelling",
+ "read_only": 1,
+ "reqd": 1
}
]
\ No newline at end of file
diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js
index 4ea179d..beff192 100644
--- a/support/doctype/support_ticket/support_ticket.js
+++ b/support/doctype/support_ticket/support_ticket.js
@@ -22,6 +22,9 @@
cur_frm.footer.help_area.innerHTML = '<p><a href="#Form/Email Settings/Email Settings">Email Settings</a><br>\
<span class="help">Integrate incoming support emails to Support Ticket</span></p>';
}
+
+ if(doc.description)
+ doc.description = wn.utils.escape_script_and_style(doc.description);
},
refresh: function(doc) {
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index c17df6d..041c4cb 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -260,9 +260,7 @@
comm_list = webnotes.conn.sql("""select * from tabCommunication
where %s=%s order by modified desc limit 20""" \
% (self.doc.doctype.replace(" ", "_").lower(), "%s"),
- self.doc.name, as_dict=1)
-
- [d.update({"doctype":"Communication"}) for d in comm_list]
+ self.doc.name, as_dict=1, update={"doctype":"Communication"})
self.doclist.extend(webnotes.doclist([webnotes.doc(fielddata=d) \
for d in comm_list]))
diff --git a/website/doctype/website_settings/website_settings.js b/website/doctype/website_settings/website_settings.js
index 5858926..57c32e9 100644
--- a/website/doctype/website_settings/website_settings.js
+++ b/website/doctype/website_settings/website_settings.js
@@ -17,29 +17,45 @@
// update parent select
$.extend(cur_frm.cscript, {
-
onload_post_render: function(doc) {
- // get labels of parent items
- var get_parent_options = function(table_field) {
- var items = getchildren('Top Bar Item', doc.name, table_field);
- var main_items = [''];
- for(var i in items) {
- var d = items[i];
- if(!d.parent_label) {
- main_items.push(d.label);
- }
- }
- return main_items.join('\n');
+ this.set_parent_label_options();
+ },
+
+ label: function(doc, cdt, cdn) {
+ var item = wn.model.get_doc(cdt, cdn);
+ if(item.parentfield === "top_bar_items") {
+ this.set_parent_label_options();
}
+ },
+
+ parent_label: function(doc, cdt, cdn) {
+ this.label(doc, cdt, cdn);
+ },
+
+ url: function(doc, cdt, cdn) {
+ this.label(doc, cdt, cdn);
+ }
+
+ set_parent_label_options: function() {
+ wn.meta.get_docfield("Top Bar Item", "parent_label", cur_frm.docname).options =
+ this.get_parent_options("top_bar_items");
- // bind function to refresh fields
- // when "Parent Label" is select, it
- // should automatically update
- // options
- $(cur_frm.fields_dict['top_bar_items'].grid.get_field('parent_label').wrapper)
- .bind('refresh', function() {
- this.fieldobj.refresh_options(get_parent_options('top_bar_items'));
- });
+ if($(cur_frm.fields_dict.top_bar_items.grid.wrapper).find(".grid-row-open")) {
+ cur_frm.fields_dict.top_bar_items.grid.refresh();
+ }
+ },
+
+ // get labels of parent items
+ get_parent_options: function(table_field) {
+ var items = getchildren('Top Bar Item', cur_frm.doc.name, table_field);
+ var main_items = [''];
+ for(var i in items) {
+ var d = items[i];
+ if(!d.parent_label && !d.url && d.label) {
+ main_items.push(d.label);
+ }
+ }
+ return main_items.join('\n');
}
});
diff --git a/website/doctype/website_settings/website_settings.py b/website/doctype/website_settings/website_settings.py
index 77eb1c5..182f063 100644
--- a/website/doctype/website_settings/website_settings.py
+++ b/website/doctype/website_settings/website_settings.py
@@ -15,12 +15,39 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
+import webnotes
+from webnotes import _, msgprint
+
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
self.set_home_page()
+ self.validate_top_bar_items()
+ self.validate_footer_items()
+
+ def validate_top_bar_items(self):
+ """validate url in top bar items"""
+ for top_bar_item in self.doclist.get({"parentfield": "top_bar_items"}):
+ if top_bar_item.parent_label:
+ parent_label_item = self.doclist.get({"parentfield": "top_bar_items",
+ "label": top_bar_item.parent_label})
+
+ if not parent_label_item:
+ # invalid item
+ msgprint(_(self.meta.get_label("parent_label", parentfield="top_bar_items")) +
+ (" \"%s\": " % top_bar_item.parent_label) + _("does not exist"), raise_exception=True)
+
+ elif not parent_label_item[0] or parent_label_item[0].url:
+ # parent cannot have url
+ msgprint(_("Top Bar Item") + (" \"%s\": " % top_bar_item.parent_label) +
+ _("cannot have a URL, because it has child item(s)"), raise_exception=True)
+
+ def validate_footer_items(self):
+ """clear parent label in footer"""
+ for footer_item in self.doclist.get({"parentfield": "footer_items"}):
+ footer_item.parent_label = None
def on_update(self):
# make js and css
@@ -32,10 +59,7 @@
clear_cache()
def set_home_page(self):
-
- import webnotes
from webnotes.model.doc import Document
-
webnotes.conn.sql("""delete from `tabDefault Home Page` where role='Guest'""")
d = Document('Default Home Page')
diff --git a/website/helpers/product.py b/website/helpers/product.py
index a107d9b..a8b60fd 100644
--- a/website/helpers/product.py
+++ b/website/helpers/product.py
@@ -91,7 +91,7 @@
def get_item_for_list_in_html(r):
scrub_item_for_list(r)
- r.template = "app/website/templates/html/product_in_list.html"
+ r.template = "app/website/templates/html/product_in_grid.html"
return build_html(r)
def scrub_item_for_list(r):
diff --git a/website/templates/css/product_page.css b/website/templates/css/product_page.css
index 71be9ee..e2f4293 100644
--- a/website/templates/css/product_page.css
+++ b/website/templates/css/product_page.css
@@ -7,7 +7,7 @@
font-size: 18px;
line-height: 200%;
}
- .item-price {
+ .item-price-info {
margin-top: 20px;
}
</style>
\ No newline at end of file
diff --git a/website/templates/html/product_in_grid.html b/website/templates/html/product_in_grid.html
new file mode 100644
index 0000000..e9752b3
--- /dev/null
+++ b/website/templates/html/product_in_grid.html
@@ -0,0 +1,14 @@
+<div class="col col-lg-3">
+ <div style="height: 120px; overflow: hidden;">
+ <a href="{{ page_name }}">
+ {%- if website_image -%}
+ <img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
+ {%- else -%}
+ {% include 'app/website/templates/html/product_missing_image.html' %}
+ {%- endif -%}
+ </a>
+ </div>
+ <div style="height: 100px; overflow: hidden; font-size: 80%;">
+ <h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
+ </div>
+</div>
\ No newline at end of file
diff --git a/website/templates/html/product_missing_image.html b/website/templates/html/product_missing_image.html
index 3858a13..81b8935 100644
--- a/website/templates/html/product_missing_image.html
+++ b/website/templates/html/product_missing_image.html
@@ -1 +1 @@
-<div class='missing-image'><i class='icon-camera'></i></div>
\ No newline at end of file
+<div class="missing-image"><i class="icon-camera"></i></div>
\ No newline at end of file