[fixes] buying/selling price lists, communication and website settings
This commit is contained in:
parent
9c901e75cd
commit
060d9248d3
@ -28,13 +28,13 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
|
||||
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});
|
||||
});
|
||||
|
@ -102,7 +102,7 @@ def _get_price_list_rate(args, item_bean, meta):
|
||||
"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)
|
||||
|
@ -42,7 +42,7 @@ class AccountsController(TransactionBase):
|
||||
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):
|
||||
|
@ -4,6 +4,6 @@ def execute():
|
||||
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, '')=''""")
|
||||
|
14
patches/june_2013/p03_buying_selling_for_price_list.py
Normal file
14
patches/june_2013/p03_buying_selling_for_price_list.py
Normal file
@ -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))
|
@ -241,7 +241,8 @@ patch_list = [
|
||||
"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",
|
||||
]
|
@ -90,14 +90,14 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({
|
||||
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) {
|
||||
|
@ -102,7 +102,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
},
|
||||
|
||||
price_list_name: function() {
|
||||
this._super("selling");
|
||||
this._super("Selling");
|
||||
},
|
||||
|
||||
ref_rate: function(doc, cdt, cdn) {
|
||||
|
@ -135,7 +135,7 @@ def _get_price_list_rate(args, item_bean, meta):
|
||||
"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 {}
|
||||
|
@ -21,6 +21,7 @@ cur_frm.cscript.onload = function() {
|
||||
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 @@ cur_frm.cscript.show_item_prices = function() {
|
||||
<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>\
|
||||
|
@ -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 @@ class DocType:
|
||||
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""",
|
||||
|
@ -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"
|
||||
},
|
||||
@ -60,6 +60,26 @@
|
||||
"options": "Currency",
|
||||
"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",
|
||||
@ -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"
|
||||
},
|
||||
{
|
||||
@ -87,6 +108,11 @@
|
||||
"fieldtype": "HTML",
|
||||
"label": "Item Prices"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_10",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"doctype": "DocField",
|
||||
|
@ -34,16 +34,16 @@ def get_price_list_currency(args):
|
||||
"""
|
||||
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 {}
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
]
|
@ -22,6 +22,9 @@ $.extend(cur_frm.cscript, {
|
||||
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) {
|
||||
|
@ -260,9 +260,7 @@ class TransactionBase(StatusUpdater):
|
||||
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]))
|
||||
|
@ -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');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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 @@ class DocType:
|
||||
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')
|
||||
|
@ -91,7 +91,7 @@ def get_group_item_count(item_group):
|
||||
|
||||
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):
|
||||
|
@ -7,7 +7,7 @@
|
||||
font-size: 18px;
|
||||
line-height: 200%;
|
||||
}
|
||||
.item-price {
|
||||
.item-price-info {
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
14
website/templates/html/product_in_grid.html
Normal file
14
website/templates/html/product_in_grid.html
Normal file
@ -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>
|
@ -1 +1 @@
|
||||
<div class='missing-image'><i class='icon-camera'></i></div>
|
||||
<div class="missing-image"><i class="icon-camera"></i></div>
|
Loading…
x
Reference in New Issue
Block a user