Merge remote-tracking branch 'webnotes/develop' into 4.0.0-wip
Conflicts:
config.json
erpnext/accounts/utils.py
erpnext/patches/patch_list.py
erpnext/stock/doctype/price_list/price_list.txt
erpnext/stock/doctype/warehouse/warehouse.py
portal/templates/sale.html
portal/utils.py
selling/doctype/sales_order/templates/pages/order.py
selling/utils/cart.py
selling/utils/product.py
utilities/demo/demo_docs/Fiscal_Year.csv
utilities/demo/make_demo.py
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.js b/erpnext/accounts/doctype/sales_invoice/pos.js
index 8909d85..991dad8 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.js
+++ b/erpnext/accounts/doctype/sales_invoice/pos.js
@@ -127,6 +127,7 @@
this.party = party;
this.price_list = (party == "Customer" ?
this.frm.doc.selling_price_list : this.frm.doc.buying_price_list);
+ this.price_list_field = (party == "Customer" ? "selling_price_list" : "buying_price_list");
this.sales_or_purchase = (party == "Customer" ? "Sales" : "Purchase");
this.net_total = "net_total_" + export_or_import;
this.grand_total = "grand_total_" + export_or_import;
@@ -287,22 +288,17 @@
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
if (d.item_code == item_code) {
caught = true;
- if (serial_no) {
- d.serial_no += '\n' + serial_no;
- me.frm.script_manager.trigger("serial_no", d.doctype, d.name);
- }
- else {
- d.qty += 1;
- me.frm.script_manager.trigger("qty", d.doctype, d.name);
- }
+ if (serial_no)
+ wn.model.set_value(d.doctype, d.name, "serial_no", d.serial_no + '\n' + serial_no);
+ else
+ wn.model.set_value(d.doctype, d.name, "qty", d.qty + 1);
}
});
}
// if item not found then add new item
- if (!caught) {
+ if (!caught)
this.add_new_item_to_grid(item_code, serial_no);
- }
this.refresh();
this.refresh_search_box();
@@ -337,15 +333,16 @@
wn.model.clear_doc(d.doctype, d.name);
me.refresh_grid();
} else {
- d.qty = qty;
- me.frm.script_manager.trigger("qty", d.doctype, d.name);
+ wn.model.set_value(d.doctype, d.name, "qty", qty);
}
}
});
- me.refresh();
+ this.refresh();
},
refresh: function() {
var me = this;
+
+ this.refresh_item_list();
this.party_field.set_input(this.frm.doc[this.party.toLowerCase()]);
this.wrapper.find('input.discount-amount').val(this.frm.doc.discount_amount);
this.barcode.set_input("");
@@ -369,6 +366,14 @@
this.make_party();
}
},
+ refresh_item_list: function() {
+ var me = this;
+ // refresh item list on change of price list
+ if (this.frm.doc[this.price_list_field] != this.price_list) {
+ this.price_list = this.frm.doc[this.price_list_field];
+ this.make_item_list();
+ }
+ },
show_items_in_item_cart: function() {
var me = this;
var $items = this.wrapper.find("#cart tbody").empty();
@@ -402,9 +407,8 @@
)).appendTo($items);
});
- this.wrapper.find(".increase-qty, .decrease-qty").on("click", function() {
- var item_code = $(this).closest("tr").attr("id");
- me.selected_item_qty_operation(item_code, $(this).attr("class"));
+ this.wrapper.find("input.qty").on("focus", function() {
+ $(this).select();
});
},
show_taxes: function() {
@@ -441,10 +445,16 @@
// append quantity to the respective item after change from input box
$(this.wrapper).find("input.qty").on("change", function() {
- var item_code = $(this).closest("tr")[0].id;
+ var item_code = $(this).closest("tr").attr("id");
me.update_qty(item_code, $(this).val());
});
+ // increase/decrease qty on plus/minus button
+ $(this.wrapper).find(".increase-qty, .decrease-qty").on("click", function() {
+ var tr = $(this).closest("tr");
+ me.increase_decrease_qty(tr, $(this).attr("class"));
+ });
+
// on td click toggle the highlighting of row
$(this.wrapper).find("#cart tbody tr td").on("click", function() {
var row = $(this).closest("tr");
@@ -462,6 +472,15 @@
me.refresh_delete_btn();
this.barcode.$input.focus();
},
+ increase_decrease_qty: function(tr, operation) {
+ var item_code = tr.attr("id");
+ var item_qty = cint(tr.find("input.qty").val());
+
+ if (operation == "increase-qty")
+ this.update_qty(item_code, item_qty + 1);
+ else if (operation == "decrease-qty" && item_qty != 1)
+ this.update_qty(item_code, item_qty - 1);
+ },
disable_text_box_and_button: function() {
var me = this;
// if form is submitted & cancelled then disable all input box & buttons
@@ -533,26 +552,11 @@
this.refresh_grid();
},
refresh_grid: function() {
+ this.frm.dirty();
this.frm.fields_dict[this.frm.cscript.fname].grid.refresh();
this.frm.script_manager.trigger("calculate_taxes_and_totals");
this.refresh();
},
- selected_item_qty_operation: function(item_code, operation) {
- var me = this;
- var child = wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
- this.frm.cscript.fname, this.frm.doctype);
-
- $.each(child, function(i, d) {
- if (d.item_code == item_code) {
- if (operation == "increase-qty")
- d.qty += 1;
- else if (operation == "decrease-qty")
- d.qty != 1 ? d.qty -= 1 : d.qty = 1;
-
- me.refresh();
- }
- });
- },
make_payment: function() {
var me = this;
var no_of_items = $(this.wrapper).find("#cart tbody tr").length;
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 2259bbe..1292507 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -320,12 +320,9 @@
item = webnotes.conn.sql("select name,is_asset_item,is_sales_item from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())"% d.item_code)
acc = webnotes.conn.sql("select account_type from `tabAccount` where name = '%s' and docstatus != 2" % d.income_account)
if not acc:
- msgprint("Account: "+d.income_account+" does not exist in the system")
- raise Exception
+ msgprint("Account: "+d.income_account+" does not exist in the system", raise_exception=True)
elif item and item[0][1] == 'Yes' and not acc[0][0] == 'Fixed Asset Account':
- msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code)
- raise Exception
-
+ msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code, raise_exception=True)
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index de96abb..085595e 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -37,12 +37,15 @@
return columns
def get_data(self, customer_naming_by):
+ from erpnext.accounts.utils import get_currency_precision
+ currency_precision = get_currency_precision() or 2
+
data = []
future_vouchers = self.get_entries_after(self.filters.report_date)
for gle in self.get_entries_till(self.filters.report_date):
if self.is_receivable(gle, future_vouchers):
outstanding_amount = self.get_outstanding_amount(gle, self.filters.report_date)
- if abs(outstanding_amount) > 0.0:
+ if abs(outstanding_amount) > 0.1/10**currency_precision:
due_date = self.get_due_date(gle)
invoiced_amount = gle.debit if (gle.debit > 0) else 0
payment_received = invoiced_amount - outstanding_amount
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index a22a114..ccdba06 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -34,7 +34,7 @@
def get_columns():
return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Float:100",
"Credit:Float:100", "Voucher Type::120", "Voucher No::160", "Link::20",
- "Against Account::120", "Cost Center:Link/Cost Center:100", "Remarks::200"]
+ "Against Account::120", "Cost Center:Link/Cost Center:100", "Remarks::400"]
def get_result(filters, account_details):
gl_entries = get_gl_entries(filters)
@@ -51,7 +51,7 @@
gl_entries = webnotes.conn.sql("""select posting_date, account,
sum(ifnull(debit, 0)) as debit, sum(ifnull(credit, 0)) as credit,
- voucher_type, voucher_no, cost_center, remarks, is_advance, against
+ voucher_type, voucher_no, cost_center, remarks, is_opening, against
from `tabGL Entry`
where company=%(company)s {conditions}
{group_by_condition}
@@ -138,7 +138,7 @@
for gle in gl_entries:
amount = flt(gle.debit) - flt(gle.credit)
if filters.get("account") and (gle.posting_date < filters.from_date
- or cstr(gle.is_advance) == "Yes"):
+ or cstr(gle.is_opening) == "Yes"):
gle_map[gle.account].opening += amount
opening += amount
elif gle.posting_date <= filters.to_date:
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 5d9c09b..d9cb516 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -379,3 +379,12 @@
return webnotes.conn.get_value("Account", {account_for_field: account_for_doctype,
"master_name": account_for})
+
+def get_currency_precision(currency=None):
+ if not currency:
+ currency = webnotes.conn.get_value("Company",
+ webnotes.conn.get_default("company"), "default_currency")
+ currency_format = webnotes.conn.get_value("Currency", currency, "number_format")
+
+ from webnotes.utils import get_number_format_info
+ return get_number_format_info(currency_format)[2]
diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js
index b3dec80..4eb0479 100644
--- a/erpnext/buying/doctype/supplier/supplier.js
+++ b/erpnext/buying/doctype/supplier/supplier.js
@@ -3,7 +3,7 @@
{% include 'setup/doctype/contact_control/contact_control.js' %};
-cur_frm.cscript.refresh = function(doc,dt,dn) {
+cur_frm.cscript.refresh = function(doc, dt, dn) {
cur_frm.cscript.make_dashboard(doc);
erpnext.hide_naming_series();
@@ -93,7 +93,7 @@
cur_frm.contact_list.run();
}
-cur_frm.fields_dict['default_price_list'].get_query = function(doc,cdt,cdn) {
+cur_frm.fields_dict['default_price_list'].get_query = function(doc, cdt, cdn) {
return{
filters:{'buying': 1}
}
diff --git a/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt b/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt
index 49c7478..4d3558c 100644
--- a/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt
+++ b/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-13 16:10:02",
"docstatus": 0,
- "modified": "2013-05-13 16:21:07",
+ "modified": "2014-01-24 18:19:11",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -11,7 +11,7 @@
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
- "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Ordered Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc",
+ "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tsum(ifnull(mr_item.qty, 0)) as \"Qty:Float:100\",\n\tsum(ifnull(mr_item.ordered_qty, 0)) as \"Ordered Qty:Float:100\", \n\t(sum(mr_item.qty) - sum(ifnull(mr_item.ordered_qty, 0))) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\ngroup by mr.name, mr_item.item_code\nhaving\n\tsum(ifnull(mr_item.ordered_qty, 0)) < sum(ifnull(mr_item.qty, 0))\norder by mr.transaction_date asc",
"ref_doctype": "Purchase Order",
"report_name": "Requested Items To Be Ordered",
"report_type": "Query Report"
diff --git a/erpnext/buying/utils.py b/erpnext/buying/utils.py
index d7e3d81..1bb3154 100644
--- a/erpnext/buying/utils.py
+++ b/erpnext/buying/utils.py
@@ -89,8 +89,10 @@
# try fetching from price list
if args.buying_price_list and args.price_list_currency:
- price_list_rate = webnotes.conn.sql("""select ref_rate from `tabItem Price`
- where price_list=%s and item_code=%s and buying=1""",
+ price_list_rate = webnotes.conn.sql("""select ip.ref_rate from
+ `tabItem Price` ip, `tabPrice List` pl
+ where ip.price_list=pl.name and ip.price_list=%s and
+ ip.item_code=%s and ip.buying=1 and pl.enabled=1""",
(args.buying_price_list, args.item_code), as_dict=1)
if price_list_rate:
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index f39e214..a1614aa 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -1,3 +1,4 @@
+erpnext.patches.1401.enable_all_price_list
erpnext.patches.4_0.update_user_properties
erpnext.patches.4_0.move_warehouse_user_to_restrictions
erpnext.patches.4_0.new_permissions
@@ -18,4 +19,4 @@
execute:webnotes.reload_doc('selling', 'Print Format', 'Sales Order Spartan') # 2014-01-03
execute:webnotes.reload_doc('stock', 'Print Format', 'Delivery Note Classic') # 2014-01-03
execute:webnotes.reload_doc('stock', 'Print Format', 'Delivery Note Modern') # 2014-01-03
-execute:webnotes.reload_doc('stock', 'Print Format', 'Delivery Note Spartan') # 2014-01-03
\ No newline at end of file
+execute:webnotes.reload_doc('stock', 'Print Format', 'Delivery Note Spartan') # 2014-01-03
diff --git a/erpnext/patches/1401/enable_all_price_list.py b/erpnext/patches/1401/enable_all_price_list.py
new file mode 100644
index 0000000..9cf141f
--- /dev/null
+++ b/erpnext/patches/1401/enable_all_price_list.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2014, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def execute():
+ webnotes.reload_doc("stock", "doctype", "price_list")
+ webnotes.conn.sql("""update `tabPrice List` set enabled=1""")
\ No newline at end of file
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index 789954b..6e27628 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -270,4 +270,5 @@
"execute:webnotes.reload_doc('selling', 'doctype', 'sales_order') # 2013-12-26",
"execute:webnotes.reload_doc('selling', 'doctype', 'quotation') # 2013-12-26",
"execute:webnotes.reload_doc('stock', 'doctype', 'delivery_note') # 2013-12-26",
+ "patches.1401.enable_all_price_list",
]
\ No newline at end of file
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index 9578558..f2568d6 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -18,7 +18,7 @@
cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
-cur_frm.cscript.refresh = function(doc,dt,dn) {
+cur_frm.cscript.refresh = function(doc, dt, dn) {
cur_frm.cscript.setup_dashboard(doc);
erpnext.hide_naming_series();
@@ -107,20 +107,20 @@
}
-cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) {
+cur_frm.fields_dict['customer_group'].get_query = function(doc, dt, dn) {
return{
filters:{'is_group': 'No'}
}
}
-cur_frm.fields_dict.lead_name.get_query = function(doc,cdt,cdn) {
+cur_frm.fields_dict.lead_name.get_query = function(doc, cdt, cdn) {
return{
query: "erpnext.controllers.queries.lead_query"
}
}
-cur_frm.fields_dict['default_price_list'].get_query = function(doc,cdt,cdn) {
+cur_frm.fields_dict['default_price_list'].get_query = function(doc, cdt, cdn) {
return{
filters:{'selling': 1}
}
diff --git a/erpnext/selling/utils.py b/erpnext/selling/utils.py
index 118318f..ed3711d 100644
--- a/erpnext/selling/utils.py
+++ b/erpnext/selling/utils.py
@@ -150,8 +150,10 @@
return out
def _get_price_list_rate(args, item_bean, meta):
- ref_rate = webnotes.conn.sql("""select ref_rate from `tabItem Price`
- where price_list=%s and item_code=%s and selling=1""",
+ ref_rate = webnotes.conn.sql("""select ip.ref_rate from
+ `tabItem Price` ip, `tabPrice List` pl
+ where ip.price_list=pl.name and ip.price_list=%s and
+ ip.item_code=%s and ip.selling=1 and pl.enabled=1""",
(args.selling_price_list, args.item_code), as_dict=1)
if not ref_rate:
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py
index eec92aa..47e22df 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.py
@@ -98,6 +98,7 @@
{
"doctype": "Price List",
"price_list_name": "Standard " + pl_type,
+ "enabled": 1,
"buying": 1 if pl_type == "Buying" else 0,
"selling": 1 if pl_type == "Selling" else 0,
"currency": args["currency"]
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index 0571c15..68a5a5a 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import webnotes
-from webnotes import _, msgprint
+from webnotes import _, msgprint, throw
import json
def get_company_currency(company):
@@ -11,8 +11,8 @@
if not currency:
currency = webnotes.conn.get_default("currency")
if not currency:
- msgprint(_('Please specify Default Currency in Company Master \
- and Global Defaults'), raise_exception=True)
+ throw(_('Please specify Default Currency in Company Master \
+ and Global Defaults'))
return currency
@@ -32,5 +32,14 @@
@webnotes.whitelist()
def get_price_list_currency(price_list):
- return {"price_list_currency": webnotes.conn.get_value("Price List", price_list,
- "currency")}
\ No newline at end of file
+ price_list_currency = webnotes.conn.get_value("Price List", {"name": price_list,
+ "enabled": 1}, "currency")
+
+ if not price_list_currency:
+ throw("{message}: {price_list} {disabled}".format(**{
+ "message": _("Price List"),
+ "price_list": price_list,
+ "disabled": _("is disabled.")
+ }))
+ else:
+ return {"price_list_currency": price_list_currency}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_price/item_price.py b/erpnext/stock/doctype/item_price/item_price.py
index e2c9f2f..cb07e70 100644
--- a/erpnext/stock/doctype/item_price/item_price.py
+++ b/erpnext/stock/doctype/item_price/item_price.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import webnotes
-from webnotes import _
+from webnotes import throw, _
class ItemPriceDuplicateItem(webnotes.ValidationError): pass
@@ -12,26 +12,36 @@
self.doc, self.doclist = d, dl
def validate(self):
+ self.validate_price_list()
self.check_duplicate_item()
self.update_price_list_details()
self.update_item_details()
- def update_price_list_details(self):
- self.doc.buying, self.doc.selling, self.doc.currency = webnotes.conn.get_value("Price List",
- self.doc.price_list, ["buying", "selling", "currency"])
-
- def update_item_details(self):
- self.doc.item_name, self.doc.item_description = webnotes.conn.get_value("Item",
- self.doc.item_code, ["item_name", "description"])
+ def validate_price_list(self):
+ enabled = webnotes.conn.get_value("Price List", self.doc.price_list, "enabled")
+ if not enabled:
+ throw("{message}: {price_list} {disabled}".format(**{
+ "message": _("Price List"),
+ "price_list": self.doc.price_list,
+ "disabled": _("is disabled.")
+ }))
def check_duplicate_item(self):
if webnotes.conn.sql("""select name from `tabItem Price`
where item_code=%s and price_list=%s and name!=%s""",
(self.doc.item_code, self.doc.price_list, self.doc.name)):
- webnotes.throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{
+ throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{
"duplicate_item": _("Duplicate Item"),
"item_code": self.doc.item_code,
"already": _("already available in Price List"),
"price_list": self.doc.price_list
}), ItemPriceDuplicateItem)
+
+ def update_price_list_details(self):
+ self.doc.buying, self.doc.selling, self.doc.currency = webnotes.conn.get_value("Price List",
+ {"name": self.doc.price_list, "enabled": 1}, ["buying", "selling", "currency"])
+
+ def update_item_details(self):
+ self.doc.item_name, self.doc.item_description = webnotes.conn.get_value("Item",
+ self.doc.item_code, ["item_name", "description"])
\ No newline at end of file
diff --git a/erpnext/stock/doctype/price_list/price_list.txt b/erpnext/stock/doctype/price_list/price_list.txt
index 41d9c47..7f8b3a1 100644
--- a/erpnext/stock/doctype/price_list/price_list.txt
+++ b/erpnext/stock/doctype/price_list/price_list.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-25 11:35:09",
"docstatus": 0,
- "modified": "2014-01-20 17:48:59",
+ "modified": "2014-01-20 17:50:00",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -42,6 +42,18 @@
"name": "Price List"
},
{
+ "default": "1",
+ "doctype": "DocField",
+ "fieldname": "enabled",
+ "fieldtype": "Check",
+ "label": "Enabled"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "sb_1",
+ "fieldtype": "Section Break"
+ },
+ {
"doctype": "DocField",
"fieldname": "price_list_name",
"fieldtype": "Data",
diff --git a/erpnext/stock/doctype/price_list/test_price_list.py b/erpnext/stock/doctype/price_list/test_price_list.py
index bdcacc3..803be27 100644
--- a/erpnext/stock/doctype/price_list/test_price_list.py
+++ b/erpnext/stock/doctype/price_list/test_price_list.py
@@ -11,6 +11,7 @@
{
"doctype": "Price List",
"price_list_name": "_Test Price List",
+ "enabled": 1,
"currency": "INR",
"selling": 1
},
@@ -24,6 +25,7 @@
{
"doctype": "Price List",
"price_list_name": "_Test Price List 2",
+ "enabled": 1,
"currency": "INR",
"selling": 1
},
@@ -37,6 +39,7 @@
{
"doctype": "Price List",
"price_list_name": "_Test Price List India",
+ "enabled": 1,
"currency": "INR",
"selling": 1
},
@@ -50,6 +53,7 @@
{
"doctype": "Price List",
"price_list_name": "_Test Price List Rest of the World",
+ "enabled": 1,
"currency": "USD",
"selling": 1
},
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 7729b2e..0f2d138 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, validate_email_add
-from webnotes import msgprint, _
+from webnotes import throw, msgprint, _
class DocType:
def __init__(self, doc, doclist=[]):
@@ -18,7 +18,7 @@
def validate(self):
if self.doc.email_id and not validate_email_add(self.doc.email_id):
- msgprint("Please enter valid Email Id", raise_exception=1)
+ throw(_("Please enter valid Email Id"))
self.update_parent_account()
@@ -76,8 +76,8 @@
for d in bins:
if d['actual_qty'] or d['reserved_qty'] or d['ordered_qty'] or \
d['indented_qty'] or d['projected_qty'] or d['planned_qty']:
- msgprint("""Warehouse: %s can not be deleted as qty exists for item: %s"""
- % (self.doc.name, d['item_code']), raise_exception=1)
+ throw("""Warehouse: %s can not be deleted as qty exists for item: %s"""
+ % (self.doc.name, d['item_code']))
else:
webnotes.conn.sql("delete from `tabBin` where name = %s", d['name'])
@@ -88,8 +88,8 @@
if webnotes.conn.sql("""select name from `tabStock Ledger Entry`
where warehouse = %s""", self.doc.name):
- msgprint("""Warehouse can not be deleted as stock ledger entry
- exists for this warehouse.""", raise_exception=1)
+ throw(_("""Warehouse can not be deleted as stock ledger entry
+ exists for this warehouse."""))
def before_rename(self, olddn, newdn, merge=False):
# Add company abbr if not provided
@@ -97,8 +97,8 @@
new_warehouse = get_name_with_abbr(newdn, self.doc.company)
if merge:
- if not webnotes.conn.exists("Warehouse", newdn):
- webnotes.throw(_("Warehouse ") + newdn +_(" does not exists"))
+ if not webnotes.conn.exists("Warehouse", new_warehouse):
+ webnotes.throw(_("Warehouse ") + new_warehouse +_(" does not exists"))
if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"):
webnotes.throw(_("Both Warehouse must belong to same Company"))
diff --git a/erpnext/stock/report/item_prices/item_prices.py b/erpnext/stock/report/item_prices/item_prices.py
index 5eee7df..323277d 100644
--- a/erpnext/stock/report/item_prices/item_prices.py
+++ b/erpnext/stock/report/item_prices/item_prices.py
@@ -15,8 +15,8 @@
bom_rate = get_item_bom_rate()
val_rate_map = get_valuation_rate()
+ from erpnext.accounts.utils import get_currency_precision
precision = get_currency_precision() or 2
-
data = []
for item in sorted(item_map):
data.append([item, item_map[item]["item_name"],
@@ -30,14 +30,6 @@
])
return columns, data
-
-def get_currency_precision():
- company_currency = webnotes.conn.get_value("Company",
- webnotes.conn.get_default("company"), "default_currency")
- currency_format = webnotes.conn.get_value("Currency", company_currency, "number_format")
-
- from webnotes.utils import get_number_format_info
- return get_number_format_info(currency_format)[2]
def get_columns(filters):
"""return columns based on filters"""
@@ -65,9 +57,10 @@
rate = {}
- price_list = webnotes.conn.sql("""select item_code, buying, selling,
- concat(price_list, " - ", currency, " ", ref_rate) as price
- from `tabItem Price`""", as_dict=1)
+ price_list = webnotes.conn.sql("""select ip.item_code, ip.buying, ip.selling,
+ concat(ip.price_list, " - ", ip.currency, " ", ip.ref_rate) as price
+ from `tabItem Price` ip, `tabPrice List` pl
+ where ip.price_list=pl.name and pl.enabled=1""", as_dict=1)
for j in price_list:
if j.price: