From 9c901e75cd9eb7e7ac40a1119660e09ec2d6283e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 12 Jun 2013 15:28:45 +0530 Subject: [PATCH 1/3] [sales invoice] [cleanup] removed basic info section --- accounts/doctype/sales_invoice/sales_invoice.txt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt index f5eb3564ee..27a0340f90 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.txt +++ b/accounts/doctype/sales_invoice/sales_invoice.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:05", "docstatus": 0, - "modified": "2013-06-05 18:53:03", + "modified": "2013-06-12 15:14:00", "modified_by": "Administrator", "owner": "Administrator" }, @@ -39,15 +39,6 @@ "doctype": "DocType", "name": "Sales Invoice" }, - { - "doctype": "DocField", - "fieldname": "basic_info", - "fieldtype": "Section Break", - "label": "Basic Info", - "oldfieldtype": "Section Break", - "print_hide": 1, - "read_only": 0 - }, { "description": "To manage multiple series please go to Setup > Manage Series", "doctype": "DocField", From 060d9248d37541118e047d96bc42ec8f65b454dd Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 12 Jun 2013 17:40:36 +0530 Subject: [PATCH 2/3] [fixes] buying/selling price lists, communication and website settings --- .../purchase_common/purchase_common.js | 6 +- buying/utils.py | 2 +- controllers/accounts_controller.py | 2 +- patches/january_2013/purchase_price_list.py | 4 +- .../p03_buying_selling_for_price_list.py | 14 +++++ patches/patch_list.py | 3 +- public/js/transaction.js | 4 +- selling/doctype/sales_common/sales_common.js | 2 +- selling/utils.py | 2 +- setup/doctype/price_list/price_list.js | 7 +-- setup/doctype/price_list/price_list.py | 6 +- setup/doctype/price_list/price_list.txt | 30 +++++++++- setup/utils.py | 6 +- stock/doctype/item/item.js | 3 +- stock/doctype/item_price/item_price.txt | 25 ++++----- .../doctype/support_ticket/support_ticket.js | 3 + utilities/transaction_base.py | 4 +- .../website_settings/website_settings.js | 56 ++++++++++++------- .../website_settings/website_settings.py | 30 +++++++++- website/helpers/product.py | 2 +- website/templates/css/product_page.css | 2 +- website/templates/html/product_in_grid.html | 14 +++++ .../templates/html/product_missing_image.html | 2 +- 23 files changed, 162 insertions(+), 67 deletions(-) create mode 100644 patches/june_2013/p03_buying_selling_for_price_list.py create mode 100644 website/templates/html/product_in_grid.html diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index eee7984a2b..4cf8de796c 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -28,13 +28,13 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ if(this.frm.fields_dict.price_list_name) { this.frm.set_query("price_list_name", function() { - return repl("select distinct price_list_name from `tabItem Price` \ - where buying = 1 and price_list_name like \"%s%%\""); + return repl("select name, currency from `tabPrice List` \ + where buying_or_selling = 'Buying' and name like \"%s%%\""); }); this.frm.set_query("price_list_currency", function() { return repl("select distinct ref_currency from `tabItem Price` \ - where price_list_name=\"%(price_list_name)s\" and buying = 1 \ + where price_list_name=\"%(price_list_name)s\" and buying_or_selling = 'Buying' \ and ref_currency like \"%s%%\"", {price_list_name: me.frm.doc.price_list_name}); }); diff --git a/buying/utils.py b/buying/utils.py index 1aaa5d11c9..3c8f69366b 100644 --- a/buying/utils.py +++ b/buying/utils.py @@ -102,7 +102,7 @@ def _get_price_list_rate(args, item_bean, meta): "parentfield": "ref_rate_details", "price_list_name": args.price_list_name, "ref_currency": args.price_list_currency, - "buying": 1}) + "buying_or_selling": "Buying"}) if price_list_rate: out.import_ref_rate = \ flt(price_list_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate) diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py index f417b310c4..bf5da8dd40 100644 --- a/controllers/accounts_controller.py +++ b/controllers/accounts_controller.py @@ -42,7 +42,7 @@ class AccountsController(TransactionBase): not self.doc.price_list_currency: self.doc.fields.update(get_price_list_currency({ "price_list_name": self.doc.price_list_name, - "use_for": buying_or_selling + "buying_or_selling": buying_or_selling })) def set_missing_item_details(self, get_item_details): diff --git a/patches/january_2013/purchase_price_list.py b/patches/january_2013/purchase_price_list.py index 02c260ed28..419e709fb2 100644 --- a/patches/january_2013/purchase_price_list.py +++ b/patches/january_2013/purchase_price_list.py @@ -4,6 +4,6 @@ def execute(): webnotes.reload_doc("stock", "doctype", "item_price") # check for selling - webnotes.conn.sql("""update `tabItem Price` set selling=1 - where ifnull(selling, 0)=0 and ifnull(buying, 0)=0""") + webnotes.conn.sql("""update `tabItem Price` set buying_or_selling = "Selling" + where ifnull(buying_or_selling, '')=''""") \ No newline at end of file diff --git a/patches/june_2013/p03_buying_selling_for_price_list.py b/patches/june_2013/p03_buying_selling_for_price_list.py new file mode 100644 index 0000000000..a41bda1ce8 --- /dev/null +++ b/patches/june_2013/p03_buying_selling_for_price_list.py @@ -0,0 +1,14 @@ +import webnotes +from webnotes.utils import cint + +def execute(): + for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""): + buying, selling = False, False + for b, s in webnotes.conn.sql("""select distinct buying, selling + from `tabItem Price` where price_list_name=%s""", price_list): + buying = buying or cint(b) + selling = selling or cint(s) + + webnotes.conn.set_value("Price List", price_list, "buying_or_selling", ("Selling" if selling else "Buying")) + webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s where price_list_name=%s""", + (("Selling" if selling else "Buying"), price_list)) diff --git a/patches/patch_list.py b/patches/patch_list.py index a1012baa09..035666c5a4 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -241,7 +241,8 @@ patch_list = [ "patches.june_2013.p01_update_bom_exploded_items", "patches.june_2013.p02_update_project_completed", "execute:webnotes.delete_doc('DocType', 'System Console')", + "patches.june_2013.p03_buying_selling_for_price_list", "patches.june_2013.p04_fix_event_for_lead_oppty_project", "patches.june_2013.p05_remove_unused_doctypes", - "patches.june_2013.p06_drop_unused_tables" + "patches.june_2013.p06_drop_unused_tables", ] \ No newline at end of file diff --git a/public/js/transaction.js b/public/js/transaction.js index b7df5b6876..a7e8c10a24 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -90,14 +90,14 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({ this.price_list_currency(); }, - price_list_name: function(use_for) { + price_list_name: function(buying_or_selling) { var me = this; if(this.frm.doc.price_list_name) { this.frm.call({ method: "setup.utils.get_price_list_currency", args: {args: { price_list_name: this.frm.doc.price_list_name, - use_for: use_for + buying_or_selling: buying_or_selling }}, callback: function(r) { if(!r.exc) { diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js index dc3f60d617..ef23bab59a 100644 --- a/selling/doctype/sales_common/sales_common.js +++ b/selling/doctype/sales_common/sales_common.js @@ -102,7 +102,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }, price_list_name: function() { - this._super("selling"); + this._super("Selling"); }, ref_rate: function(doc, cdt, cdn) { diff --git a/selling/utils.py b/selling/utils.py index 6901028710..8947cb51f6 100644 --- a/selling/utils.py +++ b/selling/utils.py @@ -135,7 +135,7 @@ def _get_price_list_rate(args, item_bean, meta): "parentfield": "ref_rate_details", "price_list_name": args.price_list_name, "price_list_currency": args.price_list_currency, - "selling": 1}) + "buying_or_selling": "Selling"}) if not base_ref_rate: return {} diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index b68627f73f..3bfa63af5e 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -21,6 +21,7 @@ cur_frm.cscript.onload = function() { cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.set_intro(""); if(doc.__islocal) { + cur_frm.toggle_display("item_prices_section", false); cur_frm.set_intro("Save this list to begin."); return; } else { @@ -41,16 +42,12 @@ cur_frm.cscript.show_item_prices = function() { \ ' + wn._("Item Code") + '\ ' + wn._("Price") + '\ - ' + wn._("Valid For Selling") + '\ - ' + wn._("Valid For Buying") + '\ \ ' + $.map(item_price.sort(function(a, b) { return a.parent.localeCompare(b.parent); }), function(d) { return '' - + '' + d.parent + '' + + '' + d.parent + '' + '' + format_currency(d.ref_rate, d.ref_currency) + '' - + '' + (cint(d.selling) ? '' : "") + '' - + '' + (cint(d.buying) ? '' : "") + '' + '' }).join("\n") + '\ diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py index 5c03a3a853..eae6a3cdd3 100644 --- a/setup/doctype/price_list/price_list.py +++ b/setup/doctype/price_list/price_list.py @@ -17,7 +17,7 @@ from __future__ import unicode_literals import webnotes from webnotes import msgprint, _ -from webnotes.utils import cint +from webnotes.utils import cint, comma_or class DocType: @@ -32,6 +32,10 @@ class DocType: if not (cint(self.doc.valid_for_all_countries) or len(self.doclist.get({"parentfield": "valid_for_countries"}))): msgprint(_("""Please check "Valid For All Countries" or \ enter atlease one row in the "Countries" table."""), raise_exception=True) + + if self.doc.buying_or_selling not in ["Buying", "Selling"]: + msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " + + comma_or(["Buying", "Selling"]), raise_exception=True) def on_trash(self): webnotes.conn.sql("""delete from `tabItem Price` where price_list_name = %s""", diff --git a/setup/doctype/price_list/price_list.txt b/setup/doctype/price_list/price_list.txt index 781eae5f68..ed432ec7b0 100644 --- a/setup/doctype/price_list/price_list.txt +++ b/setup/doctype/price_list/price_list.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-25 11:35:09", "docstatus": 0, - "modified": "2013-05-02 14:45:00", + "modified": "2013-06-11 20:00:07", "modified_by": "Administrator", "owner": "Administrator" }, @@ -60,6 +60,26 @@ "options": "Currency", "reqd": 1 }, + { + "default": "Selling", + "doctype": "DocField", + "fieldname": "buying_or_selling", + "fieldtype": "Select", + "label": "Valid for Buying or Selling?", + "options": "Buying\nSelling", + "reqd": 1 + }, + { + "doctype": "DocField", + "fieldname": "use_for_website", + "fieldtype": "Check", + "label": "Use for Website" + }, + { + "doctype": "DocField", + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, { "default": "1", "doctype": "DocField", @@ -68,7 +88,7 @@ "label": "Valid for all countries" }, { - "description": "A list of Countries, for which, this Price List is valid", + "description": "Or specify a list of Countries, for which, this Price List is valid", "doctype": "DocField", "fieldname": "valid_for_countries", "fieldtype": "Table", @@ -79,6 +99,7 @@ "doctype": "DocField", "fieldname": "item_prices_section", "fieldtype": "Section Break", + "hidden": 0, "label": "Item Prices" }, { @@ -87,6 +108,11 @@ "fieldtype": "HTML", "label": "Item Prices" }, + { + "doctype": "DocField", + "fieldname": "column_break_10", + "fieldtype": "Column Break" + }, { "depends_on": "eval:!doc.__islocal", "doctype": "DocField", diff --git a/setup/utils.py b/setup/utils.py index 33fa3e286e..69481171d6 100644 --- a/setup/utils.py +++ b/setup/utils.py @@ -34,16 +34,16 @@ def get_price_list_currency(args): """ args = { "price_list_name": "Something", - "use_for": "buying" or "selling" + "buying_or_selling": "Buying" or "Selling" } """ if isinstance(args, basestring): args = json.loads(args) result = webnotes.conn.sql("""select distinct ref_currency from `tabItem Price` - where price_list_name=%s and `%s`=1""" % ("%s", args.get("use_for")), + where price_list_name=%s and buying_or_selling=%s""" % ("%s", args.get("buying_or_selling")), (args.get("price_list_name"),)) if result and len(result)==1: return {"price_list_currency": result[0][0]} else: - return {} + return {} \ No newline at end of file diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index acc78e77dc..1dcd038f46 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -14,7 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -cur_frm.add_fetch("price_list_name", "currency", "ref_currency") +cur_frm.add_fetch("price_list_name", "currency", "ref_currency"); +cur_frm.add_fetch("price_list_name", "buying_or_selling", "buying_or_selling"); cur_frm.cscript.refresh = function(doc) { // make sensitive fields(has_serial_no, is_stock_item, valuation_method) diff --git a/stock/doctype/item_price/item_price.txt b/stock/doctype/item_price/item_price.txt index ad0b840c11..e4926cbebb 100644 --- a/stock/doctype/item_price/item_price.txt +++ b/stock/doctype/item_price/item_price.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-29 15:18:04", + "creation": "2013-05-02 16:29:48", "docstatus": 0, - "modified": "2013-04-29 19:16:45", + "modified": "2013-06-11 18:27:55", "modified_by": "Administrator", "owner": "Administrator" }, @@ -60,21 +60,18 @@ "oldfieldname": "ref_currency", "oldfieldtype": "Select", "options": "Currency", - "reqd": 1, + "read_only": 1, + "reqd": 0, "search_index": 1 }, { - "description": "Allow this price in sales related forms", + "default": "Selling", "doctype": "DocField", - "fieldname": "selling", - "fieldtype": "Check", - "label": "Valid For Selling" - }, - { - "description": "Allow this price in purchase related forms", - "doctype": "DocField", - "fieldname": "buying", - "fieldtype": "Check", - "label": "Valid For Buying" + "fieldname": "buying_or_selling", + "fieldtype": "Select", + "label": "Valid for Buying or Selling?", + "options": "Buying\nSelling", + "read_only": 1, + "reqd": 1 } ] \ No newline at end of file diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js index 4ea179dc87..beff192346 100644 --- a/support/doctype/support_ticket/support_ticket.js +++ b/support/doctype/support_ticket/support_ticket.js @@ -22,6 +22,9 @@ $.extend(cur_frm.cscript, { cur_frm.footer.help_area.innerHTML = '

