diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py
index b590ba7fc0..08bf80fdce 100644
--- a/accounts/doctype/account/account.py
+++ b/accounts/doctype/account/account.py
@@ -208,31 +208,3 @@ def get_parent_account(doctype, txt, searchfield, start, page_len, filters):
and %s like %s order by name limit %s, %s""" %
("%s", searchfield, "%s", "%s", "%s"),
(filters["company"], "%%%s%%" % txt, start, page_len), as_list=1)
-
-def make_test_records(verbose):
- from webnotes.test_runner import load_module_and_make_records, make_test_objects
-
- load_module_and_make_records("Company", verbose)
-
- accounts = [
- # [account_name, parent_account, group_or_ledger]
- ["_Test Account Stock Expenses", "Direct Expenses - _TC", "Group"],
- ["_Test Account Shipping Charges", "_Test Account Stock Expenses - _TC", "Ledger"],
- ["_Test Account Customs Duty", "_Test Account Stock Expenses - _TC", "Ledger"],
- ["_Test Account Tax Assets", "Current Assets - _TC", "Group"],
- ["_Test Account VAT", "_Test Account Tax Assets - _TC", "Ledger"],
- ["_Test Account Cost for Goods Sold", "Expenses - _TC", "Ledger"],
- ["_Test Account Excise Duty", "_Test Account Tax Assets - _TC", "Ledger"],
- ["_Test Account Education Cess", "_Test Account Tax Assets - _TC", "Ledger"],
- ["_Test Account S&H Education Cess", "_Test Account Tax Assets - _TC", "Ledger"],
- ["_Test Account CST", "Direct Expenses - _TC", "Ledger"],
- ["_Test Account Discount", "Direct Expenses - _TC", "Ledger"]
- ]
-
- return make_test_objects([[{
- "doctype": "Account",
- "account_name": account_name,
- "parent_account": parent_account,
- "company": "_Test Company",
- "group_or_ledger": group_or_ledger
- }] for account_name, parent_account, group_or_ledger in accounts])
\ No newline at end of file
diff --git a/accounts/doctype/account/test_account.py b/accounts/doctype/account/test_account.py
new file mode 100644
index 0000000000..ec72dbcf23
--- /dev/null
+++ b/accounts/doctype/account/test_account.py
@@ -0,0 +1,25 @@
+def make_test_records(verbose):
+ from webnotes.test_runner import make_test_objects
+
+ accounts = [
+ # [account_name, parent_account, group_or_ledger]
+ ["_Test Account Stock Expenses", "Direct Expenses - _TC", "Group"],
+ ["_Test Account Shipping Charges", "_Test Account Stock Expenses - _TC", "Ledger"],
+ ["_Test Account Customs Duty", "_Test Account Stock Expenses - _TC", "Ledger"],
+ ["_Test Account Tax Assets", "Current Assets - _TC", "Group"],
+ ["_Test Account VAT", "_Test Account Tax Assets - _TC", "Ledger"],
+ ["_Test Account Cost for Goods Sold", "Expenses - _TC", "Ledger"],
+ ["_Test Account Excise Duty", "_Test Account Tax Assets - _TC", "Ledger"],
+ ["_Test Account Education Cess", "_Test Account Tax Assets - _TC", "Ledger"],
+ ["_Test Account S&H Education Cess", "_Test Account Tax Assets - _TC", "Ledger"],
+ ["_Test Account CST", "Direct Expenses - _TC", "Ledger"],
+ ["_Test Account Discount", "Direct Expenses - _TC", "Ledger"]
+ ]
+
+ return make_test_objects("Account", [[{
+ "doctype": "Account",
+ "account_name": account_name,
+ "parent_account": parent_account,
+ "company": "_Test Company",
+ "group_or_ledger": group_or_ledger
+ }] for account_name, parent_account, group_or_ledger in accounts])
\ No newline at end of file
diff --git a/accounts/doctype/budget_distribution/test_budget_distribution.py b/accounts/doctype/budget_distribution/test_budget_distribution.py
new file mode 100644
index 0000000000..3afb472bae
--- /dev/null
+++ b/accounts/doctype/budget_distribution/test_budget_distribution.py
@@ -0,0 +1 @@
+test_records = []
\ No newline at end of file
diff --git a/accounts/doctype/cost_center/cost_center.py b/accounts/doctype/cost_center/cost_center.py
index 65d1f68520..d23b08681c 100644
--- a/accounts/doctype/cost_center/cost_center.py
+++ b/accounts/doctype/cost_center/cost_center.py
@@ -98,13 +98,3 @@ class DocType(DocTypeNestedSet):
(cost_center_name, old))
return " - ".join(parts)
-
-test_records = [
- [{
- "doctype": "Cost Center",
- "cost_center_name": "_Test Cost Center",
- "parent_cost_center": "Root - _TC",
- "company_name": "_Test Company",
- "group_or_ledger": "Ledger"
- }],
-]
\ No newline at end of file
diff --git a/accounts/doctype/cost_center/test_cost_center.py b/accounts/doctype/cost_center/test_cost_center.py
new file mode 100644
index 0000000000..1692d13d33
--- /dev/null
+++ b/accounts/doctype/cost_center/test_cost_center.py
@@ -0,0 +1,9 @@
+test_records = [
+ [{
+ "doctype": "Cost Center",
+ "cost_center_name": "_Test Cost Center",
+ "parent_cost_center": "Root - _TC",
+ "company_name": "_Test Company",
+ "group_or_ledger": "Ledger"
+ }],
+]
\ No newline at end of file
diff --git a/accounts/doctype/fiscal_year/fiscal_year.py b/accounts/doctype/fiscal_year/fiscal_year.py
index 95c1aa42e6..e23351c3ac 100644
--- a/accounts/doctype/fiscal_year/fiscal_year.py
+++ b/accounts/doctype/fiscal_year/fiscal_year.py
@@ -30,17 +30,4 @@ class DocType:
webnotes.clear_cache()
msgprint(self.doc.name + _(""" is now the default Fiscal Year. \
- Please refresh your browser for the change to take effect."""))
-
-test_records = [
- [{
- "doctype": "Fiscal Year",
- "year": "_Test Fiscal Year 2013",
- "year_start_date": "2013-01-01"
- }],
- [{
- "doctype": "Fiscal Year",
- "year": "_Test Fiscal Year 2014",
- "year_start_date": "2014-01-01"
- }]
-]
\ No newline at end of file
+ Please refresh your browser for the change to take effect."""))
\ No newline at end of file
diff --git a/accounts/doctype/fiscal_year/test_fiscal_year.py b/accounts/doctype/fiscal_year/test_fiscal_year.py
new file mode 100644
index 0000000000..e031a194fe
--- /dev/null
+++ b/accounts/doctype/fiscal_year/test_fiscal_year.py
@@ -0,0 +1,14 @@
+from __future__ import unicode_literals
+
+test_records = [
+ [{
+ "doctype": "Fiscal Year",
+ "year": "_Test Fiscal Year 2013",
+ "year_start_date": "2013-01-01"
+ }],
+ [{
+ "doctype": "Fiscal Year",
+ "year": "_Test Fiscal Year 2014",
+ "year_start_date": "2014-01-01"
+ }]
+]
\ No newline at end of file
diff --git a/accounts/doctype/payment_to_invoice_matching_tool/test_ir.py b/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py
similarity index 100%
rename from accounts/doctype/payment_to_invoice_matching_tool/test_ir.py
rename to accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py
diff --git a/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 0619475bd1..825c7d03c1 100644
--- a/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -21,23 +21,9 @@ import webnotes
import webnotes.model
import json
+test_dependencies = ["Item", "Cost Center"]
+
class TestPurchaseInvoice(unittest.TestCase):
- def setUp(self):
- webnotes.conn.begin()
- self.load_test_data()
- # webnotes.conn.set_value("Global Defaults", None,
- # "automatic_inventory_accounting", 1)
-
- def tearDown(self):
- webnotes.conn.rollback()
-
- def load_test_data(self):
- from webnotes.test_runner import make_test_records
- webnotes.test_objects = {}
- make_test_records("Cost Center", verbose=0)
- make_test_records("Item", verbose=0)
- make_test_records("Purchase Invoice", verbose=0)
-
def test_gl_entries(self):
wrapper = webnotes.model_wrapper(self.get_test_doclist())
diff --git a/accounts/doctype/sales_invoice/test_sales_invoice.py b/accounts/doctype/sales_invoice/test_sales_invoice.py
deleted file mode 100644
index 06ca887aa1..0000000000
--- a/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ /dev/null
@@ -1,233 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-
-from __future__ import unicode_literals
-import unittest
-import webnotes
-import webnotes.model
-from webnotes.model.doclist import DocList
-from webnotes.utils import nowdate
-
-from stock.doctype.purchase_receipt import test_purchase_receipt
-
-company = webnotes.conn.get_default("company")
-abbr = webnotes.conn.get_value("Company", company, "abbr")
-
-def load_data():
- test_purchase_receipt.load_data()
-
- # create customer group
- webnotes.insert({"doctype": "Customer Group",
- "customer_group_name": "_Test Customer Group",
- "parent_customer_group": "All Customer Groups", "is_group": "No"})
-
- # create customer
- webnotes.insert({"doctype": "Customer", "customer_name": "West Wind Inc.",
- "customer_type": "Company", "territory": "Default",
- "customer_group": "_Test Customer Group", "company": company,
- "credit_days": 50, "credit_limit": 0})
-
- webnotes.insert({"doctype": "Account", "account_name": "_Test Account Sales",
- "parent_account": "Income - %s" % abbr, "company": company,
- "group_or_ledger": "Ledger"})
-
- webnotes.insert({"doctype": "Account", "account_name": "Excise Duty",
- "parent_account": "Tax Assets - %s" % abbr, "company": company,
- "group_or_ledger": "Ledger"})
-
- webnotes.insert({"doctype": "Account", "account_name": "Education Cess",
- "parent_account": "Tax Assets - %s" % abbr, "company": company,
- "group_or_ledger": "Ledger"})
-
- webnotes.insert({"doctype": "Account", "account_name": "S&H Education Cess",
- "parent_account": "Tax Assets - %s" % abbr, "company": company,
- "group_or_ledger": "Ledger"})
-
- webnotes.insert({"doctype": "Account", "account_name": "CST",
- "parent_account": "Direct Expenses - %s" % abbr, "company": company,
- "group_or_ledger": "Ledger"})
-
- webnotes.insert({"doctype": "Account", "account_name": "adj_rate",
- "parent_account": "Direct Expenses - %s" % abbr, "company": company,
- "group_or_ledger": "Ledger"})
-
- from webnotes.model.doc import Document
- item = Document("Item", "Home Desktop 100")
-
- # excise duty
- item_tax = item.addchild("item_tax", "Item Tax")
- item_tax.tax_type = "Excise Duty - %s" % abbr
- item_tax.tax_rate = 10
- item_tax.save()
-
-import json
-sales_invoice_doclist = [
- # parent
- {
- "doctype": "Sales Invoice",
- "debit_to": "West Wind Inc. - %s" % abbr,
- "customer_name": "West Wind Inc.",
- "naming_series": "INV", "posting_date": nowdate(),
- "company": company, "fiscal_year": webnotes.conn.get_default("fiscal_year"),
- "currency": webnotes.conn.get_default("currency"), "conversion_rate": 1.0,
- "price_list_currency": webnotes.conn.get_default("currency"),
- "plc_conversion_rate": 1.0, "net_total": 1250, "grand_total": 1627.05,
- "grand_total_export": 1627.05
- },
- # items
- {
- "doctype": "Sales Invoice Item", "warehouse": "Default Warehouse",
- "item_code": "Home Desktop 100", "qty": 10, "basic_rate": 50, "amount": 500,
- "parentfield": "entries", "so_detail": None, "dn_detail": None,
- "stock_uom": "Nos", "item_tax_rate": json.dumps({"Excise Duty - %s" % abbr: 10}),
- "income_account": "_Test Account Sales - %s" % abbr,
- "cost_center": "Default Cost Center - %s" % abbr
- },
- {
- "doctype": "Sales Invoice Item", "warehouse": "Default Warehouse",
- "item_code": "Home Desktop 200", "qty": 5, "basic_rate": 150, "amount": 750,
- "so_detail": None, "dn_detail": None,
- "parentfield": "entries", "stock_uom": "Nos", "income_account": "_Test Account Sales - %s" % abbr,
- "cost_center": "Default Cost Center - %s" % abbr
- },
- # taxes
- {
- "doctype": "Sales Taxes and Charges", "charge_type": "Actual",
- "account_head": "Shipping Charges - %s" % abbr, "rate": 100, "tax_amount": 100,
- "parentfield": "other_charges",
- "cost_center_other_charges": "Default Cost Center - %s" % abbr
- },
- {
- "doctype": "Sales Taxes and Charges", "charge_type": "On Net Total",
- "account_head": "Customs Duty - %s" % abbr, "rate": 10, "tax_amount": 125,
- "parentfield": "other_charges",
- "cost_center_other_charges": "Default Cost Center - %s" % abbr
- },
- {
- "doctype": "Sales Taxes and Charges", "charge_type": "On Net Total",
- "account_head": "Excise Duty - %s" % abbr, "rate": 12, "tax_amount": 140,
- "parentfield": "other_charges"
- },
- {
- "doctype": "Sales Taxes and Charges", "charge_type": "On Previous Row Amount",
- "account_head": "Education Cess - %s" % abbr, "rate": 2, "row_id": 3, "tax_amount": 2.8,
- "parentfield": "other_charges"
- },
- {
- "doctype": "Sales Taxes and Charges", "charge_type": "On Previous Row Amount",
- "account_head": "S&H Education Cess - %s" % abbr, "rate": 1, "row_id": 3,
- "tax_amount": 1.4, "parentfield": "other_charges"
- },
- {
- "doctype": "Sales Taxes and Charges", "charge_type": "On Previous Row Total",
- "account_head": "CST - %s" % abbr, "rate": 2, "row_id": 5, "tax_amount": 32.38,
- "parentfield": "other_charges",
- "cost_center_other_charges": "Default Cost Center - %s" % abbr
- },
- {
- "doctype": "Sales Taxes and Charges", "charge_type": "On Net Total",
- "account_head": "VAT - Test - %s" % abbr, "rate": 12.5, "tax_amount": 156.25,
- "parentfield": "other_charges"
- },
- {
- "doctype": "Sales Taxes and Charges", "charge_type": "On Previous Row Total",
- "account_head": "adj_rate - %s" % abbr, "rate": -10, "row_id": 7, "tax_amount": -180.78,
- "parentfield": "other_charges",
- "cost_center_other_charges": "Default Cost Center - %s" % abbr
- },
-]
-
-class TestSalesInvoice(unittest.TestCase):
- def setUp(self):
- webnotes.conn.begin()
- load_data()
- #webnotes.conn.set_value("Global Defaults", None, "automatic_inventory_accounting", 1)
-
- def test_sales_invoice(self):
- doclist = [] + [d.copy() for d in sales_invoice_doclist]
- controller = webnotes.insert(DocList(doclist))
- controller.submit()
- controller.load_from_db()
- dl = controller.doclist
-
- # test net total
- self.assertEqual(dl[0].net_total, 1250)
-
- # test item values calculation
- expected_values = [
- {
- "item_code": "Home Desktop 100",
- # "ref_rate": 50,
- # "adj_rate": 0,
- # "export_amount": 500,
- # "base_ref_rate": 50,
- "basic_rate": 50,
- "amount": 500
- },
- {
- "item_code": "Home Desktop 200",
- # "ref_rate": 150,
- # "adj_rate": 0,
- # "export_amount": 750,
- # "base_ref_rate": 150,
- "basic_rate": 150,
- "amount": 750
- },
- ]
- for i, item in enumerate(dl.get({"parentfield": "entries"})):
- for key, val in expected_values[i].items():
- self.assertEqual(item.fields.get(key), val)
-
- # test tax amounts and totals
- expected_values = [
- ["Shipping Charges - %s" % abbr, 100, 1350],
- ["Customs Duty - %s" % abbr, 125, 1475],
- ["Excise Duty - %s" % abbr, 140, 1615],
- ["Education Cess - %s" % abbr, 2.8, 1617.8],
- ["S&H Education Cess - %s" % abbr, 1.4, 1619.2],
- ["CST - %s" % abbr, 32.38, 1651.58],
- ["VAT - Test - %s" % abbr, 156.25, 1807.83],
- ["adj_rate - %s" % abbr, -180.78, 1627.05],
- ]
- for i, tax in enumerate(dl.get({"parentfield": "other_charges"})):
- # print tax.account_head, tax.tax_amount, tax.total
- self.assertEqual(tax.account_head, expected_values[i][0])
- self.assertEqual(tax.tax_amount, expected_values[i][1])
- # self.assertEqual(tax.total, expected_values[i][2])
-
- expected_gl_entries = {
- "West Wind Inc. - %s" % abbr : [1627.05, 0.0],
- "_Test Account Sales - %s" % abbr: [0.0, 1250.00],
- "Shipping Charges - %s" % abbr: [0.0, 100],
- "Customs Duty - %s" % abbr: [0, 125.0],
- "Excise Duty - %s" % abbr: [0, 140],
- "Education Cess - %s" % abbr: [0, 2.8],
- "S&H Education Cess - %s" % abbr: [0, 1.4],
- "CST - %s" % abbr: [0, 32.38],
- "VAT - Test - %s" % abbr: [0, 156.25],
- "adj_rate - %s" % abbr: [180.78, 0],
- }
-
- gl_entries = webnotes.conn.sql("""select account, debit, credit from `tabGL Entry`
- where voucher_type = %s and voucher_no = %s""",
- (controller.doc.doctype, controller.doc.name), as_dict=1)
-
- for gle in gl_entries:
- self.assertEqual([gle.debit, gle.credit], expected_gl_entries[gle.account])
-
- def tearDown(self):
- webnotes.conn.rollback()
\ No newline at end of file
diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py
index 0149f81cc5..096a43e3ff 100644
--- a/buying/doctype/supplier/supplier.py
+++ b/buying/doctype/supplier/supplier.py
@@ -182,12 +182,3 @@ class DocType(TransactionBase):
#update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
master_type = 'Supplier' where master_name = %s""" , (new,old))
-
-test_records = [
- [{
- "doctype": "Supplier",
- "supplier_name": "_Test Supplier",
- "supplier_type": "_Test Supplier Type",
- "company": "_Test Company"
- }]
-]
\ No newline at end of file
diff --git a/buying/doctype/supplier/test_supplier.py b/buying/doctype/supplier/test_supplier.py
new file mode 100644
index 0000000000..3ee3419ffa
--- /dev/null
+++ b/buying/doctype/supplier/test_supplier.py
@@ -0,0 +1,8 @@
+test_records = [
+ [{
+ "doctype": "Supplier",
+ "supplier_name": "_Test Supplier",
+ "supplier_type": "_Test Supplier Type",
+ "company": "_Test Company"
+ }]
+]
\ No newline at end of file
diff --git a/home/page/desktop/desktop.txt b/home/page/desktop/desktop.txt
index 1eec626e41..4a5fb9559d 100644
--- a/home/page/desktop/desktop.txt
+++ b/home/page/desktop/desktop.txt
@@ -1,21 +1,32 @@
[
{
- "owner": "Administrator",
+ "creation": "2012-06-14 18:44:56",
"docstatus": 0,
- "creation": "2012-02-24 11:37:43",
+ "modified": "2013-02-12 18:11:00",
"modified_by": "Administrator",
- "modified": "2012-02-24 11:37:43"
+ "owner": "Administrator"
},
{
- "name": "__common__",
- "title": "Desktop",
- "module": "Home",
"doctype": "Page",
+ "module": "Home",
+ "name": "__common__",
"page_name": "desktop",
- "standard": "Yes"
+ "standard": "Yes",
+ "title": "Desktop"
},
{
- "name": "desktop",
- "doctype": "Page"
+ "doctype": "Page Role",
+ "name": "__common__",
+ "parent": "desktop",
+ "parentfield": "roles",
+ "parenttype": "Page",
+ "role": "All"
+ },
+ {
+ "doctype": "Page",
+ "name": "desktop"
+ },
+ {
+ "doctype": "Page Role"
}
]
\ No newline at end of file
diff --git a/hr/doctype/branch/branch.py b/hr/doctype/branch/branch.py
index 8b4a24df55..eb3916b006 100644
--- a/hr/doctype/branch/branch.py
+++ b/hr/doctype/branch/branch.py
@@ -21,4 +21,3 @@ class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-test_records = [[{"doctype":"Branch", "branch":"_Test Branch"}]]
\ No newline at end of file
diff --git a/hr/doctype/branch/test_branch.py b/hr/doctype/branch/test_branch.py
new file mode 100644
index 0000000000..dc336440d6
--- /dev/null
+++ b/hr/doctype/branch/test_branch.py
@@ -0,0 +1 @@
+test_records = [[{"doctype":"Branch", "branch":"_Test Branch"}]]
\ No newline at end of file
diff --git a/hr/doctype/department/department.py b/hr/doctype/department/department.py
index c38ee93cf5..6c41e4f039 100644
--- a/hr/doctype/department/department.py
+++ b/hr/doctype/department/department.py
@@ -20,9 +20,4 @@ import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-
-test_records = [
- [{"doctype":"Department", "department_name":"_Test Department"}],
- [{"doctype":"Department", "department_name":"_Test Department with Block List",
- "holiday_block_list": "_Test Holiday Block List"}],
-]
+
\ No newline at end of file
diff --git a/hr/doctype/department/test_department.py b/hr/doctype/department/test_department.py
new file mode 100644
index 0000000000..9db4f61ac7
--- /dev/null
+++ b/hr/doctype/department/test_department.py
@@ -0,0 +1,5 @@
+test_records = [
+ [{"doctype":"Department", "department_name":"_Test Department"}],
+ [{"doctype":"Department", "department_name":"_Test Department with Block List",
+ "holiday_block_list": "_Test Holiday Block List"}],
+]
diff --git a/hr/doctype/designation/designation.py b/hr/doctype/designation/designation.py
index d101ee317e..eb3916b006 100644
--- a/hr/doctype/designation/designation.py
+++ b/hr/doctype/designation/designation.py
@@ -21,4 +21,3 @@ class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-test_records = [[{"doctype":"Designation", "designation_name":"_Test Designation"}]]
\ No newline at end of file
diff --git a/hr/doctype/designation/test_designation.py b/hr/doctype/designation/test_designation.py
new file mode 100644
index 0000000000..913b7ec871
--- /dev/null
+++ b/hr/doctype/designation/test_designation.py
@@ -0,0 +1 @@
+test_records = [[{"doctype":"Designation", "designation_name":"_Test Designation"}]]
\ No newline at end of file
diff --git a/hr/doctype/employee/employee.py b/hr/doctype/employee/employee.py
index d08da1acba..6846c5efba 100644
--- a/hr/doctype/employee/employee.py
+++ b/hr/doctype/employee/employee.py
@@ -128,26 +128,3 @@ class DocType:
if self.doc.status == 'Left' and not self.doc.relieving_date:
msgprint("Please enter relieving date.")
raise Exception
-
-test_records = [[{
- "doctype":"Employee",
- "employee_name": "_Test Employee",
- "naming_series": "_T-Employee-",
- "date_of_joining": "2010-01-01",
- "date_of_birth": "1980-01-01",
- "gender": "Female",
- "status": "Active",
- "company": "_Test Company",
- "user_id": "test@erpnext.com"
-}],
-[{
- "doctype":"Employee",
- "employee_name": "_Test Employee 1",
- "naming_series": "_T-Employee-",
- "date_of_joining": "2010-01-01",
- "date_of_birth": "1980-01-01",
- "gender": "Male",
- "status": "Active",
- "company": "_Test Company",
- "user_id": "test1@erpnext.com"
-}]]
\ No newline at end of file
diff --git a/hr/doctype/employee/test_employee.py b/hr/doctype/employee/test_employee.py
new file mode 100644
index 0000000000..a9c715b9d8
--- /dev/null
+++ b/hr/doctype/employee/test_employee.py
@@ -0,0 +1,22 @@
+test_records = [[{
+ "doctype":"Employee",
+ "employee_name": "_Test Employee",
+ "naming_series": "_T-Employee-",
+ "date_of_joining": "2010-01-01",
+ "date_of_birth": "1980-01-01",
+ "gender": "Female",
+ "status": "Active",
+ "company": "_Test Company",
+ "user_id": "test@erpnext.com"
+}],
+[{
+ "doctype":"Employee",
+ "employee_name": "_Test Employee 1",
+ "naming_series": "_T-Employee-",
+ "date_of_joining": "2010-01-01",
+ "date_of_birth": "1980-01-01",
+ "gender": "Male",
+ "status": "Active",
+ "company": "_Test Company",
+ "user_id": "test1@erpnext.com"
+}]]
\ No newline at end of file
diff --git a/hr/doctype/employment_type/employment_type.py b/hr/doctype/employment_type/employment_type.py
index ac34d45686..6c41e4f039 100644
--- a/hr/doctype/employment_type/employment_type.py
+++ b/hr/doctype/employment_type/employment_type.py
@@ -20,6 +20,4 @@ import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-
-test_records = [[{"doctype":"Employment Type",
- "employee_type_name": "_Test Employment Type"}]]
\ No newline at end of file
+
\ No newline at end of file
diff --git a/hr/doctype/employment_type/test_employment_type.py b/hr/doctype/employment_type/test_employment_type.py
new file mode 100644
index 0000000000..9aedad413e
--- /dev/null
+++ b/hr/doctype/employment_type/test_employment_type.py
@@ -0,0 +1,2 @@
+test_records = [[{"doctype":"Employment Type",
+ "employee_type_name": "_Test Employment Type"}]]
\ No newline at end of file
diff --git a/hr/doctype/grade/grade.py b/hr/doctype/grade/grade.py
index b1eaefa4d4..eb3916b006 100644
--- a/hr/doctype/grade/grade.py
+++ b/hr/doctype/grade/grade.py
@@ -21,4 +21,3 @@ class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-test_records = [[{"doctype":"Grade", "grade_name":"Test Grade"}]]
\ No newline at end of file
diff --git a/hr/doctype/grade/test_grade.py b/hr/doctype/grade/test_grade.py
new file mode 100644
index 0000000000..2d6ce794f0
--- /dev/null
+++ b/hr/doctype/grade/test_grade.py
@@ -0,0 +1 @@
+test_records = [[{"doctype":"Grade", "grade_name":"_Test Grade"}]]
\ No newline at end of file
diff --git a/hr/doctype/holiday_block_list/holiday_block_list.py b/hr/doctype/holiday_block_list/holiday_block_list.py
index a016ab8f6b..776e4a9940 100644
--- a/hr/doctype/holiday_block_list/holiday_block_list.py
+++ b/hr/doctype/holiday_block_list/holiday_block_list.py
@@ -20,23 +20,3 @@ class DocType:
webnotes.msgprint(_("Date is repeated") + ":" + d.block_date, raise_exception=1)
dates.append(d.block_date)
-test_records = [[{
- "doctype":"Holiday Block List",
- "holiday_block_list_name": "_Test Holiday Block List",
- "year": "_Test Fiscal Year 2013",
- "company": "_Test Company"
- }, {
- "doctype": "Holiday Block List Date",
- "parent": "_Test Holiday Block List",
- "parenttype": "Holiday Block List",
- "parentfield": "holiday_block_list_dates",
- "block_date": "2013-01-02",
- "reason": "First work day"
- }, {
- "doctype": "Holiday Block List Allow",
- "parent": "_Test Holiday Block List",
- "parenttype": "Holiday Block List",
- "parentfield": "holiday_block_list_allowed",
- "allow_user": "test1@erpnext.com",
- }
- ]]
\ No newline at end of file
diff --git a/hr/doctype/holiday_block_list/test_holiday_block_list.py b/hr/doctype/holiday_block_list/test_holiday_block_list.py
new file mode 100644
index 0000000000..5ec4dd1af5
--- /dev/null
+++ b/hr/doctype/holiday_block_list/test_holiday_block_list.py
@@ -0,0 +1,20 @@
+test_records = [[{
+ "doctype":"Holiday Block List",
+ "holiday_block_list_name": "_Test Holiday Block List",
+ "year": "_Test Fiscal Year 2013",
+ "company": "_Test Company"
+ }, {
+ "doctype": "Holiday Block List Date",
+ "parent": "_Test Holiday Block List",
+ "parenttype": "Holiday Block List",
+ "parentfield": "holiday_block_list_dates",
+ "block_date": "2013-01-02",
+ "reason": "First work day"
+ }, {
+ "doctype": "Holiday Block List Allow",
+ "parent": "_Test Holiday Block List",
+ "parenttype": "Holiday Block List",
+ "parentfield": "holiday_block_list_allowed",
+ "allow_user": "test1@erpnext.com",
+ }
+ ]]
\ No newline at end of file
diff --git a/hr/doctype/holiday_list/holiday_list.py b/hr/doctype/holiday_list/holiday_list.py
index 4c929cd8e4..5a4c062810 100644
--- a/hr/doctype/holiday_list/holiday_list.py
+++ b/hr/doctype/holiday_list/holiday_list.py
@@ -89,16 +89,3 @@ class DocType:
def update_default_holiday_list(self):
webnotes.conn.sql("""update `tabHoliday List` set is_default = 0
where ifnull(is_default, 0) = 1 and fiscal_year = %s""", (self.doc.fiscal_year,))
-
-test_records = [[{
- "doctype": "Holiday List",
- "holiday_list_name": "_Test Holiday List",
- "fiscal_year": "_Test Fiscal Year 2013"
- }, {
- "doctype": "Holiday",
- "parent": "_Test Holiday List",
- "parenttype": "Holiday List",
- "parentfield": "holiday_list_details",
- "holiday_date": "2013-01-01",
- "description": "New Year"
- }]]
diff --git a/hr/doctype/holiday_list/test_holiday_list.py b/hr/doctype/holiday_list/test_holiday_list.py
new file mode 100644
index 0000000000..e3a2d82980
--- /dev/null
+++ b/hr/doctype/holiday_list/test_holiday_list.py
@@ -0,0 +1,12 @@
+test_records = [[{
+ "doctype": "Holiday List",
+ "holiday_list_name": "_Test Holiday List",
+ "fiscal_year": "_Test Fiscal Year 2013"
+ }, {
+ "doctype": "Holiday",
+ "parent": "_Test Holiday List",
+ "parenttype": "Holiday List",
+ "parentfield": "holiday_list_details",
+ "holiday_date": "2013-01-01",
+ "description": "New Year"
+ }]]
\ No newline at end of file
diff --git a/hr/doctype/leave_application/test_leave_application.py b/hr/doctype/leave_application/test_leave_application.py
index 74f73c2825..7195826bf9 100644
--- a/hr/doctype/leave_application/test_leave_application.py
+++ b/hr/doctype/leave_application/test_leave_application.py
@@ -1,9 +1,6 @@
-import sys
+import webnotes
import unittest
-if __name__=="__main__":
- sys.path.extend([".", "app", "lib"])
-
from hr.doctype.leave_application.leave_application import LeaveDayBlockedError
class TestLeaveApplication(unittest.TestCase):
@@ -54,13 +51,3 @@ test_records = [
"employee": "_T-Employee-0001",
"company": "_Test Company"
}]]
-
-if __name__=="__main__":
- import webnotes
- webnotes.connect()
-
- from webnotes.test_runner import make_test_records
- make_test_records("Leave Application")
-
- unittest.main()
-
diff --git a/hr/doctype/leave_type/leave_type.py b/hr/doctype/leave_type/leave_type.py
index 5b2e5e8827..6c41e4f039 100644
--- a/hr/doctype/leave_type/leave_type.py
+++ b/hr/doctype/leave_type/leave_type.py
@@ -20,10 +20,4 @@ import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-
-test_records = [
- [{
- "leave_type_name": "_Test Leave Type",
- "doctype": "Leave Type"
- }]
-]
\ No newline at end of file
+
\ No newline at end of file
diff --git a/hr/doctype/leave_type/test_leave_type.py b/hr/doctype/leave_type/test_leave_type.py
new file mode 100644
index 0000000000..4d789758a4
--- /dev/null
+++ b/hr/doctype/leave_type/test_leave_type.py
@@ -0,0 +1,6 @@
+test_records = [
+ [{
+ "leave_type_name": "_Test Leave Type",
+ "doctype": "Leave Type"
+ }]
+]
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 467c6b05cf..c1fa08f24e 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -166,5 +166,6 @@ patch_list = [
"patches.february_2013.remove_sales_order_pending_items",
"patches.february_2013.account_negative_balance",
"patches.february_2013.remove_account_utils_folder",
- "patches.february_2013.update_company_in_leave_application"
+ "patches.february_2013.update_company_in_leave_application",
+ "execute:webnotes.conn.sql_ddl('alter table tabSeries change `name` `name` varchar(100)')"
]
\ No newline at end of file
diff --git a/selling/doctype/campaign/campaign.py b/selling/doctype/campaign/campaign.py
index 7f48feb2eb..6c41e4f039 100644
--- a/selling/doctype/campaign/campaign.py
+++ b/selling/doctype/campaign/campaign.py
@@ -19,4 +19,5 @@ import webnotes
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
+
\ No newline at end of file
diff --git a/selling/doctype/campaign/test_campaign.py b/selling/doctype/campaign/test_campaign.py
new file mode 100644
index 0000000000..4783fffda2
--- /dev/null
+++ b/selling/doctype/campaign/test_campaign.py
@@ -0,0 +1,4 @@
+test_records = [
+ [{"doctype":"Campaign", "campaign_name":"_Test Campaign"}],
+ [{"doctype":"Campaign", "campaign_name":"_Test Campaign 1"}],
+]
\ No newline at end of file
diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py
index 932256fcf5..0b49b77883 100644
--- a/selling/doctype/customer/customer.py
+++ b/selling/doctype/customer/customer.py
@@ -248,15 +248,4 @@ class DocType(TransactionBase):
#update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
- master_type = 'Customer' where master_name = %s""", (new,old))
-
-test_records = [
- [{
- "doctype": "Customer",
- "customer_name": "_Test Customer",
- "customer_type": "Individual",
- "customer_group": "_Test Customer Group",
- "territory": "_Test Territory",
- "company": "_Test Company"
- }]
-]
\ No newline at end of file
+ master_type = 'Customer' where master_name = %s""", (new,old))
\ No newline at end of file
diff --git a/selling/doctype/customer/test_customer.py b/selling/doctype/customer/test_customer.py
new file mode 100644
index 0000000000..09e2f5d7f5
--- /dev/null
+++ b/selling/doctype/customer/test_customer.py
@@ -0,0 +1,10 @@
+test_records = [
+ [{
+ "doctype": "Customer",
+ "customer_name": "_Test Customer",
+ "customer_type": "Individual",
+ "customer_group": "_Test Customer Group",
+ "territory": "_Test Territory",
+ "company": "_Test Company"
+ }]
+]
\ No newline at end of file
diff --git a/selling/doctype/industry_type/industry_type.py b/selling/doctype/industry_type/industry_type.py
index 7f48feb2eb..6c41e4f039 100644
--- a/selling/doctype/industry_type/industry_type.py
+++ b/selling/doctype/industry_type/industry_type.py
@@ -19,4 +19,5 @@ import webnotes
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
+
\ No newline at end of file
diff --git a/selling/doctype/industry_type/test_industry_type.py b/selling/doctype/industry_type/test_industry_type.py
new file mode 100644
index 0000000000..344080720e
--- /dev/null
+++ b/selling/doctype/industry_type/test_industry_type.py
@@ -0,0 +1,4 @@
+test_records = [
+ [{"doctype":"Industry Type", "industry":"_Test Industry"}],
+ [{"doctype":"Industry Type", "industry":"_Test Industry 1"}],
+]
\ No newline at end of file
diff --git a/selling/doctype/lead/lead.py b/selling/doctype/lead/lead.py
index 4c76d17e1b..c336fe2132 100644
--- a/selling/doctype/lead/lead.py
+++ b/selling/doctype/lead/lead.py
@@ -100,4 +100,4 @@ class DocType(SellingController):
webnotes.conn.sql("""delete from tabCommunication where lead=%s""",
self.doc.name)
webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
- self.doc.name)
\ No newline at end of file
+ self.doc.name)
diff --git a/selling/doctype/lead/test_lead.py b/selling/doctype/lead/test_lead.py
new file mode 100644
index 0000000000..e525547c24
--- /dev/null
+++ b/selling/doctype/lead/test_lead.py
@@ -0,0 +1,10 @@
+test_records = [
+ [{"doctype":"Lead", "lead_name": "_Test Lead", "status":"Open",
+ "email_id":"test_lead@example.com"}],
+ [{"doctype":"Lead", "lead_name": "_Test Lead 1", "status":"Open",
+ "email_id":"test_lead1@example.com"}],
+ [{"doctype":"Lead", "lead_name": "_Test Lead 2", "status":"Contacted",
+ "email_id":"test_lead2@example.com"}],
+ [{"doctype":"Lead", "lead_name": "_Test Lead 3", "status":"Converted",
+ "email_id":"test_lead3@example.com"}],
+]
diff --git a/setup/doctype/brand/brand.py b/setup/doctype/brand/brand.py
index 19546da1a9..7794430349 100644
--- a/setup/doctype/brand/brand.py
+++ b/setup/doctype/brand/brand.py
@@ -20,10 +20,3 @@ import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-
-test_records = [
- [{
- "doctype": "Brand",
- "brand": "_Test Brand"
- }]
-]
\ No newline at end of file
diff --git a/setup/doctype/brand/test_brand.py b/setup/doctype/brand/test_brand.py
new file mode 100644
index 0000000000..7a18c2ebb2
--- /dev/null
+++ b/setup/doctype/brand/test_brand.py
@@ -0,0 +1,6 @@
+test_records = [
+ [{
+ "doctype": "Brand",
+ "brand": "_Test Brand"
+ }]
+]
\ No newline at end of file
diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py
index a951af58c9..a9d11c6cf4 100644
--- a/setup/doctype/company/company.py
+++ b/setup/doctype/company/company.py
@@ -254,13 +254,4 @@ class DocType:
sql("update `tabCompany` set company_name = '%s' where name = '%s'" %(newdn,olddn))
sql("update `tabSingles` set value = %s where doctype='Global Defaults' and field = 'default_company' and value = %s", (newdn, olddn))
if get_defaults('company') == olddn:
- set_default('company', newdn)
-
-test_records = [
- [{
- "doctype": "Company",
- "company_name": "_Test Company",
- "abbr": "_TC",
- "default_currency": "INR",
- }],
-]
\ No newline at end of file
+ set_default('company', newdn)
\ No newline at end of file
diff --git a/setup/doctype/company/test_company.py b/setup/doctype/company/test_company.py
new file mode 100644
index 0000000000..fe793ffce4
--- /dev/null
+++ b/setup/doctype/company/test_company.py
@@ -0,0 +1,10 @@
+test_ignore = ["Account"]
+
+test_records = [
+ [{
+ "doctype": "Company",
+ "company_name": "_Test Company",
+ "abbr": "_TC",
+ "default_currency": "INR",
+ }],
+]
\ No newline at end of file
diff --git a/setup/doctype/country/country.py b/setup/doctype/country/country.py
index 360f67915b..7794430349 100644
--- a/setup/doctype/country/country.py
+++ b/setup/doctype/country/country.py
@@ -20,10 +20,3 @@ import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-
-test_records = [
- [{
- "doctype": "Country",
- "country_name": "_Test Country"
- }]
-]
\ No newline at end of file
diff --git a/setup/doctype/country/test_country.py b/setup/doctype/country/test_country.py
new file mode 100644
index 0000000000..c42e80fe1b
--- /dev/null
+++ b/setup/doctype/country/test_country.py
@@ -0,0 +1,6 @@
+test_records = [
+ [{
+ "doctype": "Country",
+ "country_name": "_Test Country"
+ }]
+]
\ No newline at end of file
diff --git a/setup/doctype/currency/test_currency.py b/setup/doctype/currency/test_currency.py
new file mode 100644
index 0000000000..71963f91f6
--- /dev/null
+++ b/setup/doctype/currency/test_currency.py
@@ -0,0 +1,2 @@
+# pre loaded
+test_records = []
\ No newline at end of file
diff --git a/setup/doctype/customer_group/customer_group.py b/setup/doctype/customer_group/customer_group.py
index fa81dcad15..de0042ec59 100644
--- a/setup/doctype/customer_group/customer_group.py
+++ b/setup/doctype/customer_group/customer_group.py
@@ -61,12 +61,3 @@ class DocType(DocTypeNestedSet):
# rebuild tree
super(DocType, self).on_trash()
-
-test_records = [
- [{
- "doctype": "Customer Group",
- "customer_group_name": "_Test Customer Group",
- "parent_customer_group": "All Customer Groups",
- "is_group": "No"
- }]
-]
\ No newline at end of file
diff --git a/setup/doctype/customer_group/test_customer_group.py b/setup/doctype/customer_group/test_customer_group.py
new file mode 100644
index 0000000000..7670824692
--- /dev/null
+++ b/setup/doctype/customer_group/test_customer_group.py
@@ -0,0 +1,8 @@
+test_records = [
+ [{
+ "doctype": "Customer Group",
+ "customer_group_name": "_Test Customer Group",
+ "parent_customer_group": "All Customer Groups",
+ "is_group": "No"
+ }]
+]
\ No newline at end of file
diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py
index c0fd9068ab..66565d6e78 100644
--- a/setup/doctype/item_group/item_group.py
+++ b/setup/doctype/item_group/item_group.py
@@ -68,18 +68,3 @@ class DocType(DocTypeNestedSet):
if self.doc.slideshow:
from website.helpers.slideshow import get_slideshow
get_slideshow(self)
-
-test_records = [
- [{
- "doctype": "Item Group",
- "item_group_name": "_Test Item Group",
- "parent_item_group": "All Item Groups",
- "is_group": "No"
- }],
- [{
- "doctype": "Item Group",
- "item_group_name": "_Test Item Group Desktops",
- "parent_item_group": "All Item Groups",
- "is_group": "No"
- }],
-]
\ No newline at end of file
diff --git a/setup/doctype/item_group/test_item_group.py b/setup/doctype/item_group/test_item_group.py
new file mode 100644
index 0000000000..924b3671f5
--- /dev/null
+++ b/setup/doctype/item_group/test_item_group.py
@@ -0,0 +1,14 @@
+test_records = [
+ [{
+ "doctype": "Item Group",
+ "item_group_name": "_Test Item Group",
+ "parent_item_group": "All Item Groups",
+ "is_group": "No"
+ }],
+ [{
+ "doctype": "Item Group",
+ "item_group_name": "_Test Item Group Desktops",
+ "parent_item_group": "All Item Groups",
+ "is_group": "No"
+ }],
+]
\ No newline at end of file
diff --git a/setup/doctype/price_list/test_price_list.py b/setup/doctype/price_list/test_price_list.py
new file mode 100644
index 0000000000..53b86a39fc
--- /dev/null
+++ b/setup/doctype/price_list/test_price_list.py
@@ -0,0 +1,6 @@
+test_records = [
+ [{
+ "doctype": "Price List",
+ "price_list_name": "_Test Price List"
+ }]
+]
\ No newline at end of file
diff --git a/setup/doctype/quotation_lost_reason/quotation_lost_reason.py b/setup/doctype/quotation_lost_reason/quotation_lost_reason.py
index 7f48feb2eb..7794430349 100644
--- a/setup/doctype/quotation_lost_reason/quotation_lost_reason.py
+++ b/setup/doctype/quotation_lost_reason/quotation_lost_reason.py
@@ -19,4 +19,4 @@ import webnotes
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
diff --git a/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py b/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py
new file mode 100644
index 0000000000..9e982046ea
--- /dev/null
+++ b/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py
@@ -0,0 +1 @@
+test_records = [[{"doctype":"Quotation Lost Reason", "order_lost_reason": "_Test Quotation Lost Reason"}]]
\ No newline at end of file
diff --git a/setup/doctype/sales_partner/test_sales_partner.py b/setup/doctype/sales_partner/test_sales_partner.py
new file mode 100644
index 0000000000..3afb472bae
--- /dev/null
+++ b/setup/doctype/sales_partner/test_sales_partner.py
@@ -0,0 +1 @@
+test_records = []
\ No newline at end of file
diff --git a/setup/doctype/sales_person/test_sales_person.py b/setup/doctype/sales_person/test_sales_person.py
new file mode 100644
index 0000000000..5af450916b
--- /dev/null
+++ b/setup/doctype/sales_person/test_sales_person.py
@@ -0,0 +1,8 @@
+test_records = [
+ [{
+ "doctype": "Sales Person",
+ "sales_person_name": "_Test Sales Person",
+ "parent_sales_person": "All Sales Persons",
+ "is_group": "No"
+ }]
+]
\ No newline at end of file
diff --git a/setup/doctype/supplier_type/supplier_type.py b/setup/doctype/supplier_type/supplier_type.py
index 4a8fdff58d..7794430349 100644
--- a/setup/doctype/supplier_type/supplier_type.py
+++ b/setup/doctype/supplier_type/supplier_type.py
@@ -20,11 +20,3 @@ import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-
-
-test_records = [
- [{
- "doctype": "Supplier Type",
- "supplier_type": "_Test Supplier Type",
- }]
-]
\ No newline at end of file
diff --git a/setup/doctype/supplier_type/test_supplier_type.py b/setup/doctype/supplier_type/test_supplier_type.py
new file mode 100644
index 0000000000..74dde9735d
--- /dev/null
+++ b/setup/doctype/supplier_type/test_supplier_type.py
@@ -0,0 +1,6 @@
+test_records = [
+ [{
+ "doctype": "Supplier Type",
+ "supplier_type": "_Test Supplier Type",
+ }]
+]
\ No newline at end of file
diff --git a/setup/doctype/territory/territory.py b/setup/doctype/territory/territory.py
index 11bd4cc9c4..d97a9cada5 100644
--- a/setup/doctype/territory/territory.py
+++ b/setup/doctype/territory/territory.py
@@ -33,12 +33,4 @@ class DocType(DocTypeNestedSet):
if not flt(d.target_qty) and not flt(d.target_amount):
msgprint("Either target qty or target amount is mandatory.")
raise Exception
-
-test_records = [
- [{
- "doctype": "Territory",
- "territory_name": "_Test Territory",
- "parent_territory": "All Territories",
- "is_group": "No",
- }]
-]
\ No newline at end of file
+
\ No newline at end of file
diff --git a/setup/doctype/territory/test_territory.py b/setup/doctype/territory/test_territory.py
new file mode 100644
index 0000000000..2124199c12
--- /dev/null
+++ b/setup/doctype/territory/test_territory.py
@@ -0,0 +1,8 @@
+test_records = [
+ [{
+ "doctype": "Territory",
+ "territory_name": "_Test Territory",
+ "parent_territory": "All Territories",
+ "is_group": "No",
+ }]
+]
\ No newline at end of file
diff --git a/setup/doctype/uom/test_uom.py b/setup/doctype/uom/test_uom.py
new file mode 100644
index 0000000000..51c2bdd92f
--- /dev/null
+++ b/setup/doctype/uom/test_uom.py
@@ -0,0 +1,6 @@
+test_records = [
+ [{
+ "doctype": "UOM",
+ "uom_name": "_Test UOM"
+ }]
+]
\ No newline at end of file
diff --git a/setup/doctype/uom/uom.py b/setup/doctype/uom/uom.py
index 733cb57822..7794430349 100644
--- a/setup/doctype/uom/uom.py
+++ b/setup/doctype/uom/uom.py
@@ -20,10 +20,3 @@ import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-
-test_records = [
- [{
- "doctype": "UOM",
- "uom_name": "_Test UOM"
- }]
-]
\ No newline at end of file
diff --git a/setup/doctype/warehouse_type/test_warehouse_type.py b/setup/doctype/warehouse_type/test_warehouse_type.py
new file mode 100644
index 0000000000..208859bf75
--- /dev/null
+++ b/setup/doctype/warehouse_type/test_warehouse_type.py
@@ -0,0 +1,6 @@
+test_records = [
+ [{
+ "doctype": "Warehouse Type",
+ "warehouse_type": "_Test Warehouse Type"
+ }]
+]
\ No newline at end of file
diff --git a/setup/doctype/warehouse_type/warehouse_type.py b/setup/doctype/warehouse_type/warehouse_type.py
index 451db4122c..7794430349 100644
--- a/setup/doctype/warehouse_type/warehouse_type.py
+++ b/setup/doctype/warehouse_type/warehouse_type.py
@@ -20,10 +20,3 @@ import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
-
-test_records = [
- [{
- "doctype": "Warehouse Type",
- "warehouse_type": "_Test Warehouse Type"
- }]
-]
\ No newline at end of file
diff --git a/startup/__init__.py b/startup/__init__.py
index 08a243c7cc..18ae9328de 100644
--- a/startup/__init__.py
+++ b/startup/__init__.py
@@ -39,7 +39,9 @@ profile_defaults = {
"Company": "company",
"Territory": "territory"
}
-
+
+application_home_page = "desktop"
+
# add startup propertes
mail_footer = """
"""
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index 2d781bd3b9..c6ace19b48 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -221,49 +221,3 @@ class DocType:
if self.doc.slideshow:
from website.helpers.slideshow import get_slideshow
get_slideshow(self)
-
-test_records = [
- [{
- "doctype": "Item",
- "item_code": "_Test Item Home Desktop 100",
- "item_name": "_Test Item Home Desktop 100",
- "description": "_Test Item Home Desktop 100",
- "item_group": "_Test Item Group Desktops",
- "is_stock_item": "Yes",
- "is_asset_item": "No",
- "has_batch_no": "No",
- "has_serial_no": "No",
- "is_purchase_item": "Yes",
- "is_sales_item": "Yes",
- "is_service_item": "No",
- "is_sample_item": "No",
- "inspection_required": "No",
- "is_pro_applicable": "No",
- "is_sub_contracted_item": "No",
- "stock_uom": "_Test UOM"
- },
- {
- "doctype": "Item Tax",
- "tax_type": "_Test Account Excise Duty - _TC",
- "tax_rate": 10
- }],
- [{
- "doctype": "Item",
- "item_code": "_Test Item Home Desktop 200",
- "item_name": "_Test Item Home Desktop 200",
- "description": "_Test Item Home Desktop 200",
- "item_group": "_Test Item Group Desktops",
- "is_stock_item": "Yes",
- "is_asset_item": "No",
- "has_batch_no": "No",
- "has_serial_no": "No",
- "is_purchase_item": "Yes",
- "is_sales_item": "Yes",
- "is_service_item": "No",
- "is_sample_item": "No",
- "inspection_required": "No",
- "is_pro_applicable": "No",
- "is_sub_contracted_item": "No",
- "stock_uom": "_Test UOM"
- }],
-]
\ No newline at end of file
diff --git a/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py
index f7876a6cba..28da848f23 100644
--- a/stock/doctype/item/test_item.py
+++ b/stock/doctype/item/test_item.py
@@ -76,3 +76,48 @@ docok = [Document(fielddata=r) for r in tabOK]
docnotok = [Document(fielddata=r) for r in tabNotOK]
+test_records = [
+ [{
+ "doctype": "Item",
+ "item_code": "_Test Item Home Desktop 100",
+ "item_name": "_Test Item Home Desktop 100",
+ "description": "_Test Item Home Desktop 100",
+ "item_group": "_Test Item Group Desktops",
+ "is_stock_item": "Yes",
+ "is_asset_item": "No",
+ "has_batch_no": "No",
+ "has_serial_no": "No",
+ "is_purchase_item": "Yes",
+ "is_sales_item": "Yes",
+ "is_service_item": "No",
+ "is_sample_item": "No",
+ "inspection_required": "No",
+ "is_pro_applicable": "No",
+ "is_sub_contracted_item": "No",
+ "stock_uom": "_Test UOM"
+ },
+ {
+ "doctype": "Item Tax",
+ "tax_type": "_Test Account Excise Duty - _TC",
+ "tax_rate": 10
+ }],
+ [{
+ "doctype": "Item",
+ "item_code": "_Test Item Home Desktop 200",
+ "item_name": "_Test Item Home Desktop 200",
+ "description": "_Test Item Home Desktop 200",
+ "item_group": "_Test Item Group Desktops",
+ "is_stock_item": "Yes",
+ "is_asset_item": "No",
+ "has_batch_no": "No",
+ "has_serial_no": "No",
+ "is_purchase_item": "Yes",
+ "is_sales_item": "Yes",
+ "is_service_item": "No",
+ "is_sample_item": "No",
+ "inspection_required": "No",
+ "is_pro_applicable": "No",
+ "is_sub_contracted_item": "No",
+ "stock_uom": "_Test UOM"
+ }],
+]
\ No newline at end of file
diff --git a/stock/doctype/warehouse/test_warehouse.py b/stock/doctype/warehouse/test_warehouse.py
new file mode 100644
index 0000000000..eb4554b5ee
--- /dev/null
+++ b/stock/doctype/warehouse/test_warehouse.py
@@ -0,0 +1,7 @@
+test_records = [
+ [{
+ "doctype": "Warehouse",
+ "warehouse_name": "_Test Warehouse",
+ "warehouse_type": "_Test Warehouse Type"
+ }]
+]
\ No newline at end of file
diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py
index a4ee3704e2..fb6fc298e2 100644
--- a/stock/doctype/warehouse/warehouse.py
+++ b/stock/doctype/warehouse/warehouse.py
@@ -207,11 +207,3 @@ class DocType:
exists for this warehouse.""", raise_exception=1)
else:
sql("delete from `tabStock Ledger Entry` where warehouse = %s", self.doc.name)
-
-test_records = [
- [{
- "doctype": "Warehouse",
- "warehouse_name": "_Test Warehouse",
- "warehouse_type": "_Test Warehouse Type"
- }]
-]
\ No newline at end of file
diff --git a/support/doctype/newsletter/newsletter.js b/support/doctype/newsletter/newsletter.js
index 69a55eff09..b7e24d2173 100644
--- a/support/doctype/newsletter/newsletter.js
+++ b/support/doctype/newsletter/newsletter.js
@@ -29,4 +29,13 @@ cur_frm.cscript.refresh = function(doc) {
cur_frm.set_value("send_from",
repl("%(fullname)s <%(email)s>", wn.user_info(doc.owner)));
}
+
+ wn.call({
+ method: "support.doctype.newsletter.newsletter.get_lead_options",
+ type: "GET",
+ callback: function(r) {
+ set_field_options("lead_source", r.message.sources.join("\n"))
+ set_field_options("lead_status", r.message.statuses.join("\n"))
+ }
+ })
}
\ No newline at end of file
diff --git a/support/doctype/newsletter/newsletter.py b/support/doctype/newsletter/newsletter.py
index d32154e590..88ec384c72 100644
--- a/support/doctype/newsletter/newsletter.py
+++ b/support/doctype/newsletter/newsletter.py
@@ -25,100 +25,72 @@ from webnotes import _
class DocType():
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
- self.dt_map = {
- "Contact": {
- "email_field": "email_id",
- "first_name_field": "first_name",
- },
- "Lead": {
- "email_field": "email_id",
- "first_name_field": "lead_name"
- }
- }
- self.query_map = {
- "contacts": """select distinct email_id from `tabContact`
- where ifnull(email_id, '') != '' """,
- "customer_contacts": """select distinct email_id from `tabContact`
- where ifnull(customer, '') != '' and ifnull(email_id, '') != '' """,
- "leads": """select distinct email_id from `tabLead`
- where ifnull(email_id, '') != '' """,
- "active_leads": """select distinct email_id from `tabLead`
- where status = "Open" and ifnull(email_id, '') != '' """,
- "blog_subscribers": """select distinct email_id from `tabLead`
- where ifnull(blog_subscriber,0) = 1 and ifnull(email_id, '') != '' """
- }
-
+
+ def test_send(self, doctype="Lead"):
+ self.recipients = self.doc.test_email_id.split(",")
+ self.send_bulk()
+ webnotes.msgprint("""Scheduled to send to %s""" % self.doc.test_email_id)
+
def send_emails(self):
"""send emails to leads and customers"""
if self.doc.email_sent:
webnotes.msgprint("""Newsletter has already been sent""", raise_exception=1)
- self.all_recipients = []
- self.send_count = {}
+ self.recipients = self.get_recipients()
+ self.send_bulk()
- if self.doc.contacts:
- self.send("contacts", "Contact")
- elif self.doc.customer_contacts:
- self.send("customer_contacts", "Contact")
-
- if self.doc.leads:
- self.send("leads", "Lead")
- else:
- if self.doc.active_leads:
- self.send("active_leads", "Lead")
+ webnotes.msgprint("""Scheduled to send to %d %s(s)""" % (len(self.recipients),
+ self.send_to_doctype))
+
+ webnotes.conn.set(self.doc, "email_sent", 1)
+
+ def get_recipients(self):
+ if self.doc.send_to_type=="Contact":
+ self.send_to_doctype = "Contact"
+ if self.doc.contact_type == "Customer":
+ return webnotes.conn.sql_list("""select email_id from tabContact
+ where ifnull(email_id, '') != '' and ifnull(customer, '') != ''""")
+
+ elif self.doc.contact_type == "Supplier":
+ return webnotes.conn.sql_list("""select email_id from tabContact
+ where ifnull(email_id, '') != '' and ifnull(supplier, '') != ''""")
+
+ elif self.doc.send_to_type=="Lead":
+ self.send_to_doctype = "Lead"
+ conditions = []
+ if self.doc.lead_source and self.doc.lead_source != "All":
+ conditions.append(" and source='%s'" % self.doc.lead_source)
+ if self.doc.lead_status and self.doc.lead_status != "All":
+ conditions.append(" and status='%s'" % self.doc.lead_status)
+
+ if conditions:
+ conditions = "".join(conditions)
- if self.doc.blog_subscribers:
- self.send("blog_subscribers", "Lead")
-
- if self.doc.email_list:
+ return webnotes.conn.sql_list("""select email_id from tabLead
+ where ifnull(email_id, '') != '' %s""" % (conditions or ""))
+
+ elif self.doc.email_list:
email_list = [cstr(email).strip() for email in self.doc.email_list.split(",")]
for email in email_list:
if not webnotes.conn.exists({"doctype": "Lead", "email_id": email}):
create_lead(email)
-
- self.send(email_list, "Lead")
-
- webnotes.msgprint("""Scheduled to send to %s""" % \
- ", ".join(["%d %s(s)" % (self.send_count[s], s) for s in self.send_count]))
-
- def test_send(self, doctype="Lead"):
+
+ self.send_to_doctype = "Lead"
+ return email_list
+
+ def send_bulk(self):
self.validate_send()
- args = self.dt_map[doctype]
-
sender = self.doc.send_from or webnotes.utils.get_formatted_email(self.doc.owner)
- recipients = self.doc.test_email_id.split(",")
+
from webnotes.utils.email_lib.bulk import send
- send(recipients = recipients, sender = sender,
- subject = self.doc.subject, message = self.doc.message,
- doctype = doctype, email_field = args["email_field"])
- webnotes.msgprint("""Scheduled to send to %s""" % self.doc.test_email_id)
-
- def get_recipients(self, key):
- recipients = webnotes.conn.sql(self.query_map[key])
- recipients = [r[0] for r in recipients if r not in self.all_recipients]
- self.all_recipients += recipients
- return recipients
-
- def send(self, query_key, doctype):
- self.validate_send()
-
webnotes.conn.auto_commit_on_many_writes = True
- if isinstance(query_key, basestring) and self.query_map.has_key(query_key):
- recipients = self.get_recipients(query_key)
- else:
- recipients = query_key
- sender = self.doc.send_from or webnotes.utils.get_formatted_email(self.doc.owner)
- args = self.dt_map[doctype]
- self.send_count[doctype] = self.send_count.setdefault(doctype, 0) + \
- len(recipients)
- from webnotes.utils.email_lib.bulk import send
- send(recipients = recipients, sender = sender,
+ send(recipients = self.recipients, sender = sender,
subject = self.doc.subject, message = self.doc.message,
- doctype = doctype, email_field = args["email_field"])
+ doctype = self.send_to_doctype, email_field = "email_id")
- webnotes.conn.set(self.doc, "email_sent", 1)
+ webnotes.conn.auto_commit_on_many_writes = False
def validate_send(self):
if self.doc.fields.get("__islocal"):
@@ -130,6 +102,14 @@ class DocType():
webnotes.msgprint(_("""Sending newsletters is not allowed for Trial users, \
to prevent abuse of this feature."""), raise_exception=1)
+@webnotes.whitelist()
+def get_lead_options():
+ return {
+ "sources": ["All"] + webnotes.conn.sql_list("""select distinct source from tabLead"""),
+ "statuses": ["All"]+ webnotes.conn.sql_list("""select distinct status from tabLead""")
+ }
+
+
lead_naming_series = None
def create_lead(email_id):
"""create a lead if it does not exist"""
diff --git a/support/doctype/newsletter/newsletter.txt b/support/doctype/newsletter/newsletter.txt
index 3ffd5a0af8..dbab81ee0a 100644
--- a/support/doctype/newsletter/newsletter.txt
+++ b/support/doctype/newsletter/newsletter.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:31",
"docstatus": 0,
- "modified": "2013-01-28 15:28:59",
+ "modified": "2013-02-11 17:23:08",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -58,33 +58,10 @@
},
{
"doctype": "DocField",
- "fieldname": "contacts",
- "fieldtype": "Check",
- "label": "All Contacts"
- },
- {
- "doctype": "DocField",
- "fieldname": "customer_contacts",
- "fieldtype": "Check",
- "label": "All Customer Contacts"
- },
- {
- "doctype": "DocField",
- "fieldname": "leads",
- "fieldtype": "Check",
- "label": "All Leads"
- },
- {
- "doctype": "DocField",
- "fieldname": "active_leads",
- "fieldtype": "Check",
- "label": "All Active Leads"
- },
- {
- "doctype": "DocField",
- "fieldname": "blog_subscribers",
- "fieldtype": "Check",
- "label": "All Blog Subscribers"
+ "fieldname": "send_to_type",
+ "fieldtype": "Select",
+ "label": "Send To Type",
+ "options": "Lead\nContact\nCustom"
},
{
"doctype": "DocField",
@@ -92,6 +69,29 @@
"fieldtype": "Column Break"
},
{
+ "depends_on": "eval:doc.send_to_type==\"Lead\"",
+ "doctype": "DocField",
+ "fieldname": "lead_source",
+ "fieldtype": "Select",
+ "label": "Lead Source"
+ },
+ {
+ "depends_on": "eval:doc.send_to_type==\"Lead\"",
+ "doctype": "DocField",
+ "fieldname": "lead_status",
+ "fieldtype": "Select",
+ "label": "Lead Status"
+ },
+ {
+ "depends_on": "eval:doc.send_to_type==\"Contact\"",
+ "doctype": "DocField",
+ "fieldname": "contact_type",
+ "fieldtype": "Select",
+ "label": "Contact Type",
+ "options": "Customer\nSupplier\nCustom"
+ },
+ {
+ "depends_on": "eval:doc.send_to_type==\"Custom\"",
"description": "Comma separated list of email addresses",
"doctype": "DocField",
"fieldname": "email_list",
diff --git a/support/doctype/newsletter/test_newsletter.py b/support/doctype/newsletter/test_newsletter.py
new file mode 100644
index 0000000000..98ad21f160
--- /dev/null
+++ b/support/doctype/newsletter/test_newsletter.py
@@ -0,0 +1,58 @@
+import webnotes, unittest
+
+class TestNewsletter(unittest.TestCase):
+ def test_get_recipients_lead(self):
+ w = webnotes.model_wrapper(test_records[0])
+ w.insert()
+ self.assertTrue("test_lead@example.com" in w.controller.get_recipients())
+ webnotes.conn.sql("""delete from `tabBulk Email`""")
+ w.controller.send_emails()
+ self.assertTrue(webnotes.conn.get_value("Bulk Email", {"recipient": "test_lead@example.com"}))
+
+ def test_get_recipients_lead_by_status(self):
+ w = webnotes.model_wrapper(test_records[0])
+ w.doc.lead_status="Converted"
+ w.insert()
+ self.assertTrue("test_lead3@example.com" in w.controller.get_recipients())
+
+ def test_get_recipients_contact_customer(self):
+ w = webnotes.model_wrapper(test_records[1])
+ w.insert()
+ self.assertTrue("test_contact_customer@example.com" in w.controller.get_recipients())
+
+ def test_get_recipients_contact_supplier(self):
+ w = webnotes.model_wrapper(test_records[1])
+ w.doc.contact_type="Supplier"
+ w.insert()
+ self.assertTrue("test_contact_supplier@example.com" in w.controller.get_recipients())
+
+ def test_get_recipients_custom(self):
+ w = webnotes.model_wrapper(test_records[2])
+ w.insert()
+ self.assertTrue("test_custom2@example.com" in w.controller.get_recipients())
+ self.assertTrue(webnotes.conn.get("Lead",
+ {"email_id": "test_custom2@example.com"}))
+
+
+test_dependencies = ["Lead", "Contact"]
+
+test_records =[
+ [{
+ "subject": "_Test Newsletter to Lead",
+ "send_to_type": "Lead",
+ "lead_source": "All",
+ "message": "This is a test newsletter"
+ }],
+ [{
+ "subject": "_Test Newsletter to Contact",
+ "send_to_type": "Contact",
+ "contact_type": "Customer",
+ "message": "This is a test newsletter"
+ }],
+ [{
+ "subject": "_Test Newsletter to Custom",
+ "send_to_type": "Custom",
+ "email_list": "test_custom@example.com, test_custom1@example.com, test_custom2@example.com",
+ "message": "This is a test newsletter"
+ }],
+]
diff --git a/utilities/doctype/contact/test_contact.py b/utilities/doctype/contact/test_contact.py
new file mode 100644
index 0000000000..d16e93d430
--- /dev/null
+++ b/utilities/doctype/contact/test_contact.py
@@ -0,0 +1,22 @@
+test_records = [
+ [{
+ "doctype": "Contact",
+ "customer": "_Test Customer",
+ "customer_name": "_Test Customer",
+ "first_name": "_Test Contact For _Test Customer",
+ "email_id": "test_contact_customer@example.com",
+ "phone": "+91 0000000000",
+ "status": "Open",
+ "is_primary_contact": 1
+ }],
+ [{
+ "doctype": "Contact",
+ "supplier": "_Test Supplier",
+ "supplier_name": "_Test Supplier",
+ "first_name": "_Test Contact For _Test Supplier",
+ "email_id": "test_contact_supplier@example.com",
+ "phone": "+91 0000000000",
+ "status": "Open",
+ "is_primary_contact": 1
+ }]
+]
\ No newline at end of file