From b604eddbfd47eea2404e4e20e25ac9665fba7fd7 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 10 Oct 2013 15:43:32 +0530 Subject: [PATCH] [minor] [fixes] view in website and other fixes --- selling/doctype/sales_order/sales_order.py | 2 +- setup/doctype/item_group/item_group.js | 6 ++++++ setup/page/setup_wizard/setup_wizard.py | 5 ++--- stock/doctype/item/item.js | 16 +++++++++------- stock/doctype/item/item.py | 3 +++ stock/doctype/serial_no/serial_no.py | 4 ++-- utilities/demo/make_erpnext_demo.py | 1 + 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py index d3ac7ad339d..af8ea1ad7a0 100644 --- a/selling/doctype/sales_order/sales_order.py +++ b/selling/doctype/sales_order/sales_order.py @@ -202,7 +202,7 @@ class DocType(SellingController): def check_nextdoc_docstatus(self): # Checks Delivery Note - submit_dn = webnotes.conn.sql("select t1.name from `tabDelivery Note` t1,`tabDelivery Note Item` t2 where t1.name = t2.parent and t2.prevdoc_docname = '%s' and t1.docstatus = 1" % (self.doc.name)) + submit_dn = webnotes.conn.sql("select t1.name from `tabDelivery Note` t1,`tabDelivery Note Item` t2 where t1.name = t2.parent and t2.against_sales_order = %s and t1.docstatus = 1", self.doc.name) if submit_dn: msgprint("Delivery Note : " + cstr(submit_dn[0][0]) + " has been submitted against " + cstr(self.doc.doctype) + ". Please cancel Delivery Note : " + cstr(submit_dn[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1) diff --git a/setup/doctype/item_group/item_group.js b/setup/doctype/item_group/item_group.js index 31edef27dec..0c18db001c8 100644 --- a/setup/doctype/item_group/item_group.js +++ b/setup/doctype/item_group/item_group.js @@ -7,6 +7,12 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.add_custom_button("Item Group Tree", function() { wn.set_route("Sales Browser", "Item Group"); }) + + if(!doc.__islocal && doc.show_in_website) { + cur_frm.add_custom_button("View In Website", function() { + window.open(doc.page_name); + }, "icon-globe"); + } } cur_frm.cscript.set_root_readonly = function(doc) { diff --git a/setup/page/setup_wizard/setup_wizard.py b/setup/page/setup_wizard/setup_wizard.py index 12767639c84..d506d419542 100644 --- a/setup/page/setup_wizard/setup_wizard.py +++ b/setup/page/setup_wizard/setup_wizard.py @@ -17,9 +17,8 @@ def setup_account(args=None): args = webnotes.local.form_dict if isinstance(args, basestring): args = json.loads(args) - - webnotes.conn.begin() - + args = webnotes._dict(args) + update_profile_name(args) create_fiscal_year_and_company(args) set_defaults(args) diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index a83032e8f26..d0b8492ddd9 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -11,14 +11,16 @@ cur_frm.cscript.refresh = function(doc) { && doc.__islocal) cur_frm.toggle_display("item_code", sys_defaults.item_naming_by!="Naming Series" && doc.__islocal) + + if(!doc.__islocal && doc.show_in_website) { + cur_frm.add_custom_button("View In Website", function() { + window.open(doc.page_name); + }, "icon-globe"); + } - - if ((!doc.__islocal) && (doc.is_stock_item == 'Yes')) { - var callback = function(r, rt) { - var enabled = (r.message == 'exists') ? false : true; - cur_frm.toggle_enable(['has_serial_no', 'is_stock_item', 'valuation_method'], enabled); - } - return $c_obj(make_doclist(doc.doctype, doc.name),'check_if_sle_exists','',callback); + if (!doc.__islocal && doc.is_stock_item == 'Yes') { + cur_frm.toggle_enable(['has_serial_no', 'is_stock_item', 'valuation_method'], + doc.__sle_exists=="exists" ? false : true); } } diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index aedb71c2c23..595895f61a7 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -14,6 +14,9 @@ from webnotes.model.controller import DocListController class WarehouseNotSet(Exception): pass class DocType(DocListController): + def onload(self): + self.doc.fields["__sle_exists"] = self.check_if_sle_exists() + def autoname(self): if webnotes.conn.get_default("item_naming_by")=="Naming Series": from webnotes.model.doc import make_autoname diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py index 1feab02cf57..3b9704fcd57 100644 --- a/stock/doctype/serial_no/serial_no.py +++ b/stock/doctype/serial_no/serial_no.py @@ -14,9 +14,9 @@ class SerialNoCannotCreateDirectError(webnotes.ValidationError): pass class SerialNoCannotCannotChangeError(webnotes.ValidationError): pass class DocType(StockController): - def __init__(self, doc, doclist=[]): + def __init__(self, doc, doclist=None): self.doc = doc - self.doclist = doclist + self.doclist = doclist or [] self.via_stock_ledger = False def validate(self): diff --git a/utilities/demo/make_erpnext_demo.py b/utilities/demo/make_erpnext_demo.py index bc25d5e34d3..262a7595c22 100644 --- a/utilities/demo/make_erpnext_demo.py +++ b/utilities/demo/make_erpnext_demo.py @@ -15,6 +15,7 @@ def make_demo_app(site=None): make_demo_login_page() make_demo_on_login_script() utilities.demo.make_demo.make(reset=False, simulate=True) + webnotes.destroy() def make_demo_user(): from webnotes.auth import _update_password