From 06a6bcce17587b5e615fa1a98cc8aafb1a32559e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 5 Mar 2015 16:38:43 +0530 Subject: [PATCH] [fixes] pos, chart of accounts --- erpnext/accounts/doctype/sales_invoice/pos.py | 8 ++++--- .../page/accounts_browser/accounts_browser.js | 21 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index 7227f742b4..6047378197 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -23,13 +23,14 @@ def get_items(price_list, sales_or_purchase, item=None): return item_code # search barcode - item_code = frappe.db.sql("""select name, item_code from `tabItem` where barcode=%s""", + item_code = frappe.db.sql("""select name, item_code from `tabItem` + where barcode=%s""", (item), as_dict=1) if item_code: item_code[0]["barcode"] = item return item_code - condition += " and CONCAT(i.name, i.item_name) like %(name)s" + condition += " and (CONCAT(i.name, i.item_name) like %(name)s or (i.variant_of like %(name)s))" args["name"] = "%%%s%%" % item return frappe.db.sql("""select i.name, i.item_name, i.image, @@ -38,6 +39,7 @@ def get_items(price_list, sales_or_purchase, item=None): (select item_code, price_list_rate, currency from `tabItem Price` where price_list=%s) item_det ON - item_det.item_code=i.name + (item_det.item_code=i.name or item_det.item_code=i.variant_of) where + ifnull(i.has_variants, 0) = 0 and %s""" % ('%(price_list)s', condition), args, as_dict=1) diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index aaa59c08a7..1b3482d00c 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -203,7 +203,8 @@ erpnext.AccountsChart = Class.extend({ 'Equity', 'Cost of Goods Sold', 'Fixed Asset', 'Expense Account', 'Income Account', 'Tax', 'Chargeable'].join('\n'), description: __("Optional. This setting will be used to filter in various transactions.") }, - {fieldtype:'Float', fieldname:'tax_rate', label:__('Tax Rate')} + {fieldtype:'Float', fieldname:'tax_rate', label:__('Tax Rate')}, + {fieldtype:'Link', fieldname:'warehouse', label:__('Warehouse'), options:"Warehouse"} ] }) @@ -214,21 +215,16 @@ erpnext.AccountsChart = Class.extend({ if($(this).val()=='Group') { $(fd.account_type.wrapper).toggle(false); $(fd.tax_rate.wrapper).toggle(false); + $(fd.warehouse.wrapper).toggle(false); } else { - $(fd.account_type.wrapper).toggle(true); - if(fd.account_type.get_value()=='Tax') { - $(fd.tax_rate.wrapper).toggle(true); - } + fd.account_type.$input.trigger("change"); } }); // tax rate if tax $(fd.account_type.input).change(function() { - if($(this).val()=='Tax') { - $(fd.tax_rate.wrapper).toggle(true); - } else { - $(fd.tax_rate.wrapper).toggle(false); - } + $(fd.tax_rate.wrapper).toggle(fd.account_type.get_value()==='Tax'); + $(fd.warehouse.wrapper).toggle(fd.account_type.get_value()==='Warehouse'); }) // create @@ -237,6 +233,11 @@ erpnext.AccountsChart = Class.extend({ var v = d.get_values(); if(!v) return; + if(v.account_type==="Warehouse" && !v.warehouse) { + msgprint(__("Warehouse is required")); + return; + } + var node = me.tree.get_selected_node(); v.parent_account = node.label; v.company = me.company;