diff --git a/accounts/doctype/account/account.js b/accounts/doctype/account/account.js index db50ff6ac8..c12c2d6964 100644 --- a/accounts/doctype/account/account.js +++ b/accounts/doctype/account/account.js @@ -82,7 +82,7 @@ cur_frm.cscript.account_type = function(doc, cdt, cdn) { // ----------------------------------------- cur_frm.cscript.add_toolbar_buttons = function(doc) { cur_frm.add_custom_button('Chart of Accounts', - function() { wn.set_route("Accounts Browser", "Account"); }, 'icon-list') + function() { wn.set_route("Accounts Browser", "Account"); }, 'icon-sitemap') if (cstr(doc.group_or_ledger) == 'Group') { cur_frm.add_custom_button('Convert to Ledger', @@ -92,7 +92,12 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) { function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet') cur_frm.add_custom_button('View Ledger', function() { - wn.set_route("general-ledger", "account=" + doc.name); + wn.route_options = { + "account": doc.name, + "from_date": sys_defaults.year_start_date, + "to_date": sys_defaults.year_end_date + }; + wn.set_route("general-ledger"); }); } } diff --git a/accounts/doctype/cost_center/cost_center.js b/accounts/doctype/cost_center/cost_center.js index e63fa042ea..2a98a960c7 100644 --- a/accounts/doctype/cost_center/cost_center.js +++ b/accounts/doctype/cost_center/cost_center.js @@ -28,6 +28,9 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger') cur_frm.set_intro(intro_txt); + + cur_frm.add_custom_button('Chart of Cost Centers', + function() { wn.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap') } //Account filtering for cost center diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index 78956bf11e..dbe666881a 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -23,7 +23,14 @@ cur_frm.cscript.refresh = function(doc) { erpnext.hide_naming_series(); cur_frm.cscript.voucher_type(doc); if(doc.docstatus==1) { - cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry); + cur_frm.add_custom_button('View Ledger', function() { + wn.route_options = { + "voucher_no": doc.name, + "from_date": doc.posting_date, + "to_date": doc.posting_date, + }; + wn.set_route("general-ledger"); + }); } } @@ -49,8 +56,6 @@ cur_frm.cscript.is_opening = function(doc, cdt, cdn) { if (doc.is_opening == 'Yes') unhide_field('aging_date'); } -//Set debit and credit to zero on adding new row -//---------------------------------------------- cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){ var d = locals[cdt][cdn]; if(d.idx == 1){ @@ -59,9 +64,6 @@ cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){ } } -// Get Outstanding of Payable & Sales Invoice -// ----------------------------------------------- - cur_frm.cscript.against_voucher = function(doc,cdt,cdn) { var d = locals[cdt][cdn]; if (d.against_voucher && !flt(d.debit)) { @@ -131,18 +133,24 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ cur_frm.pformat.print_heading = "Journal Voucher"; } -cur_frm.cscript.view_ledger_entry = function(doc,cdt,cdn){ - wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name); -} - - cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher"); cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher"); + + if(wn.model.get("Journal Voucher Detail", {"parent":doc.name}).length!==0 // too late + || !doc.company) // too early + return; - if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type) - && doc.company - && wn.model.get("Journal Voucher Detail", {"parent":doc.name}).length==0) { + var update_jv_details = function(doc, r) { + $.each(r.message, function(i, d) { + var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries"); + jvdetail.account = d.account; + jvdetail.balance = d.balance; + }); + refresh_field("entries"); + } + + if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)) { wn.call({ type: "GET", method: "accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account", @@ -152,14 +160,26 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { }, callback: function(r) { if(r.message) { - var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries"); - jvdetail.account = r.message.account; - // this is a data field???? - jvdetail.balance = format_currency(r.message.balance); - refresh_field("entries"); + update_jv_details(doc, r); } } }) + } else if(doc.voucher_type=="Opening Entry") { + wn.call({ + type:"GET", + method: "accounts.doctype.journal_voucher.journal_voucher.get_opening_accounts", + args: { + "company": doc.company + }, + callback: function(r) { + wn.model.clear_table("Journal Voucher Detail", "Journal Voucher", + doc.name, "entries"); + if(r.message) { + update_jv_details(doc, r); + } + cur_frm.set_value("is_opening", "Yes") + } + }) } } diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py index 2c5cd4fd80..77fec8ee8b 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.py +++ b/accounts/doctype/journal_voucher/journal_voucher.py @@ -352,11 +352,20 @@ def get_default_bank_cash_account(company, voucher_type): account = webnotes.conn.get_value("Company", company, voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account") if account: - return { + return [{ "account": account, "balance": get_balance_on(account) - } + }] +@webnotes.whitelist() +def get_opening_accounts(company): + """get all balance sheet accounts for opening entry""" + from accounts.utils import get_balance_on + accounts = webnotes.conn.sql_list("""select name from tabAccount + where group_or_ledger='Ledger' and is_pl_account='No' and company=%s""", company) + + return [{"account": a, "balance": get_balance_on(a)} for a in accounts] + def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters): return webnotes.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date from `tabPurchase Invoice` where credit_to = %s and docstatus = 1 diff --git a/accounts/doctype/journal_voucher/journal_voucher.txt b/accounts/doctype/journal_voucher/journal_voucher.txt index d0163e69b9..603eb99fc0 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.txt +++ b/accounts/doctype/journal_voucher/journal_voucher.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-25 10:53:52", "docstatus": 0, - "modified": "2013-06-11 16:04:20", + "modified": "2013-06-28 14:27:11", "modified_by": "Administrator", "owner": "Administrator" }, @@ -68,7 +68,7 @@ "label": "Voucher Type", "oldfieldname": "voucher_type", "oldfieldtype": "Select", - "options": "\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher", + "options": "\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher\nOpening Entry", "print_hide": 0, "read_only": 0, "search_index": 1 diff --git a/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt b/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt index 68019cb840..9946bfb37f 100644 --- a/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt +++ b/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:39", "docstatus": 0, - "modified": "2013-04-17 14:05:18", + "modified": "2013-07-01 13:53:33", "modified_by": "Administrator", "owner": "Administrator" }, @@ -74,11 +74,12 @@ { "doctype": "DocField", "fieldname": "balance", - "fieldtype": "Data", + "fieldtype": "Currency", "label": "Account Balance", "no_copy": 1, "oldfieldname": "balance", "oldfieldtype": "Data", + "options": "Company:company:default_currency", "read_only": 1 }, { diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index 665fbb7441..cf308e3bbd 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -42,7 +42,14 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext this.frm.add_custom_button('Make Payment Entry', this.make_bank_voucher); if(doc.docstatus==1) { - this.frm.add_custom_button('View Ledger', this.view_ledger_entry); + cur_frm.add_custom_button('View Ledger', function() { + wn.route_options = { + "voucher_no": doc.name, + "from_date": doc.posting_date, + "to_date": doc.posting_date, + }; + wn.set_route("general-ledger"); + }); } this.is_opening(doc); @@ -226,8 +233,4 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ } else cur_frm.pformat.print_heading = "Purchase Invoice"; -} - -cur_frm.cscript.view_ledger_entry = function(){ - wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name); -} +} \ No newline at end of file diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index ab1053494e..ca4ca9241c 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -45,7 +45,15 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte cur_frm.cscript.is_opening(doc, dt, dn); if(doc.docstatus==1) { - cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry); + cur_frm.add_custom_button('View Ledger', function() { + wn.route_options = { + "voucher_no": doc.name, + "from_date": doc.posting_date, + "to_date": doc.posting_date, + }; + wn.set_route("general-ledger"); + }); + cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); if(doc.is_pos==1 && doc.update_stock!=1) @@ -381,11 +389,6 @@ cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) { } -/****************** Get Accounting Entry *****************/ -cur_frm.cscript.view_ledger_entry = function(){ - wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name); -} - cur_frm.cscript.on_submit = function(doc, cdt, cdn) { if(cint(wn.boot.notification_settings.sales_invoice)) { cur_frm.email_doc(wn.boot.notification_settings.sales_invoice_message); diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index f7e476af30..3ca51b8d37 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -3,6 +3,7 @@ wn.module_page["Accounts"] = [ { + top: true, title: wn._("Documents"), icon: "icon-copy", items: [ diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js index 1f8618f20a..769812f506 100644 --- a/accounts/page/general_ledger/general_ledger.js +++ b/accounts/page/general_ledger/general_ledger.js @@ -22,10 +22,7 @@ wn.pages['general-ledger'].onload = function(wrapper) { }); erpnext.general_ledger = new erpnext.GeneralLedger(wrapper); - - wrapper.appframe.add_home_breadcrumb() wrapper.appframe.add_module_icon("Accounts") - wrapper.appframe.add_breadcrumb("icon-bar-chart") } @@ -110,7 +107,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ // filter accounts options by company this.filter_inputs.company.change(function() { me.setup_account_filter(this); - me.set_route() + me.refresh() }); this.filter_inputs.account.change(function() { @@ -220,13 +217,15 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ } } - if(date < from_date || item.is_opening=="Yes") { + if(!me.voucher_no && (date < from_date || item.is_opening=="Yes")) { opening.debit += item.debit; opening.credit += item.credit; grouped_ledgers[item.account].opening.debit += item.debit; grouped_ledgers[item.account].opening.credit += item.credit; + } else if(date <= to_date) { + totals.debit += item.debit; totals.credit += item.credit; @@ -242,7 +241,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ + item.voucher_no][(item.debit > 0 ? "credits" : "debits")].join(", "); } - if(me.apply_filters(item) && item.is_opening=="No") { + if(me.apply_filters(item) && (me.voucher_no || item.is_opening=="No")) { out.push(item); grouped_ledgers[item.account].entries.push(item); diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.js b/accounts/page/voucher_import_tool/voucher_import_tool.js index bf6b065b0f..48216b83ee 100644 --- a/accounts/page/voucher_import_tool/voucher_import_tool.js +++ b/accounts/page/voucher_import_tool/voucher_import_tool.js @@ -9,11 +9,11 @@ wn.pages['voucher-import-tool'].onload = function(wrapper) {

Import multiple accounting entries via CSV (spreadsheet) file:

\

1. Download Template


\
\ - \ + \

Import multiple vouchers with one debit and one credit entry

\
\
\ - \ + \

Import multiple vouchers with multiple accounts

\
\
\ diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js index 0151a60c87..1db8d41d7b 100644 --- a/buying/page/buying_home/buying_home.js +++ b/buying/page/buying_home/buying_home.js @@ -4,6 +4,7 @@ wn.module_page["Buying"] = [ { title: wn._("Documents"), + top: true, icon: "icon-copy", items: [ { diff --git a/buying/utils.py b/buying/utils.py index 3c8f69366b..23d55938a2 100644 --- a/buying/utils.py +++ b/buying/utils.py @@ -51,6 +51,9 @@ def get_item_details(args): out.supplier_part_no = _get_supplier_part_no(args, item_bean) + if not out.warehouse: + out.warehouse = item_bean.doc.default_warehouse + if out.warehouse: out.projected_qty = get_projected_qty(item.name, out.warehouse) diff --git a/hr/page/hr_home/hr_home.js b/hr/page/hr_home/hr_home.js index bee05f6a11..517fb772c4 100644 --- a/hr/page/hr_home/hr_home.js +++ b/hr/page/hr_home/hr_home.js @@ -3,9 +3,15 @@ wn.module_page["HR"] = [ { - title: wn._("Documents"), + title: wn._("Top"), + top: true, icon: "icon-copy", items: [ + { + label: wn._("Employee"), + description: wn._("Employee records."), + doctype:"Employee" + }, { label: wn._("Leave Application"), description: wn._("Applications for leave."), @@ -16,6 +22,17 @@ wn.module_page["HR"] = [ description: wn._("Claims for company expense."), doctype:"Expense Claim" }, + { + label: wn._("Job Applicant"), + description: wn._("Applicant for a Job."), + doctype:"Job Applicant" + }, + ] + }, + { + title: wn._("Documents"), + icon: "icon-copy", + items: [ { label: wn._("Attendance"), description: wn._("Attendance record."), @@ -31,22 +48,6 @@ wn.module_page["HR"] = [ description: wn._("Performance appraisal."), doctype:"Appraisal" }, - { - label: wn._("Job Applicant"), - description: wn._("Applicant for a Job."), - doctype:"Job Applicant" - }, - ] - }, - { - title: wn._("Masters"), - icon: "icon-book", - items: [ - { - label: wn._("Employee"), - description: wn._("Employee records."), - doctype:"Employee" - }, ] }, { diff --git a/manufacturing/page/manufacturing_home/manufacturing_home.js b/manufacturing/page/manufacturing_home/manufacturing_home.js index d4841df2fb..7085f9afdf 100644 --- a/manufacturing/page/manufacturing_home/manufacturing_home.js +++ b/manufacturing/page/manufacturing_home/manufacturing_home.js @@ -4,8 +4,14 @@ wn.module_page["Manufacturing"] = [ { title: wn._("Documents"), + top: true, icon: "icon-copy", items: [ + { + label: wn._("Bill of Materials"), + description: wn._("Bill of Materials (BOM)"), + doctype:"BOM" + }, { label: wn._("Production Order"), description: wn._("Orders released for production."), @@ -29,11 +35,6 @@ wn.module_page["Manufacturing"] = [ title: wn._("Masters"), icon: "icon-book", items: [ - { - label: wn._("Bill of Materials"), - description: wn._("Bill of Materials (BOM)"), - doctype:"BOM" - }, { label: wn._("Item"), description: wn._("All Products or Services."), diff --git a/master.sql.gz b/master.sql.gz deleted file mode 100644 index 030ee05b2f..0000000000 Binary files a/master.sql.gz and /dev/null differ diff --git a/projects/page/projects_home/projects_home.js b/projects/page/projects_home/projects_home.js index fd13a67367..ea078e8fa8 100644 --- a/projects/page/projects_home/projects_home.js +++ b/projects/page/projects_home/projects_home.js @@ -3,8 +3,9 @@ wn.module_page["Projects"] = [ { - title: wn._("Documents"), + title: wn._("Top"), icon: "icon-copy", + top: true, items: [ { label: wn._("Task"), @@ -21,6 +22,12 @@ wn.module_page["Projects"] = [ description: wn._("Time Log for tasks."), doctype:"Time Log" }, + ] + }, + { + title: wn._("Documents"), + icon: "icon-copy", + items: [ { label: wn._("Time Log Batch"), description: wn._("Batch Time Logs for billing."), diff --git a/public/js/controllers/stock_controller.js b/public/js/controllers/stock_controller.js index 15d34e0e33..3021d756b9 100644 --- a/public/js/controllers/stock_controller.js +++ b/public/js/controllers/stock_controller.js @@ -20,13 +20,12 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({ show_stock_ledger: function() { var me = this; this.frm.add_custom_button("Show Stock Ledger", function() { - var args = { - voucher_no: cur_frm.doc.name, - from_date: wn.datetime.str_to_user(cur_frm.doc.posting_date), - to_date: wn.datetime.str_to_user(cur_frm.doc.posting_date) - }; - wn.set_route('stock-ledger', - $.map(args, function(val, key) { return key+"="+val; }).join("&&")); + wn.route_options = { + voucher_no: me.frm.doc.name, + from_date: cur_frm.doc.posting_date, + to_date: cur_frm.doc.posting_date + }; + wn.set_route('stock-ledger'); }, "icon-bar-chart"); } }); \ No newline at end of file diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 388fa42f84..8eae737ddb 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -3,6 +3,7 @@ wn.module_page["Selling"] = [ { + top: true, title: wn._("Documents"), icon: "icon-copy", items: [ diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index 54a293f6ea..446d602082 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -201,8 +201,8 @@ class DocType: for a in accounts: account_name = accounts[a] + " - " + self.doc.abbr - if not self.doc.fields[a] and webnotes.conn.exists("Account", account_name): - webnotes.conn.set(self.doc, account_name) + if not self.doc.fields.get(a) and webnotes.conn.exists("Account", account_name): + webnotes.conn.set(self.doc, a, account_name) if not self.doc.stock_adjustment_cost_center: webnotes.conn.set(self.doc, "stock_adjustment_cost_center", self.doc.cost_center) diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index 8b44f7e294..a4af7f891a 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -61,13 +61,20 @@ class DocType: WHERE name=%(name)s AND docstatus<2""", args) def create_fiscal_year_and_company(self, args): - curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start')) - # Fiscal Year + curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start'), True) webnotes.bean([{ "doctype":"Fiscal Year", 'year': curr_fiscal_year, 'year_start_date': fy_start_date, }]).insert() + + curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start')) + webnotes.bean([{ + "doctype":"Fiscal Year", + 'year': curr_fiscal_year, + 'year_start_date': fy_start_date, + }]).insert() + # Company webnotes.bean([{ @@ -198,13 +205,15 @@ class DocType: # Get Fiscal year Details # ------------------------ - def get_fy_details(self, fy_start): + def get_fy_details(self, fy_start, last_year=False): st = {'1st Jan':'01-01','1st Apr':'04-01','1st Jul':'07-01', '1st Oct': '10-01'} curr_year = getdate(nowdate()).year + if last_year: + curr_year = curr_year - 1 if cint(getdate(nowdate()).month) < cint((st[fy_start].split('-'))[0]): curr_year = getdate(nowdate()).year - 1 stdt = cstr(curr_year)+'-'+cstr(st[fy_start]) - #eddt = sql("select DATE_FORMAT(DATE_SUB(DATE_ADD('%s', INTERVAL 1 YEAR), INTERVAL 1 DAY),'%%d-%%m-%%Y')" % (stdt.split('-')[2]+ '-' + stdt.split('-')[1] + '-' + stdt.split('-')[0])) + if(fy_start == '1st Jan'): fy = cstr(getdate(nowdate()).year) abbr = cstr(fy)[-2:] diff --git a/setup/page/setup/setup.py b/setup/page/setup/setup.py index 10fc2a4913..348fce968c 100644 --- a/setup/page/setup/setup.py +++ b/setup/page/setup/setup.py @@ -91,6 +91,19 @@ items = [ }, { "doctype": "Sales Taxes and Charges Master" }, { "doctype": "Purchase Taxes and Charges Master" }, + { + "type": "Section", + "title": "Opening Accounts and Stock", + "icon": "icon-eye-open" + }, + { "doctype": "Stock Reconciliation" }, + { + "doctype": "Journal Voucher", + "title": "Opening Accounting Entries", + "filter": { + "is_opening": "Yes" + } + }, { "type": "Section", "title": "Human Resource", @@ -148,19 +161,6 @@ items = [ { "doctype": "Email Digest", }, - { - "type": "Section", - "title": "Opening Accounts and Stock", - "icon": "icon-eye-open" - }, - { "doctype": "Stock Reconciliation" }, - { - "doctype": "Journal Voucher", - "title": "Opening Accounting Entries", - "filter": { - "is_opening": "Yes" - } - }, { "type": "Section", "title": "Customization", @@ -244,8 +244,8 @@ def set_count(item): elif "filter" in item: key = item["filter"].keys()[0] item["count"] = webnotes.conn.sql("""select count(*) from `tab%s` where - %s = %s""" % (item["doctype"], key, "%s"), + %s = %s and docstatus < 2""" % (item["doctype"], key, "%s"), item["filter"][key])[0][0] elif "doctype" in item: - item["count"] = webnotes.conn.sql("select count(*) from `tab%s`" \ + item["count"] = webnotes.conn.sql("select count(*) from `tab%s` where docstatus<2" \ % item["doctype"])[0][0] diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index d6c1f52d94..cd1f37c9ec 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -25,6 +25,7 @@ from webnotes import msgprint, _ from webnotes.model.controller import DocListController class PriceListCurrencyMismatch(Exception): pass +class WarehouseNotSet(Exception): pass class DocType(DocListController): def autoname(self): @@ -39,7 +40,8 @@ class DocType(DocListController): def validate(self): if not self.doc.stock_uom: msgprint(_("Please enter Default Unit of Measure"), raise_exception=1) - + + self.check_warehouse_is_set_for_stock_item() self.check_stock_uom_with_bin() self.validate_conversion_factor() self.add_default_uom_in_conversion_factor_table() @@ -60,6 +62,11 @@ class DocType(DocListController): self.validate_name_with_item_group() self.update_website() + def check_warehouse_is_set_for_stock_item(self): + if self.doc.is_stock_item=="Yes" and not self.doc.default_warehouse: + webnotes.msgprint(_("Default Warehouse is mandatory for Stock Item."), + raise_exception=WarehouseNotSet) + def add_default_uom_in_conversion_factor_table(self): uom_conv_list = [d.uom for d in self.doclist.get({"parentfield": "uom_conversion_details"})] if self.doc.stock_uom not in uom_conv_list: diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt index 1273b12420..d5fcb9ef28 100644 --- a/stock/doctype/item/item.txt +++ b/stock/doctype/item/item.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-03 10:45:46", "docstatus": 0, - "modified": "2013-06-26 21:39:46", + "modified": "2013-07-01 11:45:59", "modified_by": "Administrator", "owner": "Administrator" }, @@ -205,11 +205,11 @@ }, { "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "description": "Mandatory if Stock Item is \"Yes\"", + "description": "Mandatory if Stock Item is \"Yes\". Also the default warehouse where reserved quantity is set from Sales Order.", "doctype": "DocField", "fieldname": "default_warehouse", "fieldtype": "Link", - "label": "Default Reserved Warehouse", + "label": "Default Warehouse", "oldfieldname": "default_warehouse", "oldfieldtype": "Link", "options": "Warehouse", diff --git a/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py index 2145631024..35cad9d211 100644 --- a/stock/doctype/item/test_item.py +++ b/stock/doctype/item/test_item.py @@ -35,6 +35,13 @@ class TestItem(unittest.TestCase): item_price = item.doclist.get({"doctype": "Item Price"})[0].ref_currency="USD" self.assertRaises(PriceListCurrencyMismatch, item.insert) + def test_default_warehouse(self): + from stock.doctype.item.item import WarehouseNotSet + item = webnotes.bean(copy=test_records[0]) + item.doc.is_stock_item = "Yes" + item.doc.default_warehouse = None + self.assertRaises(WarehouseNotSet, item.insert) + test_records = [ [{ @@ -77,6 +84,7 @@ test_records = [ "item_name": "_Test Item Home Desktop 100", "description": "_Test Item Home Desktop 100", "item_group": "_Test Item Group Desktops", + "default_warehouse": "_Test Warehouse", "is_stock_item": "Yes", "is_asset_item": "No", "has_batch_no": "No", @@ -101,6 +109,7 @@ test_records = [ "item_name": "_Test Item Home Desktop 200", "description": "_Test Item Home Desktop 200", "item_group": "_Test Item Group Desktops", + "default_warehouse": "_Test Warehouse", "is_stock_item": "Yes", "is_asset_item": "No", "has_batch_no": "No", @@ -140,6 +149,7 @@ test_records = [ "description": "_Test FG Item", "item_group": "_Test Item Group Desktops", "is_stock_item": "Yes", + "default_warehouse": "_Test Warehouse", "is_asset_item": "No", "has_batch_no": "No", "has_serial_no": "No", @@ -178,6 +188,7 @@ test_records = [ "description": "_Test Serialized Item", "item_group": "_Test Item Group Desktops", "is_stock_item": "Yes", + "default_warehouse": "_Test Warehouse", "is_asset_item": "No", "has_batch_no": "No", "has_serial_no": "Yes", diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 3492931451..b2a10853ac 100644 --- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -121,8 +121,6 @@ class DocType(DocListController): self.doc.posting_time = '00:00' def on_doctype_update(self): - webnotes.msgprint(webnotes.conn.sql("""show index from `tabStock Ledger Entry` - where Key_name="posting_sort_index" """)) if not webnotes.conn.sql("""show index from `tabStock Ledger Entry` where Key_name="posting_sort_index" """): webnotes.conn.commit() diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.js b/stock/doctype/stock_reconciliation/stock_reconciliation.js index cf6821ebd5..dd496833b5 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -48,8 +48,6 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ return { "query": "accounts.utils.get_account_list", "filters": { - "is_pl_account": "Yes", - "debit_or_credit": "Debit", "company": me.frm.doc.company } } diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index c92c6fe5f9..b17784fde4 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -4,6 +4,7 @@ wn.module_page["Stock"] = [ { title: wn._("Documents"), + top: true, icon: "icon-copy", items: [ { diff --git a/stock/page/stock_ledger/stock_ledger.js b/stock/page/stock_ledger/stock_ledger.js index 438f132244..3ca27c5890 100644 --- a/stock/page/stock_ledger/stock_ledger.js +++ b/stock/page/stock_ledger/stock_ledger.js @@ -22,10 +22,7 @@ wn.pages['stock-ledger'].onload = function(wrapper) { }); new erpnext.StockLedger(wrapper); - - wrapper.appframe.add_home_breadcrumb() wrapper.appframe.add_module_icon("Stock") - wrapper.appframe.add_breadcrumb("icon-bar-chart") } wn.require("app/js/stock_grid_report.js"); diff --git a/support/page/support_home/support_home.js b/support/page/support_home/support_home.js index 65ea4b8fca..ea8474cf88 100644 --- a/support/page/support_home/support_home.js +++ b/support/page/support_home/support_home.js @@ -3,7 +3,8 @@ wn.module_page["Support"] = [ { - title: wn._("Documents"), + title: wn._("Top"), + top: true, icon: "icon-copy", items: [ { @@ -16,6 +17,13 @@ wn.module_page["Support"] = [ description: wn._("Customer Issue against Serial No."), doctype:"Customer Issue" }, + ] + }, + + { + title: wn._("Documents"), + icon: "icon-copy", + items: [ { label: wn._("Maintenance Schedule"), description: wn._("Plan for maintenance visits."), diff --git a/utilities/doctype/address/address.py b/utilities/doctype/address/address.py index c475da12b5..40207663e9 100644 --- a/utilities/doctype/address/address.py +++ b/utilities/doctype/address/address.py @@ -27,13 +27,13 @@ class DocType: def autoname(self): if not self.doc.address_title: - self.doc.address_title = self.doc.customer or self.doc.supplier or self.doc.sales_partner or self.doc.lead - + self.doc.address_title = self.doc.customer \ + or self.doc.supplier or self.doc.sales_partner or self.doc.lead + if self.doc.address_title: self.doc.name = cstr(self.doc.address_title).strip() + "-" + cstr(self.doc.address_type).strip() - else: - webnotes.msgprint("""Address Title is mandatory.""", raise_exception=True) + webnotes.msgprint("""Address Title is mandatory.""" + self.doc.customer, raise_exception=True) def validate(self): self.validate_primary_address() diff --git a/utilities/doctype/address/address.txt b/utilities/doctype/address/address.txt index ed39c759c5..827331d6bc 100644 --- a/utilities/doctype/address/address.txt +++ b/utilities/doctype/address/address.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:32", "docstatus": 0, - "modified": "2013-06-28 17:06:32", + "modified": "2013-07-01 15:56:39", "modified_by": "Administrator", "owner": "Administrator" }, @@ -59,7 +59,7 @@ "fieldname": "address_title", "fieldtype": "Data", "label": "Address Title", - "reqd": 1 + "reqd": 0 }, { "doctype": "DocField", diff --git a/website/page/website_home/website_home.js b/website/page/website_home/website_home.js index fb612df11d..bdedcc9051 100644 --- a/website/page/website_home/website_home.js +++ b/website/page/website_home/website_home.js @@ -5,6 +5,7 @@ wn.module_page["Website"] = [ { title: wn._("Web Content"), icon: "icon-copy", + top: true, items: [ { label: wn._("Web Page"), @@ -12,20 +13,20 @@ wn.module_page["Website"] = [ doctype:"Web Page" }, { - label: wn._("Website Slideshow"), - description: wn._("Embed image slideshows in website pages."), - doctype:"Website Slideshow" + label: wn._("Blog Post"), + description: wn._("Single Post (article)."), + doctype:"Blog Post" }, ] }, { - title: wn._("Blog"), + title: wn._("Documents"), icon: "icon-edit", items: [ { - label: wn._("Blog Post"), - description: wn._("Single Post (article)."), - doctype:"Blog Post" + label: wn._("Website Slideshow"), + description: wn._("Embed image slideshows in website pages."), + doctype:"Website Slideshow" }, { label: wn._("Blogger"),