Email Settings
\ Integrate incoming support emails to Support Ticket

'; } + + if(doc.description) + doc.description = wn.utils.escape_script_and_style(doc.description); }, refresh: function(doc) { diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index c17df6df8d..041c4cb55b 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -260,9 +260,7 @@ class TransactionBase(StatusUpdater): comm_list = webnotes.conn.sql("""select * from tabCommunication where %s=%s order by modified desc limit 20""" \ % (self.doc.doctype.replace(" ", "_").lower(), "%s"), - self.doc.name, as_dict=1) - - [d.update({"doctype":"Communication"}) for d in comm_list] + self.doc.name, as_dict=1, update={"doctype":"Communication"}) self.doclist.extend(webnotes.doclist([webnotes.doc(fielddata=d) \ for d in comm_list])) diff --git a/website/doctype/website_settings/website_settings.js b/website/doctype/website_settings/website_settings.js index 5858926ce2..57c32e90cc 100644 --- a/website/doctype/website_settings/website_settings.js +++ b/website/doctype/website_settings/website_settings.js @@ -17,29 +17,45 @@ // update parent select $.extend(cur_frm.cscript, { - onload_post_render: function(doc) { - // get labels of parent items - var get_parent_options = function(table_field) { - var items = getchildren('Top Bar Item', doc.name, table_field); - var main_items = ['']; - for(var i in items) { - var d = items[i]; - if(!d.parent_label) { - main_items.push(d.label); - } - } - return main_items.join('\n'); + this.set_parent_label_options(); + }, + + label: function(doc, cdt, cdn) { + var item = wn.model.get_doc(cdt, cdn); + if(item.parentfield === "top_bar_items") { + this.set_parent_label_options(); } + }, + + parent_label: function(doc, cdt, cdn) { + this.label(doc, cdt, cdn); + }, + + url: function(doc, cdt, cdn) { + this.label(doc, cdt, cdn); + } + + set_parent_label_options: function() { + wn.meta.get_docfield("Top Bar Item", "parent_label", cur_frm.docname).options = + this.get_parent_options("top_bar_items"); - // bind function to refresh fields - // when "Parent Label" is select, it - // should automatically update - // options - $(cur_frm.fields_dict['top_bar_items'].grid.get_field('parent_label').wrapper) - .bind('refresh', function() { - this.fieldobj.refresh_options(get_parent_options('top_bar_items')); - }); + if($(cur_frm.fields_dict.top_bar_items.grid.wrapper).find(".grid-row-open")) { + cur_frm.fields_dict.top_bar_items.grid.refresh(); + } + }, + + // get labels of parent items + get_parent_options: function(table_field) { + var items = getchildren('Top Bar Item', cur_frm.doc.name, table_field); + var main_items = ['']; + for(var i in items) { + var d = items[i]; + if(!d.parent_label && !d.url && d.label) { + main_items.push(d.label); + } + } + return main_items.join('\n'); } }); diff --git a/website/doctype/website_settings/website_settings.py b/website/doctype/website_settings/website_settings.py index 77eb1c5025..182f063b6f 100644 --- a/website/doctype/website_settings/website_settings.py +++ b/website/doctype/website_settings/website_settings.py @@ -15,12 +15,39 @@ # along with this program. If not, see . from __future__ import unicode_literals +import webnotes +from webnotes import _, msgprint + class DocType: def __init__(self, d, dl): self.doc, self.doclist = d, dl def validate(self): self.set_home_page() + self.validate_top_bar_items() + self.validate_footer_items() + + def validate_top_bar_items(self): + """validate url in top bar items""" + for top_bar_item in self.doclist.get({"parentfield": "top_bar_items"}): + if top_bar_item.parent_label: + parent_label_item = self.doclist.get({"parentfield": "top_bar_items", + "label": top_bar_item.parent_label}) + + if not parent_label_item: + # invalid item + msgprint(_(self.meta.get_label("parent_label", parentfield="top_bar_items")) + + (" \"%s\": " % top_bar_item.parent_label) + _("does not exist"), raise_exception=True) + + elif not parent_label_item[0] or parent_label_item[0].url: + # parent cannot have url + msgprint(_("Top Bar Item") + (" \"%s\": " % top_bar_item.parent_label) + + _("cannot have a URL, because it has child item(s)"), raise_exception=True) + + def validate_footer_items(self): + """clear parent label in footer""" + for footer_item in self.doclist.get({"parentfield": "footer_items"}): + footer_item.parent_label = None def on_update(self): # make js and css @@ -32,10 +59,7 @@ class DocType: clear_cache() def set_home_page(self): - - import webnotes from webnotes.model.doc import Document - webnotes.conn.sql("""delete from `tabDefault Home Page` where role='Guest'""") d = Document('Default Home Page') diff --git a/website/helpers/product.py b/website/helpers/product.py index a107d9b02b..a8b60fdbec 100644 --- a/website/helpers/product.py +++ b/website/helpers/product.py @@ -91,7 +91,7 @@ def get_group_item_count(item_group): def get_item_for_list_in_html(r): scrub_item_for_list(r) - r.template = "app/website/templates/html/product_in_list.html" + r.template = "app/website/templates/html/product_in_grid.html" return build_html(r) def scrub_item_for_list(r): diff --git a/website/templates/css/product_page.css b/website/templates/css/product_page.css index 71be9ee56b..e2f42937ec 100644 --- a/website/templates/css/product_page.css +++ b/website/templates/css/product_page.css @@ -7,7 +7,7 @@ font-size: 18px; line-height: 200%; } - .item-price { + .item-price-info { margin-top: 20px; } \ No newline at end of file diff --git a/website/templates/html/product_in_grid.html b/website/templates/html/product_in_grid.html new file mode 100644 index 0000000000..e9752b3d4a --- /dev/null +++ b/website/templates/html/product_in_grid.html @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/website/templates/html/product_missing_image.html b/website/templates/html/product_missing_image.html index 3858a131cd..81b893533f 100644 --- a/website/templates/html/product_missing_image.html +++ b/website/templates/html/product_missing_image.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file From a2e2d4bd19953f0a7bd1841b0d65b5e7eee91981 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 12 Jun 2013 17:44:10 +0530 Subject: [PATCH 3/3] [price list] [fix] fix in buying selling price list patch --- patches/june_2013/p03_buying_selling_for_price_list.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/patches/june_2013/p03_buying_selling_for_price_list.py b/patches/june_2013/p03_buying_selling_for_price_list.py index a41bda1ce8..089f0be559 100644 --- a/patches/june_2013/p03_buying_selling_for_price_list.py +++ b/patches/june_2013/p03_buying_selling_for_price_list.py @@ -2,6 +2,9 @@ import webnotes from webnotes.utils import cint def execute(): + webnotes.reload_doc("setup", "doctype", "price_list") + webnotes.reload_doc("stock", "doctype", "item_price") + for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""): buying, selling = False, False for b, s in webnotes.conn.sql("""select distinct buying, selling @@ -9,6 +12,7 @@ def execute(): buying = buying or cint(b) selling = selling or cint(s) - webnotes.conn.set_value("Price List", price_list, "buying_or_selling", ("Selling" if selling else "Buying")) - webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s where price_list_name=%s""", - (("Selling" if selling else "Buying"), price_list)) + buying_or_selling = "Selling" if selling else "Buying" + webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling) + webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s + where price_list_name=%s""", (buying_or_selling, price_list))