Merge branch 'hotfix'

This commit is contained in:
Nabin Hait 2017-01-20 15:40:35 +05:30
commit b736aafb8b
17 changed files with 203 additions and 71 deletions

View File

@ -2,7 +2,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
__version__ = '7.2.13' __version__ = '7.2.14'
def get_default_company(user=None): def get_default_company(user=None):
'''Get default company for user''' '''Get default company for user'''

View File

@ -43,9 +43,18 @@ frappe.ui.form.on('Budget', {
}, },
budget_against: function(frm) { budget_against: function(frm) {
frm.trigger("set_null_value")
frm.trigger("toggle_reqd_fields") 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) { toggle_reqd_fields: function(frm) {
frm.toggle_reqd("cost_center", frm.doc.budget_against=="Cost Center"); frm.toggle_reqd("cost_center", frm.doc.budget_against=="Cost Center");
frm.toggle_reqd("project", frm.doc.budget_against=="Project"); frm.toggle_reqd("project", frm.doc.budget_against=="Project");

View File

@ -22,6 +22,7 @@ class Budget(Document):
frappe.throw(_("{0} is mandatory").format(self.budget_against)) frappe.throw(_("{0} is mandatory").format(self.budget_against))
self.validate_duplicate() self.validate_duplicate()
self.validate_accounts() self.validate_accounts()
self.set_null_value()
def validate_duplicate(self): def validate_duplicate(self):
budget_against_field = frappe.scrub(self.budget_against) budget_against_field = frappe.scrub(self.budget_against)
@ -54,25 +55,31 @@ class Budget(Document):
else: else:
account_list.append(d.account) 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): def validate_expense_against_budget(args):
args = frappe._dict(args) args = frappe._dict(args)
if not args.cost_center and not args.project: if not args.cost_center and not args.project:
return return
for budget_against in [args.project, args.cost_center]: for budget_against in ['project', 'cost_center']:
if budget_against \ if args.get(budget_against) \
and frappe.db.get_value("Account", {"name": args.account, "root_type": "Expense"}): 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) condition = "and b.project='%s'" % frappe.db.escape(args.project)
args.budget_against_field = "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"]) cc_lft, cc_rgt = frappe.db.get_value("Cost Center", args.cost_center, ["lft", "rgt"])
condition = """and exists(select name from `tabCost Center` condition = """and exists(select name from `tabCost Center`
where lft<=%s and rgt>=%s and name=b.cost_center)""" % (cc_lft, cc_rgt) where lft<=%s and rgt>=%s and name=b.cost_center)""" % (cc_lft, cc_rgt)
args.budget_against_field = "Cost Center" args.budget_against_field = "Cost Center"
args.budget_against = budget_against args.budget_against = args.get(budget_against)
budget_records = frappe.db.sql(""" budget_records = frappe.db.sql("""
select select

View File

@ -82,8 +82,7 @@ def update_pos_profile_data(doc, pos_profile, company_data):
doc.apply_discount_on = pos_profile.get('apply_discount_on') if pos_profile.get('apply_discount') else '' 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.customer_group = pos_profile.get('customer_group') or get_root('Customer Group')
doc.territory = pos_profile.get('territory') or get_root('Territory') 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') or doc.terms or ''
doc.terms = frappe.db.get_value('Terms and Conditions', pos_profile.get('tc_name'), 'terms')
def get_root(table): def get_root(table):
root = frappe.db.sql(""" select name from `tab%(table)s` having root = frappe.db.sql(""" select name from `tab%(table)s` having

View File

@ -2385,7 +2385,7 @@
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Sales Invoice Payment", "label": "Sales Invoice Payment",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 0,
"options": "Sales Invoice Payment", "options": "Sales Invoice Payment",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
@ -4183,7 +4183,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2017-01-17 11:07:25.814402", "modified": "2017-01-18 13:21:13.226318",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice", "name": "Sales Invoice",

View File

@ -46,7 +46,7 @@ def validate_filters(filters):
def get_columns(filters): def get_columns(filters):
return [ return [
_("Payment Document") + ":Link/DocType: 100", _("Payment Document") + ":: 100",
_("Payment Entry") + ":Dynamic Link/"+_("Payment Document")+":140", _("Payment Entry") + ":Dynamic Link/"+_("Payment Document")+":140",
_("Party Type") + "::100", _("Party Type") + "::100",
_("Party") + ":Dynamic Link/Party Type:140", _("Party") + ":Dynamic Link/Party Type:140",

View File

@ -223,7 +223,8 @@ class BuyingController(StockController):
}) })
if not rm.rate: if not rm.rate:
from erpnext.stock.stock_ledger import get_valuation_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: else:
rm.rate = bom_item.rate rm.rate = bom_item.rate

