Merge pull request #7644 from mbauskar/develop
[docs] Feedback triggers
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index d916789..dcc072d 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe
-__version__ = '7.2.18'
+__version__ = '7.2.19'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
index abc6eba..11dcfe7 100644
--- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
+++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
@@ -74,6 +74,9 @@
clearance_date_updated = False
for d in self.get('payment_entries'):
if d.clearance_date:
+ if not d.payment_document:
+ frappe.throw(_("Row #{0}: Payment document is required to complete the trasaction"))
+
if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date):
frappe.throw(_("Row #{0}: Clearance date {1} cannot be before Cheque Date {2}")
.format(d.idx, d.clearance_date, d.cheque_date))
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.json b/erpnext/accounts/doctype/cost_center/cost_center.json
index f590b5d..9aaaed2 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.json
+++ b/erpnext/accounts/doctype/cost_center/cost_center.json
@@ -278,14 +278,14 @@
"icon": "fa fa-money",
"idx": 1,
"image_view": 0,
- "in_create": 1,
+ "in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2016-11-07 05:20:40.282432",
+ "modified": "2017-01-30 11:27:36.615323",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Cost Center",
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index a13cc7d..0cf34dd 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -46,6 +46,9 @@
self.accounts = [account for account in self.accounts
if not (account.debit_in_account_currency==0.0 and account.credit_in_account_currency==0.0)]
+ if not self.accounts:
+ frappe.throw("Debit or Credit amount is not found in account table")
+
def on_submit(self):
self.check_credit_limit()
self.make_gl_entries()
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
index 5a3e651..03bb7ae 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
@@ -91,8 +91,8 @@
}
//Dynamically change the description based on type of margin
-cur_frm.cscript.type = function(doc){
- cur_frm.set_df_property('rate', 'description', doc.type=='Percentage'?'In Percentage %':'In Amount')
+cur_frm.cscript.margin_type = function(doc){
+ cur_frm.set_df_property('margin_rate_or_amount', 'description', doc.margin_type=='Percentage'?'In Percentage %':'In Amount')
}
frappe.ui.form.on('Pricing Rule', 'price_or_discount', function(frm){
@@ -112,4 +112,4 @@
}
}
}
-})
\ No newline at end of file
+})
diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
index 6f8e219..a91d974 100755
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -1316,6 +1316,34 @@
"unique": 0
},
{
+ "allow_on_submit": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "is_sample_item",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Is Sample Item",
+ "length": 0,
+ "no_copy": 1,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "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,
@@ -1788,7 +1816,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2016-11-16 16:04:52.465169",
+ "modified": "2017-02-07 01:21:03.737800",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
index 944230b..bf6d986 100644
--- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
+++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
@@ -1382,6 +1382,34 @@
"unique": 0
},
{
+ "allow_on_submit": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "is_sample_item",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Is Sample Item",
+ "length": 0,
+ "no_copy": 1,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "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,
@@ -1882,7 +1910,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2016-11-16 16:04:02.438952",
+ "modified": "2017-02-07 01:21:47.142162",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Item",
diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py
index 3451238..df6cb3c 100644
--- a/erpnext/accounts/report/gross_profit/gross_profit.py
+++ b/erpnext/accounts/report/gross_profit/gross_profit.py
@@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _, scrub
+from erpnext.stock.utils import get_incoming_rate
from frappe.utils import flt
@@ -208,21 +209,18 @@
flt(my_sle[i+1].stock_value) or 0.0
return previous_stock_value - flt(sle.stock_value)
else:
- return flt(row.qty) * self.get_average_buying_rate(item_code)
-
+ return flt(row.qty) * self.get_average_buying_rate(row, item_code)
return 0.0
- def get_average_buying_rate(self, item_code):
+ def get_average_buying_rate(self, row, item_code):
if not item_code in self.average_buying_rate:
if item_code in self.non_stock_items:
self.average_buying_rate[item_code] = flt(frappe.db.sql("""select sum(base_net_amount) / sum(qty * conversion_factor)
from `tabPurchase Invoice Item`
where item_code = %s and docstatus=1""", item_code)[0][0])
else:
- self.average_buying_rate[item_code] = flt(frappe.db.sql("""select avg(valuation_rate)
- from `tabStock Ledger Entry`
- where item_code = %s and qty_after_transaction > 0""", item_code)[0][0])
+ self.average_buying_rate[item_code] = get_incoming_rate(row)
return self.average_buying_rate[item_code]
diff --git a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
index 09ba40c..c0a4212 100644
--- a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
+++ b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
@@ -11,9 +11,11 @@
value_fields = ("income", "expense", "gross_profit_loss")
def execute(filters=None):
+ if not filters.get('based_on'): filters["based_on"] = 'Cost Center'
+
based_on = filters.based_on.replace(' ', '_').lower()
validate_filters(filters)
- accounts = get_accounts_data(based_on, filters.company)
+ accounts = get_accounts_data(based_on, filters.get("company"))
data = get_data(accounts, filters, based_on)
columns = get_columns(filters)
return columns, data
@@ -27,14 +29,14 @@
def get_data(accounts, filters, based_on):
if not accounts:
- return None
+ return []
accounts, accounts_by_name, parent_children_map = filter_accounts(accounts)
gl_entries_by_account = {}
- set_gl_entries_by_account(filters.company, filters.from_date,
- filters.to_date, based_on, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry))
+ set_gl_entries_by_account(filters.get("company"), filters.get("from_date"),
+ filters.get("to_date"), based_on, gl_entries_by_account, ignore_closing_entries=not flt(filters.get("with_period_closing_entry")))
total_row = calculate_values(accounts, gl_entries_by_account, filters)
accumulate_values_into_parents(accounts, accounts_by_name)
@@ -90,7 +92,7 @@
def prepare_data(accounts, filters, total_row, parent_children_map, based_on):
data = []
- company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
+ company_currency = frappe.db.get_value("Company", filters.get("company"), "default_currency")
for d in accounts:
has_value = False
@@ -99,7 +101,7 @@
"account": d.name,
"parent_account": d.parent_account,
"indent": d.indent,
- "fiscal_year": filters.fiscal_year,
+ "fiscal_year": filters.get("fiscal_year"),
"currency": company_currency,
"based_on": based_on
}
@@ -122,9 +124,9 @@
return [
{
"fieldname": "account",
- "label": _(filters.based_on),
+ "label": _(filters.get("based_on")),
"fieldtype": "Link",
- "options": filters.based_on,
+ "options": filters.get("based_on"),
"width": 300
},
{
diff --git a/erpnext/config/learn.py b/erpnext/config/learn.py
index 426449b..86db808 100644
--- a/erpnext/config/learn.py
+++ b/erpnext/config/learn.py
@@ -44,7 +44,7 @@
},
{
"type": "help",
- "label": _("Setting up Email"),
+ "label": _("Setting up Email Account"),
"youtube_id": "YFYe0DrB95o"
},
{
@@ -64,11 +64,6 @@
},
{
"type": "help",
- "label": _("Email Account"),
- "youtube_id": "YFYe0DrB95o"
- },
- {
- "type": "help",
"label": _("File Manager"),
"youtube_id": "4-osLW3E_Rk"
},
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index c489008..add882c 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -54,9 +54,16 @@
self.check_expense_account(item_row)
- if not sle.stock_value_difference:
- self.update_stock_ledger_entries(sle)
- self.validate_negative_stock(sle)
+ # If item is not a sample item
+ # and ( valuation rate not mentioned in an incoming entry
+ # or incoming entry not found while delivering the item),
+ # try to pick valuation rate from previous sle or Item master and update in SLE
+ # Otherwise, throw an exception
+
+ if not sle.stock_value_difference and self.doctype != "Stock Reconciliation" \
+ and not item_row.get("is_sample_item"):
+
+ sle = self.update_stock_ledger_entries(sle)
gl_list.append(self.get_gl_dict({
"account": warehouse_account[sle.warehouse]["name"],
@@ -89,20 +96,25 @@
return process_gl_map(gl_list)
def update_stock_ledger_entries(self, sle):
- sle.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse,
- sle.voucher_type, sle.voucher_no)
+ sle.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse,
+ self.doctype, self.name)
+
sle.stock_value = flt(sle.qty_after_transaction) * flt(sle.valuation_rate)
- sle.stock_value_difference = sle.stock_value
+ sle.stock_value_difference = flt(sle.actual_qty) * flt(sle.valuation_rate)
+
if sle.name:
- frappe.db.sql(""" update `tabStock Ledger Entry` set stock_value = %(stock_value)s,
- valuation_rate = %(valuation_rate)s, stock_value_difference = %(stock_value_difference)s
- where name = %(name)s""", (sle))
-
- def validate_negative_stock(self, sle):
- if sle.qty_after_transaction < 0 and sle.actual_qty < 0:
- 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))
-
+ frappe.db.sql("""
+ update
+ `tabStock Ledger Entry`
+ set
+ stock_value = %(stock_value)s,
+ valuation_rate = %(valuation_rate)s,
+ stock_value_difference = %(stock_value_difference)s
+ where
+ name = %(name)s""", (sle))
+
+ return sle
+
def get_voucher_details(self, default_expense_account, default_cost_center, sle_map):
if self.doctype == "Stock Reconciliation":
return [frappe._dict({ "name": voucher_detail_no, "expense_account": default_expense_account,
@@ -150,10 +162,18 @@
def get_stock_ledger_details(self):
stock_ledger = {}
- for sle in frappe.db.sql("""select name, warehouse, stock_value_difference,
- voucher_detail_no, item_code, posting_date, posting_time, actual_qty, qty_after_transaction
- from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""",
- (self.doctype, self.name), as_dict=True):
+ stock_ledger_entries = frappe.db.sql("""
+ select
+ name, warehouse, stock_value_difference, valuation_rate,
+ voucher_detail_no, item_code, posting_date, posting_time,
+ actual_qty, qty_after_transaction
+ from
+ `tabStock Ledger Entry`
+ where
+ voucher_type=%s and voucher_no=%s
+ """, (self.doctype, self.name), as_dict=True)
+
+ for sle in stock_ledger_entries:
stock_ledger.setdefault(sle.voucher_detail_no, []).append(sle)
return stock_ledger
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index a268ea2..c306cbf 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -155,6 +155,9 @@
}
}}, target_doc)
target_doc.quotation_to = "Lead"
+ target_doc.run_method("set_missing_values")
+ target_doc.run_method("set_other_charges")
+ target_doc.run_method("calculate_taxes_and_totals")
return target_doc
diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py
index c664101..4c1d443 100644
--- a/erpnext/demo/setup/setup_data.py
+++ b/erpnext/demo/setup/setup_data.py
@@ -46,8 +46,7 @@
if not frappe.get_all('Company', limit=1):
setup_complete({
- "first_name": "Test",
- "last_name": "User",
+ "full_name": "Test User",
"email": "test_demo@erpnext.com",
"company_tagline": 'Awesome Products and Services',
"password": "demo",
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.js b/erpnext/hr/doctype/process_payroll/process_payroll.js
index cfb646d..128e533 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.js
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.js
@@ -10,6 +10,19 @@
frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet);
},
+ setup: function(frm) {
+ frm.set_query("payment_account", function() {
+ var account_types = ["Bank", "Cash"];
+ return {
+ filters: {
+ "account_type": ["in", account_types],
+ "is_group": 0,
+ "company": frm.doc.company
+ }
+ }
+ })
+ },
+
refresh: function(frm) {
frm.disable_save();
},
@@ -50,16 +63,6 @@
}
})
}
- },
- account: function(frm) {
- var account_types = ["Bank", "Cash"];
- return {
- filters: {
- "account_type": ["in", account_types],
- "is_group": 0,
- "company": frm.doc.company
- }
- }
}
})
diff --git a/erpnext/hr/doctype/salary_component/salary_component.js b/erpnext/hr/doctype/salary_component/salary_component.js
index 3ed566e..3a2492c 100644
--- a/erpnext/hr/doctype/salary_component/salary_component.js
+++ b/erpnext/hr/doctype/salary_component/salary_component.js
@@ -2,7 +2,16 @@
// For license information, please see license.txt
frappe.ui.form.on('Salary Component', {
- refresh: function(frm) {
-
+ setup: function(frm) {
+ frm.set_query("default_account", "accounts", function(doc, cdt, cdn) {
+ var d = locals[cdt][cdn];
+ return {
+ filters: {
+ "root_type": "Expense",
+ "is_group": 0,
+ "company": d.company
+ }
+ }
+ })
}
});
diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.js b/erpnext/selling/page/sales_analytics/sales_analytics.js
index 2f9b02c..73793d4 100644
--- a/erpnext/selling/page/sales_analytics/sales_analytics.js
+++ b/erpnext/selling/page/sales_analytics/sales_analytics.js
@@ -202,7 +202,9 @@
if (posting_date >= from_date && posting_date <= to_date) {
var item = me.item_by_name[tl[me.tree_grid.item_key]] ||
me.item_by_name['Not Set'];
- item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_net_amount : tl.qty);
+ if(item){
+ item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_net_amount : tl.qty);
+ }
}
}
});
diff --git a/erpnext/setup/setup_wizard/test_setup_data.py b/erpnext/setup/setup_wizard/test_setup_data.py
index de54a1d..25378f4 100644
--- a/erpnext/setup/setup_wizard/test_setup_data.py
+++ b/erpnext/setup/setup_wizard/test_setup_data.py
@@ -13,7 +13,7 @@
"customer_2": "Mahesh Engg",
"customer_contact_1": "Aditya Duggal",
"customer_contact_2": "Mahesh Malani",
-"first_name": "Rushabh",
+"full_name": "Rushabh Mehta",
"fy_start": "1st Apr",
"item_1": "Enterprise Plan",
"item_2": "Small Business",
@@ -42,7 +42,6 @@
"item_uom_3": "Unit",
"item_uom_4": "Unit",
"item_uom_5": "Unit",
-"last_name": "Mehta",
"supplier_1": "Google",
"supplier_2": "Hetzner",
"supplier_3": "Digital Ocean",
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index 0c214e4..cb63837 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -6,7 +6,7 @@
from frappe import _, throw
from frappe.utils import flt
from frappe.utils import get_datetime_str, nowdate
-
+
def get_company_currency(company):
currency = frappe.db.get_value("Company", company, "default_currency", cache=True)
if not currency:
@@ -37,8 +37,7 @@
if not frappe.get_list("Company"):
setup_complete({
"currency" :"USD",
- "first_name" :"Test",
- "last_name" :"User",
+ "full_name" :"Test User",
"company_name" :"Wind Power LLC",
"timezone" :"America/New_York",
"company_abbr" :"WP",
@@ -52,7 +51,7 @@
"password" :"test",
"chart_of_accounts" : "Standard",
"domain" : "Manufacturing",
-
+
})
frappe.db.sql("delete from `tabLeave Allocation`")
@@ -71,18 +70,18 @@
if not (from_currency and to_currency):
# manqala 19/09/2016: Should this be an empty return or should it throw and exception?
return
-
+
if from_currency == to_currency:
return 1
-
+
# cksgb 19/09/2016: get last entry in Currency Exchange with from_currency and to_currency.
- entries = frappe.get_all("Currency Exchange", fields = ["exchange_rate"],
+ entries = frappe.get_all("Currency Exchange", fields = ["exchange_rate"],
filters=[
- ["date", "<=", get_datetime_str(transaction_date)],
- ["from_currency", "=", from_currency],
+ ["date", "<=", get_datetime_str(transaction_date)],
+ ["from_currency", "=", from_currency],
["to_currency", "=", to_currency]
], order_by="date desc", limit=1)
-
+
if entries:
return flt(entries[0].exchange_rate)
diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
index e1ac06e..1147d8d 100644
--- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
+++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
@@ -1477,6 +1477,34 @@
"width": "120px"
},
{
+ "allow_on_submit": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "is_sample_item",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Is Sample Item",
+ "length": 0,
+ "no_copy": 1,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "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,
@@ -1691,7 +1719,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2016-12-24 12:33:37.728117",
+ "modified": "2017-02-07 01:22:03.047137",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note Item",
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
index d8449f1..5903713 100755
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
@@ -1575,6 +1575,34 @@
"unique": 0
},
{
+ "allow_on_submit": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "is_sample_item",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Is Sample Item",
+ "length": 0,
+ "no_copy": 1,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "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,
@@ -1885,7 +1913,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2016-11-16 16:04:21.778869",
+ "modified": "2017-02-07 01:21:36.348032",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt Item",
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index ed1843e..34b3c85 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -10,6 +10,7 @@
"doctype": "DocType",
"document_type": "Other",
"editable_grid": 1,
+ "engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
@@ -23,6 +24,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Barcode",
"length": 0,
"no_copy": 0,
@@ -50,6 +52,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -76,6 +79,7 @@
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Source Warehouse",
"length": 0,
"no_copy": 0,
@@ -105,6 +109,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -130,6 +135,7 @@
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Target Warehouse",
"length": 0,
"no_copy": 0,
@@ -159,6 +165,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -184,6 +191,7 @@
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Item Code",
"length": 0,
"no_copy": 0,
@@ -213,6 +221,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -238,6 +247,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Item Name",
"length": 0,
"no_copy": 0,
@@ -264,6 +274,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Description",
"length": 0,
"no_copy": 0,
@@ -291,6 +302,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Description",
"length": 0,
"no_copy": 0,
@@ -321,6 +333,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -347,6 +360,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Image",
"length": 0,
"no_copy": 0,
@@ -374,6 +388,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Image View",
"length": 0,
"no_copy": 0,
@@ -402,6 +417,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Quantity and Rate",
"length": 0,
"no_copy": 0,
@@ -420,7 +436,7 @@
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
- "columns": 1,
+ "columns": 3,
"fieldname": "qty",
"fieldtype": "Float",
"hidden": 0,
@@ -428,6 +444,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Qty",
"length": 0,
"no_copy": 0,
@@ -448,14 +465,15 @@
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
- "columns": 2,
+ "columns": 0,
"fieldname": "basic_rate",
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
- "in_list_view": 1,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Basic Rate (as per Stock UOM)",
"length": 0,
"no_copy": 0,
@@ -485,6 +503,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Basic Amount",
"length": 0,
"no_copy": 0,
@@ -513,6 +532,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Additional Cost",
"length": 0,
"no_copy": 0,
@@ -541,6 +561,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Amount",
"length": 0,
"no_copy": 0,
@@ -570,6 +591,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Valuation Rate",
"length": 0,
"no_copy": 0,
@@ -598,6 +620,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -623,6 +646,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "UOM",
"length": 0,
"no_copy": 0,
@@ -652,6 +676,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Conversion Factor",
"length": 0,
"no_copy": 0,
@@ -680,6 +705,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Stock UOM",
"length": 0,
"no_copy": 0,
@@ -709,6 +735,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Qty as per Stock UOM",
"length": 0,
"no_copy": 0,
@@ -737,6 +764,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Serial No / Batch",
"length": 0,
"no_copy": 0,
@@ -763,6 +791,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Serial No",
"length": 0,
"no_copy": 1,
@@ -791,6 +820,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -816,6 +846,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Batch No",
"length": 0,
"no_copy": 0,
@@ -845,6 +876,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Accounting",
"length": 0,
"no_copy": 0,
@@ -872,6 +904,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Difference Account",
"length": 0,
"no_copy": 0,
@@ -899,6 +932,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -926,6 +960,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Cost Center",
"length": 0,
"no_copy": 0,
@@ -953,6 +988,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "More Information",
"length": 0,
"no_copy": 0,
@@ -972,6 +1008,34 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "is_sample_item",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Is Sample Item",
+ "length": 0,
+ "no_copy": 1,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "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": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "actual_qty",
"fieldtype": "Float",
"hidden": 0,
@@ -979,6 +1043,7 @@
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Actual Qty (at source/target)",
"length": 0,
"no_copy": 1,
@@ -1008,6 +1073,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "BOM No",
"length": 0,
"no_copy": 0,
@@ -1035,6 +1101,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -1061,6 +1128,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Material Request",
"length": 0,
"no_copy": 1,
@@ -1088,6 +1156,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Material Request Item",
"length": 0,
"no_copy": 1,
@@ -1114,7 +1183,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2016-11-27 15:19:26.597414",
+ "modified": "2017-02-07 01:21:14.367586",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry Detail",
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index a4cc512..10722cc 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -258,11 +258,14 @@
if not self.valuation_rate and actual_qty > 0:
self.valuation_rate = sle.incoming_rate
+
+ # Get valuation rate from previous SLE or Item master, if item is not a sample item
+ if not self.valuation_rate and sle.voucher_detail_no:
+ is_sample_item = self.check_if_sample_item(sle.voucher_type, sle.voucher_detail_no)
+ if not is_sample_item:
+ self.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse,
+ sle.voucher_type, sle.voucher_no, self.allow_zero_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)
actual_qty = flt(sle.actual_qty)
@@ -286,8 +289,13 @@
while qty_to_pop:
if not self.stock_queue:
# 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)
+ is_sample_item = self.check_if_sample_item(sle.voucher_type, sle.voucher_detail_no)
+ if not is_sample_item:
+ _rate = get_valuation_rate(sle.item_code, sle.warehouse,
+ sle.voucher_type, sle.voucher_no, self.allow_zero_rate)
+ else:
+ _rate = 0
+
self.stock_queue.append([0, _rate])
index = None
@@ -333,7 +341,11 @@
if not self.stock_queue:
self.stock_queue.append([0, sle.incoming_rate or sle.outgoing_rate or self.valuation_rate])
-
+
+ def check_if_sample_item(self, voucher_type, voucher_detail_no):
+ ref_item_dt = voucher_type + (" Detail" if voucher_type == "Stock Entry" else " Item")
+ return frappe.db.get_value(ref_item_dt, voucher_detail_no, "is_sample_item")
+
def get_sle_before_datetime(self):
"""get previous stock ledger entry before current time-bucket"""
return get_stock_ledger_entries(self.args, "<", "desc", "limit 1", for_update=False)
@@ -432,7 +444,6 @@
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))
+ frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries for {1} {2}. If the item is transacting as a sample item in the {1}, please mention that in the {1} Item table. Otherwise, please create an incoming stock transaction for the item or mention valuation rate in the Item record, and then try submiting/cancelling this entry").format(item_code, voucher_type, voucher_no))
return valuation_rate