From fcd70d04f3d4a00f5ea7d43064ef180179b6ace8 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 18 Oct 2013 14:24:21 +0530 Subject: [PATCH 1/3] [item price] item price made as an individual master and removed from price list --- accounts/doctype/sales_invoice/pos.js | 55 ++-- accounts/doctype/sales_invoice/pos.py | 29 +- buying/page/buying_home/buying_home.js | 7 +- buying/utils.py | 7 +- manufacturing/doctype/bom/bom.py | 2 +- ...ice_list_and_item_details_in_item_price.py | 20 ++ patches/patch_list.py | 1 + public/js/transaction.js | 34 +++ selling/doctype/sales_common/sales_common.js | 3 +- selling/page/selling_home/selling_home.js | 7 +- selling/utils/__init__.py | 25 +- selling/utils/product.py | 5 +- setup/doctype/item_price/item_price.js | 16 ++ setup/doctype/item_price/item_price.py | 31 ++- setup/doctype/item_price/item_price.txt | 84 +++++- setup/doctype/item_price/test_item_price.py | 23 ++ setup/doctype/price_list/price_list.js | 254 +----------------- setup/doctype/price_list/price_list.py | 18 +- setup/doctype/price_list/price_list.txt | 23 +- setup/doctype/price_list/test_price_list.py | 15 -- stock/doctype/item/item.js | 10 + stock/report/item_prices/item_prices.py | 7 +- 22 files changed, 312 insertions(+), 364 deletions(-) create mode 100644 patches/october_2013/p02_update_price_list_and_item_details_in_item_price.py create mode 100644 setup/doctype/item_price/item_price.js create mode 100644 setup/doctype/item_price/test_item_price.py diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index c68b9915c8..043fe90fc1 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -167,7 +167,7 @@ erpnext.POS = Class.extend({ "fieldtype": "Data", "label": "Barcode", "fieldname": "pos_barcode", - "placeholder": "Barcode" + "placeholder": "Barcode / Serial No" }, parent: this.wrapper.find(".barcode-area") }); @@ -228,7 +228,7 @@ erpnext.POS = Class.extend({ } }); }, - add_to_cart: function(item_code) { + add_to_cart: function(item_code, serial_no) { var me = this; var caught = false; @@ -239,39 +239,46 @@ erpnext.POS = Class.extend({ if (no_of_items != 0) { $.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, this.frm.cscript.fname, this.frm.doctype), function(i, d) { - if (d.item_code == item_code) + if (d.item_code == item_code) { caught = true; + if (serial_no) { + d.serial_no += '\n' + serial_no; + me.frm.script_manager.trigger("serial_no", d.doctype, d.name); + } + else { + d.qty += 1; + me.frm.script_manager.trigger("qty", d.doctype, d.name); + } + } }); } - // if duplicate row then append the qty - if (caught) { - me.update_qty(item_code, 1); - } - else { + // if item not found then add new item + if (!caught) { var child = wn.model.add_child(me.frm.doc, this.frm.doctype + " Item", this.frm.cscript.fname); child.item_code = item_code; - me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name); + + if (serial_no) + child.serial_no = serial_no; + + me.frm.script_manager.trigger("item_code", child.doctype, child.name); } + me.refresh(); }, - update_qty: function(item_code, qty, textbox_qty) { + update_qty: function(item_code, qty) { var me = this; $.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, this.frm.cscript.fname, this.frm.doctype), function(i, d) { if (d.item_code == item_code) { - if (textbox_qty) { - if (qty == 0 && d.item_code == item_code) - wn.model.clear_doc(d.doctype, d.name); + if (qty == 0) + wn.model.clear_doc(d.doctype, d.name); + else { d.qty = qty; + me.frm.script_manager.trigger("qty", d.doctype, d.name); } - else - d.qty += 1; - - me.frm.cscript.qty(me.frm.doc, d.doctype, d.name); } }); - me.frm.dirty(); me.refresh(); }, refresh: function() { @@ -352,7 +359,7 @@ erpnext.POS = Class.extend({ // append quantity to the respective item after change from input box $(this.wrapper).find("input.qty").on("change", function() { var item_code = $(this).closest("tr")[0].id; - me.update_qty(item_code, $(this).val(), true); + me.update_qty(item_code, $(this).val()); }); // on td click toggle the highlighting of row @@ -407,11 +414,14 @@ erpnext.POS = Class.extend({ var me = this; me.barcode_timeout = null; wn.call({ - method: 'accounts.doctype.sales_invoice.pos.get_item_from_barcode', - args: {barcode: this.barcode.$input.val()}, + method: 'accounts.doctype.sales_invoice.pos.get_item_code', + args: {barcode_serial_no: this.barcode.$input.val()}, callback: function(r) { if (r.message) { - me.add_to_cart(r.message[0].name); + if (r.message[1] == "serial_no") + me.add_to_cart(r.message[0][0].item_code, r.message[0][0].name); + else + me.add_to_cart(r.message[0][0].name); } else msgprint(wn._("Invalid Barcode")); @@ -443,7 +453,6 @@ erpnext.POS = Class.extend({ }); this.frm.fields_dict[this.frm.cscript.fname].grid.refresh(); this.frm.script_manager.trigger("calculate_taxes_and_totals"); - me.frm.dirty(); me.refresh(); }, make_payment: function() { diff --git a/accounts/doctype/sales_invoice/pos.py b/accounts/doctype/sales_invoice/pos.py index 44fe40d8de..7bebbd2db8 100644 --- a/accounts/doctype/sales_invoice/pos.py +++ b/accounts/doctype/sales_invoice/pos.py @@ -20,25 +20,30 @@ def get_items(price_list, sales_or_purchase, item=None, item_group=None): condition += " and i.name='%s'" % item return webnotes.conn.sql("""select i.name, i.item_name, i.image, - pl_items.ref_rate, pl_items.currency + item_det.ref_rate, item_det.currency from `tabItem` i LEFT JOIN - (select ip.item_code, ip.ref_rate, pl.currency from - `tabItem Price` ip, `tabPrice List` pl - where ip.parent=%s and ip.parent = pl.name) pl_items + (select item_code, ref_rate, currency from + `tabItem Price` where price_list=%s) item_det ON - pl_items.item_code=i.name + item_det.item_code=i.name where %s""" % ('%s', condition), (price_list), as_dict=1) @webnotes.whitelist() -def get_item_from_barcode(barcode): - return webnotes.conn.sql("""select name from `tabItem` where barcode=%s""", - (barcode), as_dict=1) +def get_item_code(barcode_serial_no): + input_via = "serial_no" + item_code = webnotes.conn.sql("""select name, item_code from `tabSerial No` where + name=%s""", (barcode_serial_no), as_dict=1) -@webnotes.whitelist() -def get_item_from_serial_no(serial_no): - return webnotes.conn.sql("""select name, item_code from `tabSerial No` where - name=%s""", (serial_no), as_dict=1) + if not item_code: + input_via = "barcode" + item_code = webnotes.conn.sql("""select name from `tabItem` where barcode=%s""", + (barcode_serial_no), as_dict=1) + + if item_code: + return item_code, input_via + else: + webnotes.throw("Invalid Barcode / Serial No") @webnotes.whitelist() def get_mode_of_payment(): diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js index eec0725de9..b6de994e96 100644 --- a/buying/page/buying_home/buying_home.js +++ b/buying/page/buying_home/buying_home.js @@ -67,9 +67,14 @@ wn.module_page["Buying"] = [ }, { label: wn._("Price List"), - description: wn._("Mupltiple Item prices."), + description: wn._("Multiple Price list."), doctype:"Price List" }, + { + label: wn._("Item Price"), + description: wn._("Multiple Item prices."), + doctype:"Item Price" + }, { "doctype":"Supplier Type", "label": wn._("Supplier Type"), diff --git a/buying/utils.py b/buying/utils.py index 115b023962..385a8c7b51 100644 --- a/buying/utils.py +++ b/buying/utils.py @@ -89,10 +89,9 @@ def _get_price_list_rate(args, item_bean, meta): # try fetching from price list if args.buying_price_list and args.price_list_currency: - price_list_rate = webnotes.conn.sql("""select ip.ref_rate from `tabItem Price` ip, - `tabPrice List` pl where ip.parent = pl.name and ip.parent=%s and - ip.item_code=%s and pl.buying_or_selling='Buying'""", - (args.buying_price_list, args.item_code), as_dict=1) + price_list_rate = webnotes.conn.sql("""select ref_rate from `tabItem Price` + where price_list=%s and item_code=%s and buying_or_selling='Buying'""", + (args.buying_price_list, args.item_code), as_dict=1) if price_list_rate: from utilities.transaction_base import validate_currency diff --git a/manufacturing/doctype/bom/bom.py b/manufacturing/doctype/bom/bom.py index 9a566123c7..c3dd7244fe 100644 --- a/manufacturing/doctype/bom/bom.py +++ b/manufacturing/doctype/bom/bom.py @@ -121,7 +121,7 @@ class DocType: elif self.doc.rm_cost_as_per == "Price List": if not self.doc.buying_price_list: webnotes.throw(_("Please select Price List")) - rate = webnotes.conn.get_value("Item Price", {"parent": self.doc.buying_price_list, + rate = webnotes.conn.get_value("Item Price", {"price_list": self.doc.buying_price_list, "item_code": arg["item_code"]}, "ref_rate") or 0 elif self.doc.rm_cost_as_per == 'Standard Rate': rate = arg['standard_rate'] diff --git a/patches/october_2013/p02_update_price_list_and_item_details_in_item_price.py b/patches/october_2013/p02_update_price_list_and_item_details_in_item_price.py new file mode 100644 index 0000000000..209ebf3574 --- /dev/null +++ b/patches/october_2013/p02_update_price_list_and_item_details_in_item_price.py @@ -0,0 +1,20 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + webnotes.reload_doc("setup", "doctype", "item_price") + + webnotes.conn.sql("""update `tabItem Price` ip, `tabItem` i + set ip.item_name=i.item_name, ip.item_description=i.description + where ip.item_code=i.name""") + + webnotes.conn.sql("""update `tabItem Price` ip, `tabPrice List` pl + set ip.price_list=pl.name, ip.currency=pl.currency, + ip.buying_or_selling=pl.buying_or_selling + where ip.parent=pl.name""") + + webnotes.conn.sql("""update `tabItem Price` + set parent=null, parenttype=null, parentfield=null, idx=null""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 59e0b0cf87..a4f0ec058d 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -222,4 +222,5 @@ patch_list = [ "patches.october_2013.fix_is_cancelled_in_sle", "patches.october_2013.repost_ordered_qty", "patches.october_2013.repost_planned_qty", + "patches.october_2013.p02_update_price_list_and_item_details_in_item_price", ] \ No newline at end of file diff --git a/public/js/transaction.js b/public/js/transaction.js index e948829af9..feae758d8f 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -114,6 +114,40 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.frm.refresh(); } }, + + serial_no: function(doc, cdt, cdn) { + var me = this; + var item = wn.model.get_doc(cdt, cdn); + + if (item.serial_no) { + if (!item.item_code) { + this.frm.script_manager.trigger("item_code", cdt, cdn); + } + else { + var sr_no = []; + + // Replacing all occurences of comma with carriage return + var serial_nos = item.serial_no.trim().replace(/,/g, '\n'); + + serial_nos = serial_nos.trim().split('\n'); + + // Trim each string and push unique string to new list + for (var x=0; x<=serial_nos.length - 1; x++) { + if (serial_nos[x].trim() != "" && sr_no.indexOf(serial_nos[x].trim()) == -1) { + sr_no.push(serial_nos[x].trim()); + } + } + + // Add the new list to the serial no. field in grid with each in new line + item.serial_no = ""; + for (var x=0; x<=sr_no.length - 1; x++) + item.serial_no += sr_no[x] + '\n'; + + refresh_field("serial_no", item.name, item.parentfield); + wn.model.set_value(item.doctype, item.name, "qty", sr_no.length); + } + } + }, validate: function() { this.calculate_taxes_and_totals(); diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js index c87e823dba..8203af843f 100644 --- a/selling/doctype/sales_common/sales_common.js +++ b/selling/doctype/sales_common/sales_common.js @@ -160,7 +160,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ item_code: function(doc, cdt, cdn) { var me = this; var item = wn.model.get_doc(cdt, cdn); - if(item.item_code || item.barcode) { + if(item.item_code || item.barcode || item.serial_no) { if(!this.validate_company_and_party("customer")) { cur_frm.fields_dict[me.frm.cscript.fname].grid.grid_rows[item.idx - 1].remove(); } else { @@ -171,6 +171,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ args: { item_code: item.item_code, barcode: item.barcode, + serial_no: item.serial_no, warehouse: item.warehouse, doctype: me.frm.doc.doctype, parentfield: item.parentfield, diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 9697ccf985..a69e50b06b 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -83,9 +83,14 @@ wn.module_page["Selling"] = [ }, { label: wn._("Price List"), - description: wn._("Mupltiple Item prices."), + description: wn._("Multiple Price list."), doctype:"Price List" }, + { + label: wn._("Item Price"), + description: wn._("Multiple Item prices."), + doctype:"Item Price" + }, { label: wn._("Sales BOM"), description: wn._("Bundle items at time of sale."), diff --git a/selling/utils/__init__.py b/selling/utils/__init__.py index 6e74ac4869..fd9c492b89 100644 --- a/selling/utils/__init__.py +++ b/selling/utils/__init__.py @@ -40,7 +40,9 @@ def get_item_details(args): args = webnotes._dict(args) if args.barcode: - args.item_code = _get_item_code(args.barcode) + args.item_code = _get_item_code(barcode=args.barcode) + elif not args.item_code and args.serial_no: + args.item_code = _get_item_code(serial_no=args.serial_no) item_bean = webnotes.bean("Item", args.item_code) @@ -88,15 +90,17 @@ def _get_serial_nos_by_fifo(args, item_bean): "qty": cint(args.qty) })) -def _get_item_code(barcode): - item_code = webnotes.conn.sql_list("""select name from `tabItem` where barcode=%s""", barcode) +def _get_item_code(barcode=None, serial_no=None): + if barcode: + input_type = "Barcode" + item_code = webnotes.conn.sql_list("""select name from `tabItem` where barcode=%s""", barcode) + elif serial_no: + input_type = "Serial No" + item_code = webnotes.conn.sql_list("""select item_code from `tabSerial No` + where name=%s""", serial_no) if not item_code: - msgprint(_("No Item found with Barcode") + ": %s" % barcode, raise_exception=True) - - elif len(item_code) > 1: - msgprint(_("Items") + " %s " % comma_and(item_code) + - _("have the same Barcode") + " %s" % barcode, raise_exception=True) + msgprint(_("No Item found with ") + input_type + ": %s" % (barcode or serial_no), raise_exception=True) return item_code[0] @@ -142,9 +146,8 @@ def _get_basic_details(args, item_bean, warehouse_fieldname): return out def _get_price_list_rate(args, item_bean, meta): - ref_rate = webnotes.conn.sql("""select ip.ref_rate from `tabItem Price` ip, - `tabPrice List` pl where ip.parent = pl.name and ip.parent=%s and - ip.item_code=%s and pl.buying_or_selling='Selling'""", + ref_rate = webnotes.conn.sql("""select ref_rate from `tabItem Price` + where price_list=%s and item_code=%s and buying_or_selling='Selling'""", (args.selling_price_list, args.item_code), as_dict=1) if not ref_rate: diff --git a/selling/utils/product.py b/selling/utils/product.py index 3432170a01..df5f16df5c 100644 --- a/selling/utils/product.py +++ b/selling/utils/product.py @@ -27,9 +27,8 @@ def get_product_info(item_code): else: in_stock = -1 - price = price_list and webnotes.conn.sql("""select ip.ref_rate, pl.currency from - `tabItem Price` ip, `tabPrice List` pl where ip.parent = pl.name and - ip.item_code=%s and ip.parent=%s""", + price = price_list and webnotes.conn.sql("""select ref_rate, currency from + `tabItem Price` where item_code=%s and price_list=%s""", (item_code, price_list), as_dict=1) or [] price = price and price[0] or None diff --git a/setup/doctype/item_price/item_price.js b/setup/doctype/item_price/item_price.js new file mode 100644 index 0000000000..0a08c984da --- /dev/null +++ b/setup/doctype/item_price/item_price.js @@ -0,0 +1,16 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +// License: GNU General Public License v3. See license.txt + +$.extend(cur_frm.cscript, { + + onload: function () { + + // Fetch price list details + cur_frm.add_fetch("price_list", "buying_or_selling", "buying_or_selling"); + cur_frm.add_fetch("price_list", "currency", "currency"); + + // Fetch item details + cur_frm.add_fetch("item_code", "item_name", "item_name"); + cur_frm.add_fetch("item_code", "description", "item_description"); + } +}); \ No newline at end of file diff --git a/setup/doctype/item_price/item_price.py b/setup/doctype/item_price/item_price.py index 3256c80d42..ddde87e98a 100644 --- a/setup/doctype/item_price/item_price.py +++ b/setup/doctype/item_price/item_price.py @@ -5,7 +5,36 @@ from __future__ import unicode_literals import webnotes +from webnotes import _ + +class ItemPriceDuplicateItem(Exception): pass class DocType: def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file + self.doc, self.doclist = d, dl + + def on_update(self): + self.update_price_list_details() + self.update_item_details() + self.check_duplicate_item() + + def update_price_list_details(self): + self.doc.buying_or_selling = webnotes.conn.get_value("Price List", self.doc.price_list, + "buying_or_selling") + + self.doc.currency = webnotes.conn.get_value("Price List", self.doc.price_list, + "currency") + + def update_item_details(self): + self.doc.item_name = webnotes.conn.get_value("Item", self.doc.item_code, "item_name") + + self.doc.item_description = webnotes.conn.get_value("Item", self.doc.item_code, + "description") + + def check_duplicate_item(self): + if webnotes.conn.sql("""select name from `tabItem Price` + where item_code=%s and price_list=%s and name!=%s""", + (self.doc.item_code, self.doc.price_list, self.doc.name)): + webnotes.throw(_("Duplicate Item: ") + self.doc.item_code + + _(" already available in Price List: ") + self.doc.price_list, + ItemPriceDuplicateItem) \ No newline at end of file diff --git a/setup/doctype/item_price/item_price.txt b/setup/doctype/item_price/item_price.txt index 4ff5124487..b101460f42 100644 --- a/setup/doctype/item_price/item_price.txt +++ b/setup/doctype/item_price/item_price.txt @@ -2,52 +2,126 @@ { "creation": "2013-05-02 16:29:48", "docstatus": 0, - "modified": "2013-09-13 11:50:02", + "modified": "2013-10-18 13:45:46", "modified_by": "Administrator", "owner": "Administrator" }, { "autoname": "RFD/.#####", + "description": "Multiple Item prices.", "doctype": "DocType", + "document_type": "Master", + "icon": "icon-flag", "in_create": 0, - "istable": 1, + "istable": 0, "module": "Setup", "name": "__common__", "read_only": 0 }, { "doctype": "DocField", - "in_filter": 1, - "in_list_view": 1, "name": "__common__", "parent": "Item Price", "parentfield": "fields", "parenttype": "DocType", + "permlevel": 0 + }, + { + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "name": "__common__", + "parent": "Item Price", + "parentfield": "permissions", + "parenttype": "DocType", "permlevel": 0, - "reqd": 1 + "read": 1, + "report": 1, + "write": 1 }, { "doctype": "DocType", "name": "Item Price" }, + { + "doctype": "DocField", + "fieldname": "price_list", + "fieldtype": "Link", + "in_filter": 1, + "label": "Price List", + "options": "Price List", + "reqd": 1 + }, { "doctype": "DocField", "fieldname": "item_code", "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, "label": "Item Code", "oldfieldname": "price_list_name", "oldfieldtype": "Select", "options": "Item", + "reqd": 1, "search_index": 1 }, { "doctype": "DocField", "fieldname": "ref_rate", "fieldtype": "Currency", + "in_filter": 1, + "in_list_view": 1, "label": "Rate", "oldfieldname": "ref_rate", "oldfieldtype": "Currency", "options": "currency", + "reqd": 1, "search_index": 0 + }, + { + "doctype": "DocField", + "fieldname": "col_br_1", + "fieldtype": "Column Break" + }, + { + "doctype": "DocField", + "fieldname": "buying_or_selling", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Valid for Buying or Selling?", + "options": "Selling\nBuying", + "reqd": 0 + }, + { + "doctype": "DocField", + "fieldname": "item_name", + "fieldtype": "Data", + "label": "Item Name", + "read_only": 1 + }, + { + "doctype": "DocField", + "fieldname": "item_description", + "fieldtype": "Text", + "label": "Item Description", + "read_only": 1 + }, + { + "doctype": "DocField", + "fieldname": "currency", + "fieldtype": "Link", + "hidden": 1, + "label": "Currency", + "options": "Currency", + "read_only": 1 + }, + { + "doctype": "DocPerm", + "role": "Sales Master Manager" + }, + { + "doctype": "DocPerm", + "role": "Purchase Master Manager" } ] \ No newline at end of file diff --git a/setup/doctype/item_price/test_item_price.py b/setup/doctype/item_price/test_item_price.py new file mode 100644 index 0000000000..43694da8fa --- /dev/null +++ b/setup/doctype/item_price/test_item_price.py @@ -0,0 +1,23 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import unittest +import webnotes +from setup.doctype.item_price.item_price import ItemPriceDuplicateItem + +class TestItem(unittest.TestCase): + def test_duplicate_item(self): + item_price = webnotes.bean(copy=test_records[0]) + self.assertRaises(ItemPriceDuplicateItem, item_price.insert) + +test_records = [ + [ + { + "doctype": "Item Price", + "price_list": "_Test Price List", + "item_code": "_Test Item", + "ref_rate": 100 + } + ] +] \ No newline at end of file diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 67090bcbc1..1f0693497d 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -5,253 +5,13 @@ $.extend(cur_frm.cscript, { onload: function() { erpnext.add_for_territory(); }, -}); -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - cur_frm.cscript.show_item_prices(); -} - -cur_frm.cscript.show_item_prices = function() { - var item_price = wn.model.get("Item Price", {parent: cur_frm.doc.name}); - - $(cur_frm.fields_dict.item_prices_html.wrapper).empty(); - - new wn.ui.form.TableGrid({ - parent: cur_frm.fields_dict.item_prices_html.wrapper, - frm: cur_frm, - table_field: wn.meta.get_docfield("Price List", "item_prices", cur_frm.doc.name) - }); -} - -wn.ui.form.TableGrid = Class.extend({ - init: function(opts) { - $.extend(this, opts); - this.fields = wn.meta.get_docfields("Item Price", cur_frm.doc.name); - this.make_table(); - }, - make_table: function() { - var me = this; - // Creating table & assigning attributes - var grid_table = document.createElement("table"); - grid_table.className = "table table-hover table-bordered table-grid"; - - // Appending header & rows to table - grid_table.appendChild(this.make_table_headers()); - grid_table.appendChild(this.make_table_rows()); - - // Creating button to add new row - var btn_div = document.createElement("div"); - var new_row_btn = document.createElement("button"); - new_row_btn.className = "btn btn-success table-new-row"; - new_row_btn.title = "Add new row"; - - var btn_icon = document.createElement("i"); - btn_icon.className = "icon-plus"; - new_row_btn.appendChild(btn_icon); - new_row_btn.innerHTML += " Add new row"; - btn_div.appendChild(new_row_btn); - - // Appending table & button to parent - var $grid_table = $(grid_table).appendTo($(this.parent)); - var $btn_div = $(btn_div).appendTo($(this.parent)); - - $btn_div.on("click", ".table-new-row", function() { - me.make_dialog(); - return false; - }); - - $grid_table.on("click", ".table-row", function() { - me.make_dialog(this); - return false; - }); - }, - make_table_headers: function() { - var me = this; - var header = document.createElement("thead"); - - // Creating header row - var row = document.createElement("tr"); - row.className = "active"; - - // Creating head first cell - var th = document.createElement("th"); - th.width = "8%"; - th.className = "text-center"; - th.innerHTML = "#"; - row.appendChild(th); - - // Make other headers with label as heading - for(var i=0, l=this.fields.length; i Date: Fri, 18 Oct 2013 15:24:53 +0530 Subject: [PATCH 2/3] [report] created new item-wise price list rate report --- patches/patch_list.py | 1 + setup/report/item_wise_price_list/__init__.py | 0 .../item_wise_price_list.txt | 22 ------------------- .../item_wise_price_list_rate.txt | 4 ++-- stock/page/stock_home/stock_home.js | 4 ++-- 5 files changed, 5 insertions(+), 26 deletions(-) delete mode 100644 setup/report/item_wise_price_list/__init__.py delete mode 100644 setup/report/item_wise_price_list/item_wise_price_list.txt diff --git a/patches/patch_list.py b/patches/patch_list.py index a4f0ec058d..0b27a2e0d8 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -223,4 +223,5 @@ patch_list = [ "patches.october_2013.repost_ordered_qty", "patches.october_2013.repost_planned_qty", "patches.october_2013.p02_update_price_list_and_item_details_in_item_price", + "execute:webnotes.delete_doc('Report', 'Item-wise Price List')", ] \ No newline at end of file diff --git a/setup/report/item_wise_price_list/__init__.py b/setup/report/item_wise_price_list/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/setup/report/item_wise_price_list/item_wise_price_list.txt b/setup/report/item_wise_price_list/item_wise_price_list.txt deleted file mode 100644 index 44118c8b13..0000000000 --- a/setup/report/item_wise_price_list/item_wise_price_list.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-09-25 10:29:04", - "docstatus": 0, - "modified": "2013-09-25 10:29:04", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "json": "{\"filters\":[[\"Item Price\",\"item_code\",\"like\",\"%\"],[\"Price List\",\"price_list_name\",\"like\",\"%\"]],\"columns\":[[\"item_code\",\"Item Price\"],[\"price_list_name\",\"Price List\"],[\"currency\",\"Price List\"],[\"ref_rate\",\"Item Price\"],[\"buying_or_selling\",\"Price List\"],[\"name\",\"Price List\"]],\"sort_by\":\"Price List.modified\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", - "name": "__common__", - "ref_doctype": "Price List", - "report_name": "Item-Wise Price List", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Item-Wise Price List" - } -] \ No newline at end of file diff --git a/setup/report/item_wise_price_list_rate/item_wise_price_list_rate.txt b/setup/report/item_wise_price_list_rate/item_wise_price_list_rate.txt index 08b1bef01d..a28ebfd241 100644 --- a/setup/report/item_wise_price_list_rate/item_wise_price_list_rate.txt +++ b/setup/report/item_wise_price_list_rate/item_wise_price_list_rate.txt @@ -2,14 +2,14 @@ { "creation": "2013-09-25 10:21:15", "docstatus": 0, - "modified": "2013-09-25 10:24:57", + "modified": "2013-10-18 15:08:36", "modified_by": "Administrator", "owner": "Administrator" }, { "doctype": "Report", "is_standard": "Yes", - "json": "{\"filters\":[[\"Item Price\",\"item_code\",\"like\",\"%\"],[\"Price List\",\"price_list_name\",\"like\",\"%\"]],\"columns\":[[\"item_code\",\"Item Price\"],[\"price_list_name\",\"Price List\"],[\"currency\",\"Price List\"],[\"ref_rate\",\"Item Price\"],[\"buying_or_selling\",\"Price List\"],[\"name\",\"Price List\"]],\"sort_by\":\"Price List.modified\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", + "json": "{\"filters\":[[\"Item Price\",\"price_list\",\"like\",\"%\"],[\"Item Price\",\"item_code\",\"like\",\"%\"]],\"columns\":[[\"price_list\",\"Item Price\"],[\"item_code\",\"Item Price\"],[\"item_name\",\"Item Price\"],[\"item_description\",\"Item Price\"],[\"ref_rate\",\"Item Price\"],[\"buying_or_selling\",\"Item Price\"]],\"sort_by\":\"Item Price.modified\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", "name": "__common__", "ref_doctype": "Price List", "report_name": "Item-wise Price List Rate", diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index 63db6086ab..70fba89e6c 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -202,8 +202,8 @@ wn.module_page["Stock"] = [ }, { "label":wn._("Item-wise Price List Rate"), - route: "Report/Price List/Item-Wise Price List", - doctype: "Price List" + route: "Report/Item Price/Item-wise Price List Rate", + doctype: "Item Price" }, { "label":wn._("Purchase In Transit"), From cd80d86dbb0d73ef7b09096720a8fa91f3114a55 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 18 Oct 2013 15:35:13 +0530 Subject: [PATCH 3/3] [fix] [minor] renamed edit prices button from price list and item --- setup/doctype/price_list/price_list.js | 2 +- stock/doctype/item/item.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 1f0693497d..84c4c2f957 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -7,7 +7,7 @@ $.extend(cur_frm.cscript, { }, refresh: function() { - cur_frm.add_custom_button("Edit Prices", function() { + cur_frm.add_custom_button("Add / Edit Prices", function() { wn.route_options = { "price_list": cur_frm.doc.name }; diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index 8ea4cd21ea..ecd46125a5 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -30,7 +30,7 @@ cur_frm.cscript.make_dashboard = function() { } cur_frm.cscript.edit_prices_button = function() { - cur_frm.add_custom_button("Edit Prices", function() { + cur_frm.add_custom_button("Add / Edit Prices", function() { wn.route_options = { "item_code": cur_frm.doc.name };