View File

@ -198,6 +198,7 @@ def make_return_doc(doctype, source_name, target_doc=None):
if tax.charge_type == "Actual": if tax.charge_type == "Actual":
tax.tax_amount = -1 * tax.tax_amount tax.tax_amount = -1 * tax.tax_amount
doc.discount_amount = -1 * source.discount_amount
doc.run_method("calculate_taxes_and_totals") doc.run_method("calculate_taxes_and_totals")
def update_item(source_doc, target_doc, source_parent): def update_item(source_doc, target_doc, source_parent):

View File

@ -87,9 +87,8 @@ class StockController(AccountsController):
def validate_negative_stock(self, sle): def validate_negative_stock(self, sle):
if sle.qty_after_transaction < 0 and sle.actual_qty < 0: 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}") 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.warehouse, .format(sle.item_code, sle.voucher_type, sle.voucher_no))
sle.item_code, sle.posting_date, sle.posting_time, self.name))
def get_voucher_details(self, default_expense_account, default_cost_center, sle_map): def get_voucher_details(self, default_expense_account, default_cost_center, sle_map):
if self.doctype == "Stock Reconciliation": if self.doctype == "Stock Reconciliation":

View File

@ -93,7 +93,7 @@ class LeaveAllocation(Document):
if flt(leaves_taken) > flt(self.total_leaves_allocated): if flt(leaves_taken) > flt(self.total_leaves_allocated):
if frappe.db.get_value("Leave Type", self.leave_type, "allow_negative"): 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: 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) 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)

View File

