Merge branch 'develop' into assessment
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 378cf5e..67d9a35 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe
-__version__ = '7.2.13'
+__version__ = '7.2.14'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/budget/budget.js b/erpnext/accounts/doctype/budget/budget.js
index 6697b17..cadf1e7 100644
--- a/erpnext/accounts/doctype/budget/budget.js
+++ b/erpnext/accounts/doctype/budget/budget.js
@@ -43,9 +43,18 @@
},
budget_against: function(frm) {
+ frm.trigger("set_null_value")
frm.trigger("toggle_reqd_fields")
},
+ set_null_value: function(frm) {
+ if(frm.doc.budget_against == 'Cost Center') {
+ frm.set_value('project', null)
+ } else {
+ frm.set_value('cost_center', null)
+ }
+ },
+
toggle_reqd_fields: function(frm) {
frm.toggle_reqd("cost_center", frm.doc.budget_against=="Cost Center");
frm.toggle_reqd("project", frm.doc.budget_against=="Project");
diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py
index 15d6f10..a6348f1 100644
--- a/erpnext/accounts/doctype/budget/budget.py
+++ b/erpnext/accounts/doctype/budget/budget.py
@@ -22,6 +22,7 @@
frappe.throw(_("{0} is mandatory").format(self.budget_against))
self.validate_duplicate()
self.validate_accounts()
+ self.set_null_value()
def validate_duplicate(self):
budget_against_field = frappe.scrub(self.budget_against)
@@ -54,25 +55,31 @@
else:
account_list.append(d.account)
+ def set_null_value(self):
+ if self.budget_against == 'Cost Center':
+ self.project = None
+ else:
+ self.cost_center = None
+
def validate_expense_against_budget(args):
args = frappe._dict(args)
if not args.cost_center and not args.project:
return
- for budget_against in [args.project, args.cost_center]:
- if budget_against \
+ for budget_against in ['project', 'cost_center']:
+ if args.get(budget_against) \
and frappe.db.get_value("Account", {"name": args.account, "root_type": "Expense"}):
- if args.project:
+ if args.project and budget_against == 'project':
condition = "and b.project='%s'" % frappe.db.escape(args.project)
args.budget_against_field = "Project"
- elif args.cost_center:
+ elif args.cost_center and budget_against == 'cost_center':
cc_lft, cc_rgt = frappe.db.get_value("Cost Center", args.cost_center, ["lft", "rgt"])
condition = """and exists(select name from `tabCost Center`
where lft<=%s and rgt>=%s and name=b.cost_center)""" % (cc_lft, cc_rgt)
args.budget_against_field = "Cost Center"
-
- args.budget_against = budget_against
+
+ args.budget_against = args.get(budget_against)
budget_records = frappe.db.sql("""
select
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 9fb7ceb..bd54776 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -82,8 +82,7 @@
doc.apply_discount_on = pos_profile.get('apply_discount_on') if pos_profile.get('apply_discount') else ''
doc.customer_group = pos_profile.get('customer_group') or get_root('Customer Group')
doc.territory = pos_profile.get('territory') or get_root('Territory')
- if pos_profile.get('tc_name'):
- doc.terms = frappe.db.get_value('Terms and Conditions', pos_profile.get('tc_name'), 'terms')
+ doc.terms = frappe.db.get_value('Terms and Conditions', pos_profile.get('tc_name'), 'terms') or doc.terms or ''
def get_root(table):
root = frappe.db.sql(""" select name from `tab%(table)s` having
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 534f965..7ade318 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -2385,7 +2385,7 @@
"in_standard_filter": 0,
"label": "Sales Invoice Payment",
"length": 0,
- "no_copy": 1,
+ "no_copy": 0,
"options": "Sales Invoice Payment",
"permlevel": 0,
"precision": "",
@@ -4183,7 +4183,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2017-01-17 11:07:25.814402",
+ "modified": "2017-01-18 13:21:13.226318",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py
index 85c7daa..a7d1820 100644
--- a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py
+++ b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py
@@ -46,7 +46,7 @@
def get_columns(filters):
return [
- _("Payment Document") + ":Link/DocType: 100",
+ _("Payment Document") + ":: 100",
_("Payment Entry") + ":Dynamic Link/"+_("Payment Document")+":140",
_("Party Type") + "::100",
_("Party") + ":Dynamic Link/Party Type:140",
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 865514b..c4ba9e7 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -223,7 +223,8 @@
})
if not rm.rate:
from erpnext.stock.stock_ledger import get_valuation_rate
- rm.rate = get_valuation_rate(bom_item.item_code, self.supplier_warehouse)
+ rm.rate = get_valuation_rate(bom_item.item_code, self.supplier_warehouse,
+ self.doctype, self.name)
else:
rm.rate = bom_item.rate
diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py
index 3e22681..4f9bce1 100644
--- a/erpnext/controllers/sales_and_purchase_return.py
+++ b/erpnext/controllers/sales_and_purchase_return.py
@@ -198,6 +198,7 @@
if tax.charge_type == "Actual":
tax.tax_amount = -1 * tax.tax_amount
+ doc.discount_amount = -1 * source.discount_amount
doc.run_method("calculate_taxes_and_totals")
def update_item(source_doc, target_doc, source_parent):
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 74ea774..5ecab8d 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -88,9 +88,8 @@
def validate_negative_stock(self, sle):
if sle.qty_after_transaction < 0 and sle.actual_qty < 0:
- frappe.throw(_("For the Item {0}, valuation rate not found for warehouse {1}. To be able to do accounting entries (for booking expenses), we need valuation rate for item {2}. Please create an incoming stock transaction, on or before {3} {4}, and then try submiting {5}")
- .format(sle.item_code, sle.warehouse,
- sle.item_code, sle.posting_date, sle.posting_time, self.name))
+ frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries (for booking expenses). Please create an incoming stock transaction or mention valuation rate in Item record, and then try submiting {1} {2}")
+ .format(sle.item_code, sle.voucher_type, sle.voucher_no))
def get_voucher_details(self, default_expense_account, default_cost_center, sle_map):
if self.doctype == "Stock Reconciliation":
diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.py b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
index 3473fd8..58a7f30 100755
--- a/erpnext/hr/doctype/leave_allocation/leave_allocation.py
+++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
@@ -93,7 +93,7 @@
if flt(leaves_taken) > flt(self.total_leaves_allocated):
if frappe.db.get_value("Leave Type", self.leave_type, "allow_negative"):
- frappe.msgprint(_("Note: Total allocated leaves {0} shouldn't be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken), LessAllocationError)
+ frappe.msgprint(_("Note: Total allocated leaves {0} shouldn't be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken))
else:
frappe.throw(_("Total allocated leaves {0} cannot be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken), LessAllocationError)
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index bfda440..9e37081 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -365,4 +365,5 @@
erpnext.patches.v7_2.update_salary_slips
erpnext.patches.v7_2.delete_fleet_management_module_def
erpnext.patches.v7_2.contact_address_links
-erpnext.patches.v7_2.mark_students_active
\ No newline at end of file
+erpnext.patches.v7_2.mark_students_active
+erpnext.patches.v7_2.set_null_value_to_fields
diff --git a/erpnext/patches/v7_2/set_null_value_to_fields.py b/erpnext/patches/v7_2/set_null_value_to_fields.py
new file mode 100644
index 0000000..6388be4
--- /dev/null
+++ b/erpnext/patches/v7_2/set_null_value_to_fields.py
@@ -0,0 +1,11 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ fields = {"Cost Center": "project", "Project": "cost_center"}
+ for budget_against, field in fields.items():
+ frappe.db.sql(""" update `tabBudget` set {field} = null
+ where budget_against = %s """.format(field = field), budget_against)
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index 8844528..73a04f2 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -113,6 +113,12 @@
has_variants: function(frm) {
erpnext.item.toggle_attributes(frm);
+ },
+
+ show_in_website: function(frm) {
+ if (frm.doc.default_warehouse && !frm.doc.website_warehouse){
+ frm.set_value("website_warehouse", frm.doc.default_warehouse);
+ }
}
});
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index da3de1e..316d35b 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -26,6 +26,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "",
"length": 0,
"no_copy": 0,
@@ -54,6 +55,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Series",
"length": 0,
"no_copy": 0,
@@ -82,6 +84,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Item Code",
"length": 0,
"no_copy": 1,
@@ -112,6 +115,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 1,
"label": "Variant Of",
"length": 0,
"no_copy": 0,
@@ -140,6 +144,7 @@
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Item Name",
"length": 0,
"no_copy": 0,
@@ -168,6 +173,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Barcode",
"length": 0,
"no_copy": 1,
@@ -195,6 +201,7 @@
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 1,
+ "in_standard_filter": 1,
"label": "Item Group",
"length": 0,
"no_copy": 0,
@@ -225,6 +232,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Default Unit of Measure",
"length": 0,
"no_copy": 0,
@@ -254,6 +262,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -279,6 +288,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Disabled",
"length": 0,
"no_copy": 0,
@@ -308,6 +318,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Maintain Stock",
"length": 0,
"no_copy": 0,
@@ -338,6 +349,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Opening Stock",
"length": 0,
"no_copy": 0,
@@ -355,37 +367,38 @@
},
{
"allow_on_submit": 0,
- "bold": 1,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "eval:(doc.__islocal && doc.is_stock_item && !doc.has_serial_no && !doc.has_batch_no && doc.opening_stock)",
- "fieldname": "valuation_rate",
- "fieldtype": "Currency",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Valuation Rate",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "depends_on": "eval:(doc.is_stock_item && !doc.has_serial_no && !doc.has_batch_no)",
+ "fieldname": "valuation_rate",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Valuation Rate",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 1,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "standard_rate",
"fieldtype": "Currency",
"hidden": 0,
@@ -393,6 +406,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Standard Selling Rate",
"length": 0,
"no_copy": 0,
@@ -420,6 +434,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Is Fixed Asset",
"length": 0,
"no_copy": 0,
@@ -448,6 +463,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Asset Category",
"length": 0,
"no_copy": 0,
@@ -476,6 +492,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Image",
"length": 0,
"no_copy": 0,
@@ -504,6 +521,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Description",
"length": 0,
"no_copy": 0,
@@ -531,6 +549,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Brand",
"length": 0,
"no_copy": 0,
@@ -560,6 +579,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Description",
"length": 0,
"no_copy": 0,
@@ -590,6 +610,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Inventory",
"length": 0,
"no_copy": 0,
@@ -620,6 +641,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Default Warehouse",
"length": 0,
"no_copy": 0,
@@ -651,6 +673,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "End of Life",
"length": 0,
"no_copy": 0,
@@ -681,6 +704,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Has Batch No",
"length": 0,
"no_copy": 0,
@@ -713,6 +737,7 @@
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Has Serial No",
"length": 0,
"no_copy": 0,
@@ -744,6 +769,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Serial Number Series",
"length": 0,
"no_copy": 0,
@@ -771,6 +797,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Default Material Request Type",
"length": 0,
"no_copy": 0,
@@ -800,6 +827,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"oldfieldtype": "Column Break",
@@ -829,6 +857,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Allow over delivery or receipt upto this percent",
"length": 0,
"no_copy": 0,
@@ -858,6 +887,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Valuation Method",
"length": 0,
"no_copy": 0,
@@ -886,6 +916,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Warranty Period (in days)",
"length": 0,
"no_copy": 0,
@@ -916,6 +947,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Net Weight",
"length": 0,
"no_copy": 0,
@@ -943,6 +975,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Weight UOM",
"length": 0,
"no_copy": 0,
@@ -972,6 +1005,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Auto re-order",
"length": 0,
"no_copy": 0,
@@ -1001,6 +1035,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Reorder level based on Warehouse",
"length": 0,
"no_copy": 0,
@@ -1091,6 +1126,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Variants",
"length": 0,
"no_copy": 0,
@@ -1121,6 +1157,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Has Variants",
"length": 0,
"no_copy": 1,
@@ -1150,6 +1187,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Attributes",
"length": 0,
"no_copy": 1,
@@ -1178,6 +1216,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Purchase Details",
"length": 0,
"no_copy": 0,
@@ -1207,6 +1246,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Is Purchase Item",
"length": 0,
"no_copy": 0,
@@ -1237,6 +1277,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Minimum Order Qty",
"length": 0,
"no_copy": 0,
@@ -1265,6 +1306,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Safety Stock",
"length": 0,
"no_copy": 0,
@@ -1294,6 +1336,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Lead Time in days",
"length": 0,
"no_copy": 0,
@@ -1324,6 +1367,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Default Buying Cost Center",
"length": 0,
"no_copy": 0,
@@ -1355,6 +1399,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Default Expense Account",
"length": 0,
"no_copy": 0,
@@ -1385,6 +1430,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Last Purchase Rate",
"length": 0,
"no_copy": 1,
@@ -1414,6 +1460,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Supplier Details",
"length": 0,
"no_copy": 0,
@@ -1442,6 +1489,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Default Supplier",
"length": 0,
"no_copy": 0,
@@ -1469,6 +1517,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Delivered by Supplier (Drop Ship)",
"length": 0,
"no_copy": 0,
@@ -1497,6 +1546,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Manufacturer",
"length": 0,
"no_copy": 0,
@@ -1525,6 +1575,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Manufacturer Part Number",
"length": 0,
"no_copy": 0,
@@ -1552,6 +1603,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Item Code for Suppliers",
"length": 0,
"no_copy": 0,
@@ -1581,6 +1633,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Supplier Items",
"length": 0,
"no_copy": 0,
@@ -1608,6 +1661,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Sales Details",
"length": 0,
"no_copy": 0,
@@ -1637,6 +1691,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Is Sales Item",
"length": 0,
"no_copy": 0,
@@ -1666,6 +1721,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Publish in Hub",
"length": 0,
"no_copy": 0,
@@ -1694,6 +1750,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Synced With Hub",
"length": 0,
"no_copy": 0,
@@ -1722,6 +1779,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Default Income Account",
"length": 0,
"no_copy": 0,
@@ -1750,6 +1808,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Default Selling Cost Center",
"length": 0,
"no_copy": 0,
@@ -1778,6 +1837,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Customer Item Codes",
"length": 0,
"no_copy": 0,
@@ -1808,6 +1868,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Customer Items",
"length": 0,
"no_copy": 0,
@@ -1836,6 +1897,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Max Discount (%)",
"length": 0,
"no_copy": 0,
@@ -1864,6 +1926,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Item Tax",
"length": 0,
"no_copy": 0,
@@ -1893,6 +1956,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Taxes",
"length": 0,
"no_copy": 0,
@@ -1922,6 +1986,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Inspection Criteria",
"length": 0,
"no_copy": 0,
@@ -1951,6 +2016,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Inspection Required before Purchase",
"length": 0,
"no_copy": 0,
@@ -1980,6 +2046,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Inspection Required before Delivery",
"length": 0,
"no_copy": 0,
@@ -2009,6 +2076,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Quality Parameters",
"length": 0,
"no_copy": 0,
@@ -2039,6 +2107,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Manufacturing",
"length": 0,
"no_copy": 0,
@@ -2068,6 +2137,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Default BOM",
"length": 0,
"no_copy": 1,
@@ -2099,6 +2169,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Supply Raw Materials for Purchase",
"length": 0,
"no_copy": 0,
@@ -2128,6 +2199,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -2154,6 +2226,7 @@
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Customer Code",
"length": 0,
"no_copy": 1,
@@ -2180,6 +2253,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Website",
"length": 0,
"no_copy": 0,
@@ -2208,6 +2282,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Show in Website",
"length": 0,
"no_copy": 0,
@@ -2235,6 +2310,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Show in Website (Variant)",
"length": 0,
"no_copy": 0,
@@ -2263,6 +2339,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Route",
"length": 0,
"no_copy": 0,
@@ -2292,6 +2369,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Weightage",
"length": 0,
"no_copy": 0,
@@ -2320,6 +2398,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Slideshow",
"length": 0,
"no_copy": 0,
@@ -2349,6 +2428,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Image",
"length": 0,
"no_copy": 0,
@@ -2376,6 +2456,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Thumbnail",
"length": 0,
"no_copy": 0,
@@ -2403,6 +2484,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -2430,6 +2512,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Website Warehouse",
"length": 0,
"no_copy": 0,
@@ -2459,6 +2542,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Website Item Groups",
"length": 0,
"no_copy": 0,
@@ -2488,6 +2572,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Website Specifications",
"length": 0,
"no_copy": 0,
@@ -2515,6 +2600,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Copy From Item Group",
"length": 0,
"no_copy": 0,
@@ -2542,6 +2628,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Website Specifications",
"length": 0,
"no_copy": 0,
@@ -2570,6 +2657,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Website Description",
"length": 0,
"no_copy": 0,
@@ -2596,6 +2684,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Total Projected Qty",
"length": 0,
"no_copy": 0,
@@ -2624,7 +2713,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 1,
- "modified": "2017-01-10 12:02:51.807965",
+ "modified": "2017-01-18 17:43:20.262925",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",
diff --git a/erpnext/stock/doctype/item/test_records.json b/erpnext/stock/doctype/item/test_records.json
index c05c5f3..aad8ed0 100644
--- a/erpnext/stock/doctype/item/test_records.json
+++ b/erpnext/stock/doctype/item/test_records.json
@@ -15,6 +15,7 @@
"item_group": "_Test Item Group",
"item_name": "_Test Item",
"apply_warehouse_wise_reorder_level": 1,
+ "valuation_rate": 100,
"reorder_levels": [
{
"material_request_type": "Purchase",
@@ -61,6 +62,7 @@
"item_code": "_Test Item Home Desktop 100",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Item Home Desktop 100",
+ "valuation_rate": 100,
"taxes": [
{
"doctype": "Item Tax",
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
index aacf02c..0eaf5ba 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
@@ -12,22 +12,23 @@
def get_items_from_purchase_receipts(self):
self.set("items", [])
for pr in self.get("purchase_receipts"):
- pr_items = frappe.db.sql("""select pr_item.item_code, pr_item.description,
- pr_item.qty, pr_item.base_rate, pr_item.base_amount, pr_item.name
- from `tab{doctype} Item` pr_item where parent = %s
- and exists(select name from tabItem where name = pr_item.item_code and is_stock_item = 1)
- """.format(doctype=pr.receipt_document_type), pr.receipt_document, as_dict=True)
+ if pr.receipt_document_type and pr.receipt_document:
+ pr_items = frappe.db.sql("""select pr_item.item_code, pr_item.description,
+ pr_item.qty, pr_item.base_rate, pr_item.base_amount, pr_item.name
+ from `tab{doctype} Item` pr_item where parent = %s
+ and exists(select name from tabItem where name = pr_item.item_code and is_stock_item = 1)
+ """.format(doctype=pr.receipt_document_type), pr.receipt_document, as_dict=True)
- for d in pr_items:
- item = self.append("items")
- item.item_code = d.item_code
- item.description = d.description
- item.qty = d.qty
- item.rate = d.base_rate
- item.amount = d.base_amount
- item.receipt_document_type = pr.receipt_document_type
- item.receipt_document = pr.receipt_document
- item.purchase_receipt_item = d.name
+ for d in pr_items:
+ item = self.append("items")
+ item.item_code = d.item_code
+ item.description = d.description
+ item.qty = d.qty
+ item.rate = d.base_rate
+ item.amount = d.base_amount
+ item.receipt_document_type = pr.receipt_document_type
+ item.receipt_document = pr.receipt_document
+ item.purchase_receipt_item = d.name
def validate(self):
self.check_mandatory()
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index a980ed0..a4cc512 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -258,6 +258,10 @@
if not self.valuation_rate and actual_qty > 0:
self.valuation_rate = sle.incoming_rate
+
+ if not self.valuation_rate:
+ self.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse,
+ sle.voucher_type, sle.voucher_no, self.allow_zero_rate)
def get_fifo_values(self, sle):
incoming_rate = flt(sle.incoming_rate)
@@ -281,10 +285,9 @@
qty_to_pop = abs(actual_qty)
while qty_to_pop:
if not self.stock_queue:
- if self.qty_after_transaction > 0:
- _rate = get_valuation_rate(sle.item_code, sle.warehouse, self.allow_zero_rate)
- else:
- _rate = 0
+ # Get valuation rate from last sle if exists or from valuation rate field in item master
+ _rate = get_valuation_rate(sle.item_code, sle.warehouse,
+ sle.voucher_type, sle.voucher_no, self.allow_zero_rate)
self.stock_queue.append([0, _rate])
index = None
@@ -404,7 +407,8 @@
"order": order
}, previous_sle, as_dict=1, debug=debug)
-def get_valuation_rate(item_code, warehouse, allow_zero_rate=False):
+def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no, allow_zero_rate=False):
+ # Get valuation rate from last sle for the same item and warehouse
last_valuation_rate = frappe.db.sql("""select valuation_rate
from `tabStock Ledger Entry`
where item_code = %s and warehouse = %s
@@ -412,6 +416,7 @@
order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, warehouse))
if not last_valuation_rate:
+ # Get valuation rate from last sle for the item against any warehouse
last_valuation_rate = frappe.db.sql("""select valuation_rate
from `tabStock Ledger Entry`
where item_code = %s and valuation_rate > 0
@@ -420,9 +425,14 @@
valuation_rate = flt(last_valuation_rate[0][0]) if last_valuation_rate else 0
if not valuation_rate:
- valuation_rate = frappe.db.get_value("Item Price", {"item_code": item_code, "buying": 1}, "price_list_rate")
+ # If negative stock allowed, and item delivered without any incoming entry,
+ # syste does not found any SLE, then take valuation rate from Item
+ valuation_rate = frappe.db.get_value("Item", item_code, "valuation_rate")
- if not allow_zero_rate and not valuation_rate and cint(frappe.db.get_value("Accounts Settings", None, "auto_accounting_for_stock")):
- frappe.throw(_("Purchase rate for item: {0} not found, which is required to book accounting entry (expense). Please mention item price against a buying price list.").format(item_code))
+ if not allow_zero_rate and not valuation_rate \
+ and cint(frappe.db.get_value("Accounts Settings", None, "auto_accounting_for_stock")):
+
+ frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries (for booking expenses). Please create an incoming stock transaction or mention valuation rate in Item record, and then try submiting {1} {2}")
+ .format(item_code, voucher_type, voucher_no))
return valuation_rate