@ -304,9 +304,9 @@ class ProductionOrder(Document):
def get_operations_data(self, data): def get_operations_data(self, data):
return { return {
'from_time': data.planned_start_time, 'from_time': get_datetime(data.planned_start_time),
'hours': data.time_in_mins / 60.0, 'hours': data.time_in_mins / 60.0,
'to_time': data.planned_end_time, 'to_time': get_datetime(data.planned_end_time),
'project': self.project, 'project': self.project,
'operation': data.operation, 'operation': data.operation,
'operation_id': data.name, 'operation_id': data.name,

View File

@ -362,3 +362,4 @@ execute:frappe.delete_doc('Desktop Icon', {'module_name': 'Profit and Loss Statm
erpnext.patches.v7_2.update_website_for_variant erpnext.patches.v7_2.update_website_for_variant
erpnext.patches.v7_2.update_doctype_status erpnext.patches.v7_2.update_doctype_status
erpnext.patches.v7_2.update_salary_slips erpnext.patches.v7_2.update_salary_slips
erpnext.patches.v7_2.set_null_value_to_fields

View File

@ -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)

View File

@ -26,6 +26,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "", "label": "",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -54,6 +55,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Series", "label": "Series",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -82,6 +84,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Item Code", "label": "Item Code",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 1,
@ -112,6 +115,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 1,
"label": "Variant Of", "label": "Variant Of",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -140,6 +144,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 1, "in_filter": 1,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Item Name", "label": "Item Name",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -168,6 +173,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Barcode", "label": "Barcode",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 1,
@ -195,6 +201,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 1, "in_filter": 1,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 1,
"label": "Item Group", "label": "Item Group",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -225,6 +232,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Unit of Measure", "label": "Default Unit of Measure",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -254,6 +262,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -279,6 +288,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Disabled", "label": "Disabled",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -308,6 +318,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Maintain Stock", "label": "Maintain Stock",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -338,6 +349,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Opening Stock", "label": "Opening Stock",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -353,39 +365,40 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 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", "fieldname": "standard_rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@ -393,6 +406,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Standard Selling Rate", "label": "Standard Selling Rate",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -420,6 +434,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Is Fixed Asset", "label": "Is Fixed Asset",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -448,6 +463,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Asset Category", "label": "Asset Category",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -476,6 +492,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Image", "label": "Image",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -504,6 +521,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Description", "label": "Description",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -531,6 +549,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Brand", "label": "Brand",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -560,6 +579,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Description", "label": "Description",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -590,6 +610,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Inventory", "label": "Inventory",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -620,6 +641,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Warehouse", "label": "Default Warehouse",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -651,6 +673,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "End of Life", "label": "End of Life",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -681,6 +704,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Has Batch No", "label": "Has Batch No",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -713,6 +737,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 1, "in_filter": 1,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Has Serial No", "label": "Has Serial No",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -744,6 +769,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Serial Number Series", "label": "Serial Number Series",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -771,6 +797,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Material Request Type", "label": "Default Material Request Type",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -800,6 +827,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"oldfieldtype": "Column Break", "oldfieldtype": "Column Break",
@ -829,6 +857,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Allow over delivery or receipt upto this percent", "label": "Allow over delivery or receipt upto this percent",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -858,6 +887,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Valuation Method", "label": "Valuation Method",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -886,6 +916,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Warranty Period (in days)", "label": "Warranty Period (in days)",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -916,6 +947,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Net Weight", "label": "Net Weight",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -943,6 +975,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Weight UOM", "label": "Weight UOM",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -972,6 +1005,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Auto re-order", "label": "Auto re-order",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1001,6 +1035,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Reorder level based on Warehouse", "label": "Reorder level based on Warehouse",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1030,6 +1065,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Variants", "label": "Variants",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1060,6 +1096,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Has Variants", "label": "Has Variants",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 1,
@ -1089,6 +1126,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Attributes", "label": "Attributes",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 1,
@ -1117,6 +1155,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Purchase Details", "label": "Purchase Details",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1146,6 +1185,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Is Purchase Item", "label": "Is Purchase Item",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1176,6 +1216,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Minimum Order Qty", "label": "Minimum Order Qty",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1204,6 +1245,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Safety Stock", "label": "Safety Stock",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1233,6 +1275,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Lead Time in days", "label": "Lead Time in days",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1263,6 +1306,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Buying Cost Center", "label": "Default Buying Cost Center",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1294,6 +1338,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Expense Account", "label": "Default Expense Account",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1324,6 +1369,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Unit of Measure Conversion", "label": "Unit of Measure Conversion",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1353,6 +1399,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "UOMs", "label": "UOMs",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 1,
@ -1383,6 +1430,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Last Purchase Rate", "label": "Last Purchase Rate",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 1,
@ -1412,6 +1460,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Supplier Details", "label": "Supplier Details",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1440,6 +1489,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Supplier", "label": "Default Supplier",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1467,6 +1517,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Delivered by Supplier (Drop Ship)", "label": "Delivered by Supplier (Drop Ship)",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1495,6 +1546,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Manufacturer", "label": "Manufacturer",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1523,6 +1575,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Manufacturer Part Number", "label": "Manufacturer Part Number",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1550,6 +1603,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Item Code for Suppliers", "label": "Item Code for Suppliers",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1579,6 +1633,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Supplier Items", "label": "Supplier Items",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1606,6 +1661,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Sales Details", "label": "Sales Details",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1635,6 +1691,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Is Sales Item", "label": "Is Sales Item",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1664,6 +1721,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Publish in Hub", "label": "Publish in Hub",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1692,6 +1750,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Synced With Hub", "label": "Synced With Hub",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1720,6 +1779,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Income Account", "label": "Default Income Account",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1748,6 +1808,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Selling Cost Center", "label": "Default Selling Cost Center",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1776,6 +1837,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Customer Item Codes", "label": "Customer Item Codes",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1806,6 +1868,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Customer Items", "label": "Customer Items",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1834,6 +1897,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Max Discount (%)", "label": "Max Discount (%)",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1862,6 +1926,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Item Tax", "label": "Item Tax",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1891,6 +1956,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Taxes", "label": "Taxes",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1920,6 +1986,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Inspection Criteria", "label": "Inspection Criteria",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1949,6 +2016,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Inspection Required before Purchase", "label": "Inspection Required before Purchase",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -1978,6 +2046,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Inspection Required before Delivery", "label": "Inspection Required before Delivery",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2007,6 +2076,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Quality Parameters", "label": "Quality Parameters",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2037,6 +2107,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Manufacturing", "label": "Manufacturing",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2066,6 +2137,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Default BOM", "label": "Default BOM",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 1,
@ -2097,6 +2169,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Supply Raw Materials for Purchase", "label": "Supply Raw Materials for Purchase",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2126,6 +2199,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -2152,6 +2226,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 1, "in_filter": 1,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Customer Code", "label": "Customer Code",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 1,
@ -2178,6 +2253,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Website", "label": "Website",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2206,6 +2282,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Show in Website", "label": "Show in Website",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2233,6 +2310,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Show in Website (Variant)", "label": "Show in Website (Variant)",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2261,6 +2339,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Route", "label": "Route",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2290,6 +2369,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Weightage", "label": "Weightage",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2318,6 +2398,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Slideshow", "label": "Slideshow",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2347,6 +2428,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Image", "label": "Image",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2374,6 +2456,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Thumbnail", "label": "Thumbnail",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2401,6 +2484,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -2428,6 +2512,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Website Warehouse", "label": "Website Warehouse",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2457,6 +2542,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Website Item Groups", "label": "Website Item Groups",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2486,6 +2572,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Website Specifications", "label": "Website Specifications",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2513,6 +2600,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Copy From Item Group", "label": "Copy From Item Group",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2540,6 +2628,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Website Specifications", "label": "Website Specifications",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2568,6 +2657,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Website Description", "label": "Website Description",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2594,6 +2684,7 @@
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Total Projected Qty", "label": "Total Projected Qty",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -2622,7 +2713,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 1, "max_attachments": 1,
"modified": "2017-01-10 12:02:51.807965", "modified": "2017-01-18 17:43:20.262925",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Item", "name": "Item",

View File

@ -15,6 +15,7 @@
"item_group": "_Test Item Group", "item_group": "_Test Item Group",
"item_name": "_Test Item", "item_name": "_Test Item",
"apply_warehouse_wise_reorder_level": 1, "apply_warehouse_wise_reorder_level": 1,
"valuation_rate": 100,
"reorder_levels": [ "reorder_levels": [
{ {
"material_request_type": "Purchase", "material_request_type": "Purchase",
@ -61,6 +62,7 @@
"item_code": "_Test Item Home Desktop 100", "item_code": "_Test Item Home Desktop 100",
"item_group": "_Test Item Group Desktops", "item_group": "_Test Item Group Desktops",
"item_name": "_Test Item Home Desktop 100", "item_name": "_Test Item Home Desktop 100",
"valuation_rate": 100,
"taxes": [ "taxes": [
{ {
"doctype": "Item Tax", "doctype": "Item Tax",

View File

@ -12,22 +12,23 @@ class LandedCostVoucher(Document):
def get_items_from_purchase_receipts(self): def get_items_from_purchase_receipts(self):
self.set("items", []) self.set("items", [])
for pr in self.get("purchase_receipts"): for pr in self.get("purchase_receipts"):
pr_items = frappe.db.sql("""select pr_item.item_code, pr_item.description, if pr.receipt_document_type and pr.receipt_document:
pr_item.qty, pr_item.base_rate, pr_item.base_amount, pr_item.name pr_items = frappe.db.sql("""select pr_item.item_code, pr_item.description,
from `tab{doctype} Item` pr_item where parent = %s pr_item.qty, pr_item.base_rate, pr_item.base_amount, pr_item.name
and exists(select name from tabItem where name = pr_item.item_code and is_stock_item = 1) from `tab{doctype} Item` pr_item where parent = %s
""".format(doctype=pr.receipt_document_type), pr.receipt_document, as_dict=True) 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: for d in pr_items:
item = self.append("items") item = self.append("items")
item.item_code = d.item_code item.item_code = d.item_code
item.description = d.description item.description = d.description
item.qty = d.qty item.qty = d.qty
item.rate = d.base_rate item.rate = d.base_rate
item.amount = d.base_amount item.amount = d.base_amount
item.receipt_document_type = pr.receipt_document_type item.receipt_document_type = pr.receipt_document_type
item.receipt_document = pr.receipt_document item.receipt_document = pr.receipt_document
item.purchase_receipt_item = d.name item.purchase_receipt_item = d.name
if self.get("taxes"): if self.get("taxes"):
self.set_applicable_charges_for_item() self.set_applicable_charges_for_item()

View File

@ -258,6 +258,10 @@ class update_entries_after(object):
if not self.valuation_rate and actual_qty > 0: if not self.valuation_rate and actual_qty > 0:
self.valuation_rate = sle.incoming_rate 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): def get_fifo_values(self, sle):
incoming_rate = flt(sle.incoming_rate) incoming_rate = flt(sle.incoming_rate)
@ -281,10 +285,9 @@ class update_entries_after(object):
qty_to_pop = abs(actual_qty) qty_to_pop = abs(actual_qty)
while qty_to_pop: while qty_to_pop:
if not self.stock_queue: if not self.stock_queue:
if self.qty_after_transaction > 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, self.allow_zero_rate) _rate = get_valuation_rate(sle.item_code, sle.warehouse,
else: sle.voucher_type, sle.voucher_no, self.allow_zero_rate)
_rate = 0
self.stock_queue.append([0, _rate]) self.stock_queue.append([0, _rate])
index = None index = None
@ -404,7 +407,8 @@ def get_stock_ledger_entries(previous_sle, operator=None, order="desc", limit=No
"order": order "order": order
}, previous_sle, as_dict=1, debug=debug) }, 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 last_valuation_rate = frappe.db.sql("""select valuation_rate
from `tabStock Ledger Entry` from `tabStock Ledger Entry`
where item_code = %s and warehouse = %s where item_code = %s and warehouse = %s
@ -412,6 +416,7 @@ def get_valuation_rate(item_code, warehouse, allow_zero_rate=False):
order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, warehouse)) order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, warehouse))
if not last_valuation_rate: 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 last_valuation_rate = frappe.db.sql("""select valuation_rate
from `tabStock Ledger Entry` from `tabStock Ledger Entry`
where item_code = %s and valuation_rate > 0 where item_code = %s and valuation_rate > 0
@ -420,9 +425,14 @@ def get_valuation_rate(item_code, warehouse, allow_zero_rate=False):
valuation_rate = flt(last_valuation_rate[0][0]) if last_valuation_rate else 0 valuation_rate = flt(last_valuation_rate[0][0]) if last_valuation_rate else 0
if not valuation_rate: 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")): if not allow_zero_rate and not valuation_rate \
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)) 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 return valuation_rate